fix: generic external auth on ui
This commit is contained in:
parent
11e0a03df1
commit
423cfd4bbb
4 changed files with 44 additions and 23 deletions
|
|
@ -29,6 +29,7 @@ const TriggerView = ({
|
|||
toggleWizard,
|
||||
addNewTriger,
|
||||
emailAuth,
|
||||
complianceServices,
|
||||
customInfoRequests
|
||||
}) => {
|
||||
const currency = R.path(['fiatCurrency'])(
|
||||
|
|
@ -78,6 +79,7 @@ const TriggerView = ({
|
|||
save={add}
|
||||
onClose={() => toggleWizard(true)}
|
||||
customInfoRequests={customInfoRequests}
|
||||
complianceServices={complianceServices}
|
||||
emailAuth={emailAuth}
|
||||
triggers={triggers}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,12 @@ const GET_CONFIG = gql`
|
|||
query getData {
|
||||
config
|
||||
accounts
|
||||
accountsConfig {
|
||||
code
|
||||
display
|
||||
class
|
||||
cryptos
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
|
|
@ -75,6 +81,9 @@ const Triggers = () => {
|
|||
const emailAuth =
|
||||
data?.config?.triggersConfig_customerAuthentication === 'EMAIL'
|
||||
|
||||
const complianceServices = R.filter(R.propEq('class', 'compliance'))(
|
||||
data?.accountsConfig || []
|
||||
)
|
||||
const triggers = fromServer(data?.config?.triggers ?? [])
|
||||
const complianceConfig =
|
||||
data?.config && fromNamespace('compliance')(data.config)
|
||||
|
|
@ -220,6 +229,7 @@ const Triggers = () => {
|
|||
toggleWizard={toggleWizard('newTrigger')}
|
||||
addNewTriger={addNewTriger}
|
||||
emailAuth={emailAuth}
|
||||
complianceServices={complianceServices}
|
||||
customInfoRequests={enabledCustomInfoRequests}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ const getStep = (
|
|||
{ step, config },
|
||||
currency,
|
||||
customInfoRequests,
|
||||
complianceServices,
|
||||
emailAuth,
|
||||
triggers
|
||||
) => {
|
||||
|
|
@ -61,7 +62,13 @@ const getStep = (
|
|||
case 1:
|
||||
return type(currency)
|
||||
case 2:
|
||||
return requirements(config, triggers, customInfoRequests, emailAuth)
|
||||
return requirements(
|
||||
config,
|
||||
triggers,
|
||||
customInfoRequests,
|
||||
complianceServices,
|
||||
emailAuth
|
||||
)
|
||||
default:
|
||||
return Fragment
|
||||
}
|
||||
|
|
@ -218,6 +225,7 @@ const Wizard = ({
|
|||
error,
|
||||
currency,
|
||||
customInfoRequests,
|
||||
complianceServices,
|
||||
emailAuth,
|
||||
triggers
|
||||
}) => {
|
||||
|
|
@ -233,6 +241,7 @@ const Wizard = ({
|
|||
{ step, config },
|
||||
currency,
|
||||
customInfoRequests,
|
||||
complianceServices,
|
||||
emailAuth,
|
||||
triggers
|
||||
)
|
||||
|
|
|
|||
|
|
@ -556,7 +556,8 @@ const requirementOptions = [
|
|||
{ display: 'US SSN', code: 'usSsn' },
|
||||
// { display: 'Super user', code: 'superuser' },
|
||||
{ display: 'Suspend', code: 'suspend' },
|
||||
{ display: 'Block', code: 'block' }
|
||||
{ display: 'Block', code: 'block' },
|
||||
{ display: 'External Verification', code: 'external' }
|
||||
]
|
||||
|
||||
const hasRequirementError = (errors, touched, values) =>
|
||||
|
|
@ -580,6 +581,7 @@ const Requirement = ({
|
|||
config = {},
|
||||
triggers,
|
||||
emailAuth,
|
||||
complianceServices,
|
||||
customInfoRequests = []
|
||||
}) => {
|
||||
const classes = useStyles()
|
||||
|
|
@ -624,27 +626,17 @@ const Requirement = ({
|
|||
}))
|
||||
|
||||
const enableCustomRequirement = !R.isEmpty(availableCustomRequirements)
|
||||
const enableExternalRequirement = !R.any(
|
||||
// TODO: right now this condition is directly related with sumsub. On adding external validation, this needs to be generalized
|
||||
ite => ite.requirement === 'external' && ite.externalService === 'sumsub',
|
||||
R.map(it => ({
|
||||
requirement: it.requirement.requirement,
|
||||
externalService: it.requirement.externalService
|
||||
}))(triggers)
|
||||
)
|
||||
|
||||
const customInfoOption = {
|
||||
display: 'Custom information requirement',
|
||||
code: 'custom'
|
||||
}
|
||||
const externalOption = { display: 'External verification', code: 'external' }
|
||||
|
||||
const itemToRemove = emailAuth ? 'sms' : 'email'
|
||||
const reqOptions = requirementOptions.filter(it => it.code !== itemToRemove)
|
||||
const options = R.clone(reqOptions)
|
||||
|
||||
enableCustomRequirement && options.push(customInfoOption)
|
||||
enableExternalRequirement && options.push(externalOption)
|
||||
|
||||
const titleClass = {
|
||||
[classes.error]:
|
||||
|
|
@ -654,13 +646,6 @@ const Requirement = ({
|
|||
(isExternal && hasExternalRequirementError(errors, touched, values))
|
||||
}
|
||||
|
||||
const externalServices = [
|
||||
{
|
||||
value: 'sumsub',
|
||||
display: 'Sumsub'
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box display="flex" alignItems="center">
|
||||
|
|
@ -708,7 +693,10 @@ const Requirement = ({
|
|||
component={Dropdown}
|
||||
label="Service"
|
||||
name="requirement.externalService"
|
||||
options={externalServices}
|
||||
options={complianceServices.map(it => ({
|
||||
value: it.code,
|
||||
display: it.display
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -716,11 +704,23 @@ const Requirement = ({
|
|||
)
|
||||
}
|
||||
|
||||
const requirements = (config, triggers, customInfoRequests, emailAuth) => ({
|
||||
const requirements = (
|
||||
config,
|
||||
triggers,
|
||||
customInfoRequests,
|
||||
complianceServices,
|
||||
emailAuth
|
||||
) => ({
|
||||
schema: requirementSchema,
|
||||
options: requirementOptions,
|
||||
Component: Requirement,
|
||||
props: { config, triggers, customInfoRequests, emailAuth },
|
||||
props: {
|
||||
config,
|
||||
triggers,
|
||||
customInfoRequests,
|
||||
emailAuth,
|
||||
complianceServices
|
||||
},
|
||||
hasRequirementError: hasRequirementError,
|
||||
hasCustomRequirementError: hasCustomRequirementError,
|
||||
hasExternalRequirementError: hasExternalRequirementError,
|
||||
|
|
@ -804,7 +804,7 @@ const RequirementView = ({
|
|||
R.find(customReqIdMatches(customInfoRequestId))(customInfoRequests)
|
||||
) ?? ''
|
||||
: requirement === 'external'
|
||||
? `External validation (${onlyFirstToUpper(externalService)})`
|
||||
? `External Verification (${onlyFirstToUpper(externalService)})`
|
||||
: getView(requirementOptions, 'display')(requirement)
|
||||
const isSuspend = requirement === 'suspend'
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue