fix: forms keys names and img size
This commit is contained in:
parent
b77b732bcb
commit
3667d8b655
1 changed files with 30 additions and 32 deletions
|
|
@ -26,7 +26,6 @@ import { URI } from 'src/utils/apollo'
|
||||||
|
|
||||||
import styles from './CustomerData.styles.js'
|
import styles from './CustomerData.styles.js'
|
||||||
import { EditableCard } from './components'
|
import { EditableCard } from './components'
|
||||||
import { getName } from './helper.js'
|
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
|
|
@ -69,7 +68,6 @@ const CustomerData = ({
|
||||||
|
|
||||||
const idData = R.path(['idCardData'])(customer)
|
const idData = R.path(['idCardData'])(customer)
|
||||||
const rawExpirationDate = R.path(['expirationDate'])(idData)
|
const rawExpirationDate = R.path(['expirationDate'])(idData)
|
||||||
const country = R.path(['country'])(idData)
|
|
||||||
const rawDob = R.path(['dateOfBirth'])(idData)
|
const rawDob = R.path(['dateOfBirth'])(idData)
|
||||||
|
|
||||||
const sanctions = R.path(['sanctions'])(customer)
|
const sanctions = R.path(['sanctions'])(customer)
|
||||||
|
|
@ -89,44 +87,39 @@ const CustomerData = ({
|
||||||
|
|
||||||
const schemas = {
|
const schemas = {
|
||||||
idScan: Yup.object().shape({
|
idScan: Yup.object().shape({
|
||||||
name: Yup.string(),
|
firstName: Yup.string().required(),
|
||||||
idNumber: Yup.string(),
|
lastName: Yup.string().required(),
|
||||||
birthDate: Yup.string(),
|
documentNumber: Yup.string().required(),
|
||||||
age: Yup.string(),
|
dateOfBirth: Yup.string().required(),
|
||||||
gender: Yup.string(),
|
gender: Yup.string().required(),
|
||||||
state: Yup.string(),
|
country: Yup.string().required(),
|
||||||
expirationDate: Yup.string()
|
expirationDate: Yup.string().required()
|
||||||
}),
|
}),
|
||||||
usSsn: Yup.object().shape({
|
usSsn: Yup.object().shape({
|
||||||
usSsn: Yup.string()
|
usSsn: Yup.string().required()
|
||||||
}),
|
}),
|
||||||
idCardPhoto: Yup.object().shape({
|
idCardPhoto: Yup.object().shape({
|
||||||
idCardPhoto: Yup.mixed()
|
idCardPhoto: Yup.mixed().required()
|
||||||
}),
|
}),
|
||||||
frontCamera: Yup.object().shape({
|
frontCamera: Yup.object().shape({
|
||||||
frontCamera: Yup.mixed()
|
frontCamera: Yup.mixed().required()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const idScanElements = [
|
const idScanElements = [
|
||||||
{
|
{
|
||||||
name: 'name',
|
name: 'firstName',
|
||||||
label: 'Name',
|
label: 'First name',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'idNumber',
|
name: 'documentNumber',
|
||||||
label: 'ID number',
|
label: 'ID number',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'birthDate',
|
name: 'dateOfBirth',
|
||||||
label: 'Birth Date',
|
label: 'Birthdate',
|
||||||
component: TextInput
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'age',
|
|
||||||
label: 'Age',
|
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -135,14 +128,19 @@ const CustomerData = ({
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'state',
|
name: 'lastName',
|
||||||
label: country === 'Canada' ? 'Province' : 'State',
|
label: 'Last name',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'expirationDate',
|
name: 'expirationDate',
|
||||||
label: 'Expiration Date',
|
label: 'Expiration Date',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'country',
|
||||||
|
label: 'Country',
|
||||||
|
component: TextInput
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -160,12 +158,12 @@ const CustomerData = ({
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
idScan: {
|
idScan: {
|
||||||
name: getName(customer) ?? '',
|
firstName: R.path(['firstName'])(idData) ?? '',
|
||||||
idNumber: R.path(['documentNumber'])(idData) ?? '',
|
lastName: R.path(['lastName'])(idData) ?? '',
|
||||||
birthDate: (rawDob && format('yyyy-MM-dd', rawDob)) ?? '',
|
documentNumber: R.path(['documentNumber'])(idData) ?? '',
|
||||||
age: (rawDob && differenceInYears(rawDob, new Date())) ?? '',
|
dateOfBirth: (rawDob && format('yyyy-MM-dd', rawDob)) ?? '',
|
||||||
gender: R.path(['gender'])(idData) ?? '',
|
gender: R.path(['gender'])(idData) ?? '',
|
||||||
state: R.path(['state'])(idData) ?? '',
|
country: R.path(['country'])(idData) ?? '',
|
||||||
expirationDate:
|
expirationDate:
|
||||||
(rawExpirationDate && format('yyyy-MM-dd', rawExpirationDate)) ?? ''
|
(rawExpirationDate && format('yyyy-MM-dd', rawExpirationDate)) ?? ''
|
||||||
},
|
},
|
||||||
|
|
@ -184,20 +182,20 @@ const CustomerData = ({
|
||||||
{
|
{
|
||||||
fields: idScanElements,
|
fields: idScanElements,
|
||||||
title: 'ID Scan',
|
title: 'ID Scan',
|
||||||
titleIcon: <PhoneIcon className={classes.cardIcon} />,
|
titleIcon: <CardIcon className={classes.cardIcon} />,
|
||||||
state: R.path(['idCardDataOverride'])(customer),
|
state: R.path(['idCardDataOverride'])(customer),
|
||||||
authorize: () =>
|
authorize: () =>
|
||||||
updateCustomer({ idCardDataOverride: OVERRIDE_AUTHORIZED }),
|
updateCustomer({ idCardDataOverride: OVERRIDE_AUTHORIZED }),
|
||||||
reject: () => updateCustomer({ idCardDataOverride: OVERRIDE_REJECTED }),
|
reject: () => updateCustomer({ idCardDataOverride: OVERRIDE_REJECTED }),
|
||||||
deleteEditedData: () => deleteEditedData({ idCardData: null }),
|
deleteEditedData: () => deleteEditedData({ idCardData: null }),
|
||||||
save: values => editCustomer({ idCardData: values }),
|
save: values => editCustomer({ idCardData: _.merge(idData, values) }),
|
||||||
validationSchema: schemas.idScan,
|
validationSchema: schemas.idScan,
|
||||||
initialValues: initialValues.idScan,
|
initialValues: initialValues.idScan,
|
||||||
isAvailable: !_.isNil(idData)
|
isAvailable: !_.isNil(idData)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'SMS Confirmation',
|
title: 'SMS Confirmation',
|
||||||
titleIcon: <CardIcon className={classes.cardIcon} />,
|
titleIcon: <PhoneIcon className={classes.cardIcon} />,
|
||||||
authorize: () => {},
|
authorize: () => {},
|
||||||
reject: () => {},
|
reject: () => {},
|
||||||
save: () => {},
|
save: () => {},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue