feat: mock-email and some fixes for email auth
This commit is contained in:
parent
ab304093f3
commit
c173f241eb
10 changed files with 97 additions and 26 deletions
|
|
@ -31,7 +31,8 @@ const ThirdPartyProvider = () => {
|
|||
}
|
||||
|
||||
const ThirdPartySchema = Yup.object().shape({
|
||||
sms: Yup.string('The sms must be a string').required('The sms is required')
|
||||
sms: Yup.string('SMS must be a string').required('SMS is required'),
|
||||
email: Yup.string('Email must be a string').required('Email is required')
|
||||
})
|
||||
|
||||
const elements = [
|
||||
|
|
@ -46,14 +47,30 @@ const ThirdPartyProvider = () => {
|
|||
valueProp: 'code',
|
||||
labelProp: 'display'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'email',
|
||||
size: 'sm',
|
||||
view: getDisplayName('email'),
|
||||
width: 175,
|
||||
input: Autocomplete,
|
||||
inputProps: {
|
||||
options: filterOptions('email'),
|
||||
valueProp: 'code',
|
||||
labelProp: 'display'
|
||||
}
|
||||
}
|
||||
]
|
||||
const values = {
|
||||
sms: data.sms ?? 'twilio',
|
||||
email: data.email ?? 'mailgun'
|
||||
}
|
||||
|
||||
return (
|
||||
<EditableTable
|
||||
name="thirdParty"
|
||||
initialValues={{ sms: data.sms ?? 'twilio' }}
|
||||
data={R.of({ sms: data.sms ?? 'twilio' })}
|
||||
initialValues={values}
|
||||
data={R.of(values)}
|
||||
error={error?.message}
|
||||
enableEdit
|
||||
editWidth={174}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ const TriggerView = ({
|
|||
config,
|
||||
toggleWizard,
|
||||
addNewTriger,
|
||||
customInfoRequests
|
||||
customInfoRequests,
|
||||
emailAuth
|
||||
}) => {
|
||||
const currency = R.path(['fiatCurrency'])(
|
||||
fromNamespace(namespaces.LOCALE)(config)
|
||||
|
|
@ -77,6 +78,7 @@ const TriggerView = ({
|
|||
save={add}
|
||||
onClose={() => toggleWizard(true)}
|
||||
customInfoRequests={customInfoRequests}
|
||||
emailAuth={emailAuth}
|
||||
/>
|
||||
)}
|
||||
{R.isEmpty(triggers) && (
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ const GET_CUSTOM_REQUESTS = gql`
|
|||
const Triggers = () => {
|
||||
const classes = useStyles()
|
||||
const [wizardType, setWizard] = useState(false)
|
||||
const { data, loading: configLoading } = useQuery(GET_CONFIG)
|
||||
const { data, loading: configLoading, refetch } = useQuery(GET_CONFIG)
|
||||
const { data: customInfoReqData, loading: customInfoLoading } = useQuery(
|
||||
GET_CUSTOM_REQUESTS
|
||||
)
|
||||
|
|
@ -72,6 +72,8 @@ const Triggers = () => {
|
|||
const enabledCustomInfoRequests = R.filter(R.propEq('enabled', true))(
|
||||
customInfoRequests
|
||||
)
|
||||
const emailAuth =
|
||||
data?.config?.triggersConfig_customerAuthentication === 'EMAIL'
|
||||
|
||||
const triggers = fromServer(data?.config?.triggers ?? [])
|
||||
const complianceConfig =
|
||||
|
|
@ -141,6 +143,7 @@ const Triggers = () => {
|
|||
inverseIcon: ReverseSettingsIcon,
|
||||
forceDisable: !(subMenu === 'advancedSettings'),
|
||||
toggle: show => {
|
||||
refetch()
|
||||
setSubMenu(show ? 'advancedSettings' : false)
|
||||
}
|
||||
},
|
||||
|
|
@ -150,6 +153,7 @@ const Triggers = () => {
|
|||
inverseIcon: ReverseCustomInfoIcon,
|
||||
forceDisable: !(subMenu === 'customInfoRequests'),
|
||||
toggle: show => {
|
||||
refetch()
|
||||
setSubMenu(show ? 'customInfoRequests' : false)
|
||||
}
|
||||
}
|
||||
|
|
@ -216,6 +220,7 @@ const Triggers = () => {
|
|||
toggleWizard={toggleWizard('newTrigger')}
|
||||
addNewTriger={addNewTriger}
|
||||
customInfoRequests={enabledCustomInfoRequests}
|
||||
emailAuth={emailAuth}
|
||||
/>
|
||||
)}
|
||||
{!loading && subMenu === 'advancedSettings' && (
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ const styles = {
|
|||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
const getStep = (step, currency, customInfoRequests) => {
|
||||
const getStep = (step, currency, customInfoRequests, emailAuth) => {
|
||||
switch (step) {
|
||||
// case 1:
|
||||
// return txDirection
|
||||
case 1:
|
||||
return type(currency)
|
||||
case 2:
|
||||
return requirements(customInfoRequests)
|
||||
return requirements(customInfoRequests, emailAuth)
|
||||
default:
|
||||
return Fragment
|
||||
}
|
||||
|
|
@ -204,7 +204,14 @@ const GetValues = ({ setValues }) => {
|
|||
return null
|
||||
}
|
||||
|
||||
const Wizard = ({ onClose, save, error, currency, customInfoRequests }) => {
|
||||
const Wizard = ({
|
||||
onClose,
|
||||
save,
|
||||
error,
|
||||
currency,
|
||||
customInfoRequests,
|
||||
emailAuth
|
||||
}) => {
|
||||
const classes = useStyles()
|
||||
|
||||
const [liveValues, setLiveValues] = useState({})
|
||||
|
|
@ -213,7 +220,7 @@ const Wizard = ({ onClose, save, error, currency, customInfoRequests }) => {
|
|||
})
|
||||
|
||||
const isLastStep = step === LAST_STEP
|
||||
const stepOptions = getStep(step, currency, customInfoRequests)
|
||||
const stepOptions = getStep(step, currency, customInfoRequests, emailAuth)
|
||||
|
||||
const onContinue = async it => {
|
||||
const newConfig = R.merge(config, stepOptions.schema.cast(it))
|
||||
|
|
|
|||
|
|
@ -545,7 +545,7 @@ const hasCustomRequirementError = (errors, touched, values) =>
|
|||
(!values.requirement?.customInfoRequestId ||
|
||||
!R.isNil(values.requirement?.customInfoRequestId))
|
||||
|
||||
const Requirement = ({ customInfoRequests }) => {
|
||||
const Requirement = ({ customInfoRequests, emailAuth }) => {
|
||||
const classes = useStyles()
|
||||
const {
|
||||
touched,
|
||||
|
|
@ -568,9 +568,11 @@ const Requirement = ({ customInfoRequests }) => {
|
|||
display: 'Custom information requirement',
|
||||
code: 'custom'
|
||||
}
|
||||
const itemToRemove = emailAuth ? 'sms' : 'email'
|
||||
const reqOptions = requirementOptions.filter(it => it.code !== itemToRemove)
|
||||
const options = enableCustomRequirement
|
||||
? [...requirementOptions, customInfoOption]
|
||||
: [...requirementOptions]
|
||||
? [...reqOptions, customInfoOption]
|
||||
: [...reqOptions]
|
||||
const titleClass = {
|
||||
[classes.error]:
|
||||
(!!errors.requirement && !isSuspend && !isCustom) ||
|
||||
|
|
@ -622,11 +624,11 @@ const Requirement = ({ customInfoRequests }) => {
|
|||
)
|
||||
}
|
||||
|
||||
const requirements = customInfoRequests => ({
|
||||
const requirements = (customInfoRequests, emailAuth) => ({
|
||||
schema: requirementSchema,
|
||||
options: requirementOptions,
|
||||
Component: Requirement,
|
||||
props: { customInfoRequests },
|
||||
props: { customInfoRequests, emailAuth },
|
||||
hasRequirementError: hasRequirementError,
|
||||
hasCustomRequirementError: hasCustomRequirementError,
|
||||
initialValues: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue