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