From 894161a99875a6ab1e70786bfa3a3a6638fb6603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Wed, 22 Dec 2021 14:43:10 +0000 Subject: [PATCH] feat: sms data card info --- .../src/pages/Customers/CustomerData.js | 18 +++++++++++++++--- .../src/pages/Customers/CustomerProfile.js | 2 ++ .../pages/Customers/components/EditableCard.js | 3 ++- .../src/pages/Customers/helper.js | 10 +++++++++- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/new-lamassu-admin/src/pages/Customers/CustomerData.js b/new-lamassu-admin/src/pages/Customers/CustomerData.js index 3e1ba8fa..27e0e443 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomerData.js +++ b/new-lamassu-admin/src/pages/Customers/CustomerData.js @@ -29,7 +29,8 @@ import { EditableCard } from './components' import { customerDataElements, customerDataSchemas, - formatDates + formatDates, + getFormattedPhone } from './helper.js' const useStyles = makeStyles(styles) @@ -62,6 +63,7 @@ const Photo = ({ show, src }) => { } const CustomerData = ({ + locale, customer, updateCustomer, replacePhoto, @@ -96,6 +98,9 @@ const CustomerData = ({ R.path(['customInfoRequests'])(customer) ?? [] ) + const phone = R.path(['phone'])(customer) + const smsData = R.path(['subscriberInfo'])(customer) + const isEven = elem => elem % 2 === 0 const getVisibleCards = _.filter(elem => elem.isAvailable) @@ -126,6 +131,9 @@ const CustomerData = ({ }, idCardPhoto: { idCardPhoto: null + }, + smsData: { + phoneNumber: getFormattedPhone(phone, locale.country) } } @@ -148,12 +156,16 @@ const CustomerData = ({ isAvailable: !_.isNil(idData) }, { - title: 'SMS Confirmation', + fields: customerDataElements.smsData, + title: 'SMS data', titleIcon: , authorize: () => {}, reject: () => {}, save: () => {}, - isAvailable: false + validationSchema: customerDataSchemas.smsData, + initialValues: initialValues.smsData, + isAvailable: !_.isNil(phone), + isDeletable: !_.isNil(smsData) || !_.isEmpty(smsData.result) }, { title: 'Name', diff --git a/new-lamassu-admin/src/pages/Customers/CustomerProfile.js b/new-lamassu-admin/src/pages/Customers/CustomerProfile.js index 5a0d2314..9c38bdfa 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomerProfile.js +++ b/new-lamassu-admin/src/pages/Customers/CustomerProfile.js @@ -69,6 +69,7 @@ const GET_CUSTOMER = gql` daysSuspended isSuspended isTestCustomer + subscriberInfo customFields { id label @@ -628,6 +629,7 @@ const CustomerProfile = memo(() => { {isCustomerData && (
{ const classes = useStyles() diff --git a/new-lamassu-admin/src/pages/Customers/helper.js b/new-lamassu-admin/src/pages/Customers/helper.js index 9c980a33..990b091e 100644 --- a/new-lamassu-admin/src/pages/Customers/helper.js +++ b/new-lamassu-admin/src/pages/Customers/helper.js @@ -397,7 +397,12 @@ const customerDataElements = { } ], idCardPhoto: [{ name: 'idCardPhoto' }], - frontCamera: [{ name: 'frontCamera' }] + frontCamera: [{ name: 'frontCamera' }], + smsData: { + name: 'phoneNumber', + label: 'Phone number', + component: TextInput + } } const customerDataSchemas = { @@ -426,6 +431,9 @@ const customerDataSchemas = { }), frontCamera: Yup.object().shape({ frontCamera: Yup.mixed().required() + }), + smsData: Yup.object().shape({ + phoneNumber: Yup.mixed().required() }) }