fix: format twilio api response
This commit is contained in:
parent
3c33695b9d
commit
229c77eca2
2 changed files with 23 additions and 2 deletions
|
|
@ -575,6 +575,7 @@ function getCustomerById (id) {
|
|||
.then(assignCustomerData)
|
||||
.then(getCustomInfoRequestsData)
|
||||
.then(camelizeDeep)
|
||||
.then(formatSubscriberInfo)
|
||||
}
|
||||
|
||||
function assignCustomerData (customer) {
|
||||
|
|
@ -582,6 +583,26 @@ function assignCustomerData (customer) {
|
|||
.then(customerEditedData => selectLatestData(customer, customerEditedData))
|
||||
}
|
||||
|
||||
function formatSubscriberInfo(customer) {
|
||||
const subscriberInfo = customer.subscriberInfo
|
||||
if(!subscriberInfo) return customer
|
||||
const result = subscriberInfo.result
|
||||
if(subscriberInfo.status !== 'successful' || _.isEmpty(result)) return customer
|
||||
|
||||
const name = _.get('belongs_to.name')(result)
|
||||
const street = _.get('current_addresses[0].street_line_1')(result)
|
||||
const city = _.get('current_addresses[0].city')(result)
|
||||
const stateCode = _.get('current_addresses[0].state_code')(result)
|
||||
const postalCode = _.get('current_addresses[0].postal_code')(result)
|
||||
|
||||
customer.subscriberInfo = {
|
||||
name,
|
||||
address: `${street ?? ''} ${city ?? ''}${street || city ? ',' : ''} ${stateCode ?? ''} ${postalCode ?? ''}`
|
||||
}
|
||||
|
||||
return customer
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the specific customer manually edited data
|
||||
*
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ const CustomerData = ({
|
|||
)
|
||||
|
||||
const phone = R.path(['phone'])(customer)
|
||||
const smsData = R.path(['subscriberInfo', 'result'])(customer)
|
||||
const smsData = R.path(['subscriberInfo'])(customer)
|
||||
|
||||
const isEven = elem => elem % 2 === 0
|
||||
|
||||
|
|
@ -373,7 +373,7 @@ const CustomerData = ({
|
|||
name: it,
|
||||
label: onlyFirstToUpper(it),
|
||||
component: TextInput,
|
||||
editable: true
|
||||
editable: false
|
||||
})
|
||||
}, R.keys(smsData) ?? [])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue