fix: button new comet3 color, replace lodash with ramda
This commit is contained in:
parent
a35dd3e77e
commit
e3b13a228b
4 changed files with 74 additions and 70 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
import typographyStyles from 'src/components/typography/styles'
|
import typographyStyles from 'src/components/typography/styles'
|
||||||
import {
|
import {
|
||||||
white,
|
white,
|
||||||
fontColor,
|
|
||||||
subheaderColor,
|
subheaderColor,
|
||||||
subheaderDarkColor,
|
subheaderDarkColor,
|
||||||
offColor,
|
offColor,
|
||||||
offDarkColor,
|
offDarkColor,
|
||||||
|
offDarkerColor,
|
||||||
secondaryColor,
|
secondaryColor,
|
||||||
secondaryColorDark,
|
secondaryColorDark,
|
||||||
secondaryColorDarker,
|
secondaryColorDarker,
|
||||||
|
|
@ -56,10 +56,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
secondary: {
|
secondary: {
|
||||||
extend: colors(offColor, offDarkColor, white),
|
extend: colors(offColor, offDarkColor, offDarkerColor),
|
||||||
color: white,
|
color: white,
|
||||||
'&:active': {
|
'&:active': {
|
||||||
color: fontColor,
|
|
||||||
'& $actionButtonIcon': {
|
'& $actionButtonIcon': {
|
||||||
display: 'flex'
|
display: 'flex'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ 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)
|
||||||
|
|
||||||
|
|
@ -59,7 +60,6 @@ const Photo = ({ show, src }) => {
|
||||||
const CustomerData = ({
|
const CustomerData = ({
|
||||||
customer,
|
customer,
|
||||||
updateCustomer,
|
updateCustomer,
|
||||||
replacePhoto,
|
|
||||||
editCustomer,
|
editCustomer,
|
||||||
deleteEditedData
|
deleteEditedData
|
||||||
}) => {
|
}) => {
|
||||||
|
|
@ -68,6 +68,7 @@ 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)
|
||||||
|
|
@ -83,43 +84,54 @@ const CustomerData = ({
|
||||||
|
|
||||||
const isEven = elem => elem % 2 === 0
|
const isEven = elem => elem % 2 === 0
|
||||||
|
|
||||||
const getVisibleCards = _.filter(elem => elem.isAvailable)
|
const getVisibleCards = _.filter(
|
||||||
|
elem =>
|
||||||
|
!_.isEmpty(elem.fields) ||
|
||||||
|
(!_.isNil(elem.children) && !_.isNil(elem.state))
|
||||||
|
)
|
||||||
|
|
||||||
|
const getAvailableFields = _.filter(({ value }) => value !== '')
|
||||||
|
|
||||||
const schemas = {
|
const schemas = {
|
||||||
idScan: Yup.object().shape({
|
idScan: Yup.object().shape({
|
||||||
firstName: Yup.string().required(),
|
name: Yup.string(),
|
||||||
lastName: Yup.string().required(),
|
idNumber: Yup.string(),
|
||||||
documentNumber: Yup.string().required(),
|
birthDate: Yup.string(),
|
||||||
dateOfBirth: Yup.string().required(),
|
age: Yup.string(),
|
||||||
gender: Yup.string().required(),
|
gender: Yup.string(),
|
||||||
country: Yup.string().required(),
|
state: Yup.string(),
|
||||||
expirationDate: Yup.string().required()
|
expirationDate: Yup.string()
|
||||||
}),
|
}),
|
||||||
usSsn: Yup.object().shape({
|
usSsn: Yup.object().shape({
|
||||||
usSsn: Yup.string().required()
|
usSsn: Yup.string()
|
||||||
}),
|
}),
|
||||||
idCardPhoto: Yup.object().shape({
|
idCardPhoto: Yup.object().shape({
|
||||||
idCardPhoto: Yup.mixed().required()
|
idCardPhoto: Yup.mixed()
|
||||||
}),
|
}),
|
||||||
frontCamera: Yup.object().shape({
|
frontCamera: Yup.object().shape({
|
||||||
frontCamera: Yup.mixed().required()
|
frontCamera: Yup.mixed()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const idScanElements = [
|
const idScanElements = [
|
||||||
{
|
{
|
||||||
name: 'firstName',
|
name: 'name',
|
||||||
label: 'First name',
|
label: 'Name',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'documentNumber',
|
name: 'idNumber',
|
||||||
label: 'ID number',
|
label: 'ID number',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'dateOfBirth',
|
name: 'birthDate',
|
||||||
label: 'Birthdate',
|
label: 'Birth Date',
|
||||||
|
component: TextInput
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'age',
|
||||||
|
label: 'Age',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -128,19 +140,14 @@ const CustomerData = ({
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'lastName',
|
name: 'state',
|
||||||
label: 'Last name',
|
label: country === 'Canada' ? 'Province' : 'State',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'expirationDate',
|
name: 'expirationDate',
|
||||||
label: 'Expiration Date',
|
label: 'Expiration Date',
|
||||||
component: TextInput
|
component: TextInput
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'country',
|
|
||||||
label: 'Country',
|
|
||||||
component: TextInput
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -158,14 +165,27 @@ const CustomerData = ({
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
idScan: {
|
idScan: {
|
||||||
firstName: R.path(['firstName'])(idData) ?? '',
|
name: getName(customer) ?? '',
|
||||||
lastName: R.path(['lastName'])(idData) ?? '',
|
idNumber: R.path(['documentNumber'])(idData) ?? '',
|
||||||
documentNumber: R.path(['documentNumber'])(idData) ?? '',
|
birthDate:
|
||||||
dateOfBirth: (rawDob && format('yyyy-MM-dd', rawDob)) ?? '',
|
(rawDob &&
|
||||||
|
format('yyyy-MM-dd')(parse(new Date(), 'yyyyMMdd', rawDob))) ??
|
||||||
|
'',
|
||||||
|
age:
|
||||||
|
(rawDob &&
|
||||||
|
differenceInYears(
|
||||||
|
parse(new Date(), 'yyyyMMdd', rawDob),
|
||||||
|
new Date()
|
||||||
|
)) ??
|
||||||
|
'',
|
||||||
gender: R.path(['gender'])(idData) ?? '',
|
gender: R.path(['gender'])(idData) ?? '',
|
||||||
country: R.path(['country'])(idData) ?? '',
|
state: R.path(['state'])(idData) ?? '',
|
||||||
expirationDate:
|
expirationDate:
|
||||||
(rawExpirationDate && format('yyyy-MM-dd', rawExpirationDate)) ?? ''
|
(rawExpirationDate &&
|
||||||
|
format('yyyy-MM-dd')(
|
||||||
|
parse(new Date(), 'yyyyMMdd', rawExpirationDate)
|
||||||
|
)) ??
|
||||||
|
''
|
||||||
},
|
},
|
||||||
usSsn: {
|
usSsn: {
|
||||||
usSsn: customer.usSsn ?? ''
|
usSsn: customer.usSsn ?? ''
|
||||||
|
|
@ -180,34 +200,31 @@ const CustomerData = ({
|
||||||
|
|
||||||
const cards = [
|
const cards = [
|
||||||
{
|
{
|
||||||
fields: idScanElements,
|
fields: getAvailableFields(idScanElements),
|
||||||
title: 'ID Scan',
|
title: 'ID Scan',
|
||||||
titleIcon: <CardIcon className={classes.cardIcon} />,
|
titleIcon: <PhoneIcon 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: _.merge(idData, values) }),
|
save: values => editCustomer({ idCardData: values }),
|
||||||
validationSchema: schemas.idScan,
|
validationSchema: schemas.idScan,
|
||||||
initialValues: initialValues.idScan,
|
initialValues: initialValues.idScan
|
||||||
isAvailable: !_.isNil(idData)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'SMS Confirmation',
|
title: 'SMS Confirmation',
|
||||||
titleIcon: <PhoneIcon className={classes.cardIcon} />,
|
titleIcon: <CardIcon className={classes.cardIcon} />,
|
||||||
authorize: () => {},
|
authorize: () => {},
|
||||||
reject: () => {},
|
reject: () => {},
|
||||||
save: () => {},
|
save: () => {}
|
||||||
isAvailable: false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Name',
|
title: 'Name',
|
||||||
titleIcon: <EditIcon className={classes.editIcon} />,
|
titleIcon: <EditIcon className={classes.editIcon} />,
|
||||||
authorize: () => {},
|
authorize: () => {},
|
||||||
reject: () => {},
|
reject: () => {},
|
||||||
save: () => {},
|
save: () => {}
|
||||||
isAvailable: false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Sanctions check',
|
title: 'Sanctions check',
|
||||||
|
|
@ -216,22 +233,17 @@ const CustomerData = ({
|
||||||
authorize: () =>
|
authorize: () =>
|
||||||
updateCustomer({ sanctionsOverride: OVERRIDE_AUTHORIZED }),
|
updateCustomer({ sanctionsOverride: OVERRIDE_AUTHORIZED }),
|
||||||
reject: () => updateCustomer({ sanctionsOverride: OVERRIDE_REJECTED }),
|
reject: () => updateCustomer({ sanctionsOverride: OVERRIDE_REJECTED }),
|
||||||
children: <Info3>{sanctionsDisplay}</Info3>,
|
children: <Info3>{sanctionsDisplay}</Info3>
|
||||||
isAvailable: !_.isNil(sanctions)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fields: frontCameraElements,
|
fields: getAvailableFields(frontCameraElements),
|
||||||
title: 'Front facing camera',
|
title: 'Front facing camera',
|
||||||
titleIcon: <EditIcon className={classes.editIcon} />,
|
titleIcon: <EditIcon className={classes.editIcon} />,
|
||||||
state: R.path(['frontCameraOverride'])(customer),
|
state: R.path(['frontCameraOverride'])(customer),
|
||||||
authorize: () =>
|
authorize: () =>
|
||||||
updateCustomer({ frontCameraOverride: OVERRIDE_AUTHORIZED }),
|
updateCustomer({ frontCameraOverride: OVERRIDE_AUTHORIZED }),
|
||||||
reject: () => updateCustomer({ frontCameraOverride: OVERRIDE_REJECTED }),
|
reject: () => updateCustomer({ frontCameraOverride: OVERRIDE_REJECTED }),
|
||||||
save: values =>
|
save: values => editCustomer({ frontCamera: values.frontCamera }),
|
||||||
replacePhoto({
|
|
||||||
newPhoto: values.frontCamera,
|
|
||||||
photoType: 'frontCamera'
|
|
||||||
}),
|
|
||||||
deleteEditedData: () => deleteEditedData({ frontCamera: null }),
|
deleteEditedData: () => deleteEditedData({ frontCamera: null }),
|
||||||
children: customer.frontCameraPath ? (
|
children: customer.frontCameraPath ? (
|
||||||
<Photo
|
<Photo
|
||||||
|
|
@ -243,22 +255,17 @@ const CustomerData = ({
|
||||||
) : null,
|
) : null,
|
||||||
hasImage: true,
|
hasImage: true,
|
||||||
validationSchema: schemas.frontCamera,
|
validationSchema: schemas.frontCamera,
|
||||||
initialValues: initialValues.frontCamera,
|
initialValues: initialValues.frontCamera
|
||||||
isAvailable: !_.isNil(customer.frontCameraPath)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fields: idCardPhotoElements,
|
fields: getAvailableFields(idCardPhotoElements),
|
||||||
title: 'ID card image',
|
title: 'ID card image',
|
||||||
titleIcon: <EditIcon className={classes.editIcon} />,
|
titleIcon: <EditIcon className={classes.editIcon} />,
|
||||||
state: R.path(['idCardPhotoOverride'])(customer),
|
state: R.path(['idCardPhotoOverride'])(customer),
|
||||||
authorize: () =>
|
authorize: () =>
|
||||||
updateCustomer({ idCardPhotoOverride: OVERRIDE_AUTHORIZED }),
|
updateCustomer({ idCardPhotoOverride: OVERRIDE_AUTHORIZED }),
|
||||||
reject: () => updateCustomer({ idCardPhotoOverride: OVERRIDE_REJECTED }),
|
reject: () => updateCustomer({ idCardPhotoOverride: OVERRIDE_REJECTED }),
|
||||||
save: values =>
|
save: values => editCustomer({ idCardPhoto: values.idCardPhoto }),
|
||||||
replacePhoto({
|
|
||||||
newPhoto: values.idCardPhoto,
|
|
||||||
photoType: 'idCardPhoto'
|
|
||||||
}),
|
|
||||||
deleteEditedData: () => deleteEditedData({ idCardPhoto: null }),
|
deleteEditedData: () => deleteEditedData({ idCardPhoto: null }),
|
||||||
children: customer.idCardPhotoPath ? (
|
children: customer.idCardPhotoPath ? (
|
||||||
<Photo
|
<Photo
|
||||||
|
|
@ -268,11 +275,10 @@ const CustomerData = ({
|
||||||
) : null,
|
) : null,
|
||||||
hasImage: true,
|
hasImage: true,
|
||||||
validationSchema: schemas.idCardPhoto,
|
validationSchema: schemas.idCardPhoto,
|
||||||
initialValues: initialValues.idCardPhoto,
|
initialValues: initialValues.idCardPhoto
|
||||||
isAvailable: !_.isNil(customer.idCardPhotoPath)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fields: usSsnElements,
|
fields: getAvailableFields(usSsnElements),
|
||||||
title: 'US SSN',
|
title: 'US SSN',
|
||||||
titleIcon: <CardIcon className={classes.cardIcon} />,
|
titleIcon: <CardIcon className={classes.cardIcon} />,
|
||||||
state: R.path(['usSsnOverride'])(customer),
|
state: R.path(['usSsnOverride'])(customer),
|
||||||
|
|
@ -281,8 +287,7 @@ const CustomerData = ({
|
||||||
save: values => editCustomer({ usSsn: values.usSsn }),
|
save: values => editCustomer({ usSsn: values.usSsn }),
|
||||||
deleteEditedData: () => deleteEditedData({ usSsn: null }),
|
deleteEditedData: () => deleteEditedData({ usSsn: null }),
|
||||||
validationSchema: schemas.usSsn,
|
validationSchema: schemas.usSsn,
|
||||||
initialValues: initialValues.usSsn,
|
initialValues: initialValues.usSsn
|
||||||
isAvailable: !_.isNil(customer.usSsn)
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,8 @@ import { ReactComponent as EditReversedIcon } from 'src/styling/icons/action/edi
|
||||||
import { ReactComponent as AuthorizeIcon } from 'src/styling/icons/button/authorize/white.svg'
|
import { ReactComponent as AuthorizeIcon } from 'src/styling/icons/button/authorize/white.svg'
|
||||||
import { ReactComponent as BlockIcon } from 'src/styling/icons/button/block/white.svg'
|
import { ReactComponent as BlockIcon } from 'src/styling/icons/button/block/white.svg'
|
||||||
import { ReactComponent as CancelReversedIcon } from 'src/styling/icons/button/cancel/white.svg'
|
import { ReactComponent as CancelReversedIcon } from 'src/styling/icons/button/cancel/white.svg'
|
||||||
import { ReactComponent as CancelIcon } from 'src/styling/icons/button/cancel/zodiac.svg'
|
|
||||||
import { ReactComponent as ReplaceReversedIcon } from 'src/styling/icons/button/replace/white.svg'
|
import { ReactComponent as ReplaceReversedIcon } from 'src/styling/icons/button/replace/white.svg'
|
||||||
import { ReactComponent as ReplaceIcon } from 'src/styling/icons/button/replace/zodiac.svg'
|
|
||||||
import { ReactComponent as SaveReversedIcon } from 'src/styling/icons/circle buttons/save/white.svg'
|
import { ReactComponent as SaveReversedIcon } from 'src/styling/icons/circle buttons/save/white.svg'
|
||||||
import { ReactComponent as SaveIcon } from 'src/styling/icons/circle buttons/save/zodiac.svg'
|
|
||||||
import { comet } from 'src/styling/variables'
|
import { comet } from 'src/styling/variables'
|
||||||
|
|
||||||
import styles from './EditableCard.styles.js'
|
import styles from './EditableCard.styles.js'
|
||||||
|
|
@ -237,7 +234,7 @@ const EditableCard = ({
|
||||||
<ActionButton
|
<ActionButton
|
||||||
color="secondary"
|
color="secondary"
|
||||||
type="button"
|
type="button"
|
||||||
Icon={ReplaceIcon}
|
Icon={ReplaceReversedIcon}
|
||||||
InverseIcon={ReplaceReversedIcon}
|
InverseIcon={ReplaceReversedIcon}
|
||||||
onClick={() => triggerInput()}>
|
onClick={() => triggerInput()}>
|
||||||
{
|
{
|
||||||
|
|
@ -266,7 +263,7 @@ const EditableCard = ({
|
||||||
<div className={classes.button}>
|
<div className={classes.button}>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
color="secondary"
|
color="secondary"
|
||||||
Icon={SaveIcon}
|
Icon={SaveReversedIcon}
|
||||||
InverseIcon={SaveReversedIcon}
|
InverseIcon={SaveReversedIcon}
|
||||||
type="submit">
|
type="submit">
|
||||||
Save
|
Save
|
||||||
|
|
@ -276,7 +273,7 @@ const EditableCard = ({
|
||||||
<div className={classes.button}>
|
<div className={classes.button}>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
color="secondary"
|
color="secondary"
|
||||||
Icon={CancelIcon}
|
Icon={CancelReversedIcon}
|
||||||
InverseIcon={CancelReversedIcon}
|
InverseIcon={CancelReversedIcon}
|
||||||
type="reset">
|
type="reset">
|
||||||
Cancel
|
Cancel
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ const spring = '#48f694'
|
||||||
// Secondary
|
// Secondary
|
||||||
const comet = '#5f668a'
|
const comet = '#5f668a'
|
||||||
const comet2 = '#72799d'
|
const comet2 = '#72799d'
|
||||||
|
const comet3 = '#525772'
|
||||||
const spring2 = '#44e188'
|
const spring2 = '#44e188'
|
||||||
const spring3 = '#ecfbef'
|
const spring3 = '#ecfbef'
|
||||||
const spring4 = '#3fd07e'
|
const spring4 = '#3fd07e'
|
||||||
|
|
@ -47,6 +48,7 @@ const disabledColor2 = concrete
|
||||||
const fontColor = primaryColor
|
const fontColor = primaryColor
|
||||||
const offColor = comet
|
const offColor = comet
|
||||||
const offDarkColor = comet2
|
const offDarkColor = comet2
|
||||||
|
const offDarkerColor = comet3
|
||||||
const placeholderColor = comet
|
const placeholderColor = comet
|
||||||
const errorColor = tomato
|
const errorColor = tomato
|
||||||
const errorColorDark = tomato1
|
const errorColorDark = tomato1
|
||||||
|
|
@ -146,6 +148,7 @@ export {
|
||||||
placeholderColor,
|
placeholderColor,
|
||||||
offColor,
|
offColor,
|
||||||
offDarkColor,
|
offDarkColor,
|
||||||
|
offDarkerColor,
|
||||||
fontColor,
|
fontColor,
|
||||||
disabledColor,
|
disabledColor,
|
||||||
disabledColor2,
|
disabledColor2,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue