fix: latest customer data selection and button margin
This commit is contained in:
parent
68c635ce38
commit
b77b732bcb
5 changed files with 58 additions and 34 deletions
|
|
@ -156,7 +156,7 @@ function edit (id, data, userToken) {
|
|||
'id_card_data',
|
||||
'id_card_photo',
|
||||
'us_ssn',
|
||||
'subcriber_info',
|
||||
'subscriber_info',
|
||||
'name'
|
||||
]
|
||||
const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, _.omitBy(_.isNil, data)))
|
||||
|
|
@ -192,8 +192,8 @@ function edit (id, data, userToken) {
|
|||
function enhanceEditedFields (fields, userToken) {
|
||||
if (!userToken) return fields
|
||||
_.mapKeys((field) => {
|
||||
fields[field + '_edited_by'] = userToken
|
||||
fields[field + '_edited_at'] = 'now()^'
|
||||
fields[field + '_by'] = userToken
|
||||
fields[field + '_at'] = 'now()^'
|
||||
}, fields)
|
||||
return fields
|
||||
}
|
||||
|
|
@ -232,21 +232,21 @@ function enhanceEditedPhotos (fields) {
|
|||
|
||||
function deleteEditedData (id, data) {
|
||||
// NOT IMPLEMENTING THIS FEATURE FOR THE CURRENT VERSION
|
||||
// const defaults = [
|
||||
// 'front_camera',
|
||||
// 'id_card_data',
|
||||
// 'id_card_photo',
|
||||
// 'us_ssn',
|
||||
// 'subcriber_info',
|
||||
// 'name'
|
||||
// ]
|
||||
// const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, data))
|
||||
// if (_.isEmpty(filteredData)) return getCustomerById(id)
|
||||
const defaults = [
|
||||
'front_camera',
|
||||
'id_card_data',
|
||||
'id_card_photo',
|
||||
'us_ssn',
|
||||
'subcriber_info',
|
||||
'name'
|
||||
]
|
||||
const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, data))
|
||||
if (_.isEmpty(filteredData)) return getCustomerById(id)
|
||||
|
||||
// const cs = new Pgp.helpers.ColumnSet(_.keys(filteredData),
|
||||
// { table: 'edited_customer_data' })
|
||||
// const update = Pgp.helpers.update(filteredData, cs)
|
||||
// db.none(update)
|
||||
const cs = new Pgp.helpers.ColumnSet(_.keys(filteredData),
|
||||
{ table: 'edited_customer_data' })
|
||||
const update = Pgp.helpers.update(filteredData, cs)
|
||||
db.none(update)
|
||||
return getCustomerById(id)
|
||||
}
|
||||
|
||||
|
|
@ -726,6 +726,27 @@ function getEditedData (id) {
|
|||
}
|
||||
|
||||
function selectLatestData (customerData, customerEditedData) {
|
||||
const defaults = [
|
||||
'front_camera',
|
||||
'id_card_data',
|
||||
'id_card_photo',
|
||||
'us_ssn',
|
||||
'subscriber_info',
|
||||
'name'
|
||||
]
|
||||
_.map(field => {
|
||||
let fieldName = field
|
||||
if (_.includes(field, ['front_camera', 'id_card_photo'])) fieldName = fieldName + '_path'
|
||||
const atField = field + '_at'
|
||||
const byField = field + '_by'
|
||||
if (!_.has(fieldName, customerData) || !_.has(fieldName, customerEditedData)) return
|
||||
if (customerData[atField] < customerEditedData[atField]) {
|
||||
customerData[fieldName] = customerEditedData[fieldName]
|
||||
customerData[atField] = customerEditedData[atField]
|
||||
customerData[byField] = customerEditedData[byField]
|
||||
}
|
||||
}
|
||||
, defaults)
|
||||
return customerData
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue