fix: disable phone field editable

This commit is contained in:
José Oliveira 2022-01-21 15:05:49 +00:00
parent 38d6f7edf5
commit 0cca8b3bf1
4 changed files with 12 additions and 23 deletions

View file

@ -165,8 +165,7 @@ function edit (id, data, userToken) {
'id_card_photo',
'us_ssn',
'subscriber_info',
'name',
'phone'
'name'
]
const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, _.omitBy(_.isNil, data)))
if (_.isEmpty(filteredData)) return getCustomerById(id)
@ -753,8 +752,7 @@ function selectLatestData (customerData, customerEditedData) {
'id_card_photo',
'us_ssn',
'subscriber_info',
'name',
'phone'
'name'
]
_.map(field => {
let fieldName = field

View file

@ -72,7 +72,6 @@ const typeDef = gql`
idCardPhoto: UploadGQL
usSsn: String
subscriberInfo: JSONObject
phone: String
}
type CustomerNote {

View file

@ -6,11 +6,6 @@ exports.up = function (next) {
ADD COLUMN phone_override VERIFICATION_TYPE NOT NULL DEFAULT 'automatic',
ADD COLUMN phone_override_by UUID,
ADD COLUMN phone_override_at TIMESTAMPTZ
`,
`ALTER TABLE edited_customer_data
ADD COLUMN phone TEXT,
ADD COLUMN phone_at TIMESTAMPTZ,
ADD COLUMN phone_by UUID
`
]

View file

@ -2,7 +2,6 @@ import { DialogActions, DialogContent, Dialog } from '@material-ui/core'
import Grid from '@material-ui/core/Grid'
import { makeStyles } from '@material-ui/core/styles'
import { parse, format } from 'date-fns/fp'
import { parsePhoneNumber } from 'libphonenumber-js'
import * as R from 'ramda'
import { useState, React } from 'react'
import * as Yup from 'yup'
@ -152,11 +151,16 @@ const CustomerData = ({
]
const smsDataSchema = {
smsData: Yup.object()
.shape({
phoneNumber: Yup.string().required()
})
.required()
smsData: Yup.lazy(values => {
const additionalData = R.omit(['phoneNumber'])(values)
const fields = R.keys(additionalData)
if (R.length(fields) === 2) {
return Yup.object().shape({
[R.head(fields)]: Yup.string().required(),
[R.last(fields)]: Yup.string().required()
})
}
})
}
const cards = [
@ -186,7 +190,6 @@ const CustomerData = ({
reject: () => updateCustomer({ phoneOverride: OVERRIDE_REJECTED }),
save: values => {
editCustomer({
phone: parsePhoneNumber(values.phoneNumber).number,
subscriberInfo: {
result: R.merge(smsData, R.omit(['phoneNumber'])(values))
}
@ -370,12 +373,6 @@ const CustomerData = ({
component: TextInput,
editable: true
})
smsDataSchema.smsData = Yup.object()
.shape({
[it]: Yup.string()
})
.required()
.concat(smsDataSchema.smsData)
}, R.keys(smsData) ?? [])
const editableCard = (