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_data',
|
||||||
'id_card_photo',
|
'id_card_photo',
|
||||||
'us_ssn',
|
'us_ssn',
|
||||||
'subcriber_info',
|
'subscriber_info',
|
||||||
'name'
|
'name'
|
||||||
]
|
]
|
||||||
const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, _.omitBy(_.isNil, data)))
|
const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, _.omitBy(_.isNil, data)))
|
||||||
|
|
@ -192,8 +192,8 @@ function edit (id, data, userToken) {
|
||||||
function enhanceEditedFields (fields, userToken) {
|
function enhanceEditedFields (fields, userToken) {
|
||||||
if (!userToken) return fields
|
if (!userToken) return fields
|
||||||
_.mapKeys((field) => {
|
_.mapKeys((field) => {
|
||||||
fields[field + '_edited_by'] = userToken
|
fields[field + '_by'] = userToken
|
||||||
fields[field + '_edited_at'] = 'now()^'
|
fields[field + '_at'] = 'now()^'
|
||||||
}, fields)
|
}, fields)
|
||||||
return fields
|
return fields
|
||||||
}
|
}
|
||||||
|
|
@ -232,21 +232,21 @@ function enhanceEditedPhotos (fields) {
|
||||||
|
|
||||||
function deleteEditedData (id, data) {
|
function deleteEditedData (id, data) {
|
||||||
// NOT IMPLEMENTING THIS FEATURE FOR THE CURRENT VERSION
|
// NOT IMPLEMENTING THIS FEATURE FOR THE CURRENT VERSION
|
||||||
// const defaults = [
|
const defaults = [
|
||||||
// 'front_camera',
|
'front_camera',
|
||||||
// 'id_card_data',
|
'id_card_data',
|
||||||
// 'id_card_photo',
|
'id_card_photo',
|
||||||
// 'us_ssn',
|
'us_ssn',
|
||||||
// 'subcriber_info',
|
'subcriber_info',
|
||||||
// 'name'
|
'name'
|
||||||
// ]
|
]
|
||||||
// const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, data))
|
const filteredData = _.pick(defaults, _.mapKeys(_.snakeCase, data))
|
||||||
// if (_.isEmpty(filteredData)) return getCustomerById(id)
|
if (_.isEmpty(filteredData)) return getCustomerById(id)
|
||||||
|
|
||||||
// const cs = new Pgp.helpers.ColumnSet(_.keys(filteredData),
|
const cs = new Pgp.helpers.ColumnSet(_.keys(filteredData),
|
||||||
// { table: 'edited_customer_data' })
|
{ table: 'edited_customer_data' })
|
||||||
// const update = Pgp.helpers.update(filteredData, cs)
|
const update = Pgp.helpers.update(filteredData, cs)
|
||||||
// db.none(update)
|
db.none(update)
|
||||||
return getCustomerById(id)
|
return getCustomerById(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -726,6 +726,27 @@ function getEditedData (id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLatestData (customerData, customerEditedData) {
|
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
|
return customerData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,13 @@ const resolvers = {
|
||||||
replacePhoto: async (root, { customerId, photoType, newPhoto }, context) => {
|
replacePhoto: async (root, { customerId, photoType, newPhoto }, context) => {
|
||||||
const token = !!context.req.cookies.lid && context.req.session.user.id
|
const token = !!context.req.cookies.lid && context.req.session.user.id
|
||||||
const photo = await newPhoto
|
const photo = await newPhoto
|
||||||
|
if (!photo) return customers.getCustomerById(customerId)
|
||||||
return customers.updateEditedPhoto(customerId, photo, photoType)
|
return customers.updateEditedPhoto(customerId, photo, photoType)
|
||||||
.then(newPatch => customers.edit(customerId, newPatch, token))
|
.then(newPatch => customers.edit(customerId, newPatch, token))
|
||||||
},
|
},
|
||||||
deleteEditedData: (root, { customerId, customerEdit }) => {
|
deleteEditedData: (root, { customerId, customerEdit }) => {
|
||||||
return customers.deleteEditedData(customerId, customerEdit)
|
// NOT IMPLEMENTING THIS FEATURE FOR THE CURRENT VERSION
|
||||||
|
return customers.getCustomerById(customerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,23 @@ exports.up = function (next) {
|
||||||
`CREATE TABLE edited_customer_data (
|
`CREATE TABLE edited_customer_data (
|
||||||
customer_id uuid PRIMARY KEY REFERENCES customers(id),
|
customer_id uuid PRIMARY KEY REFERENCES customers(id),
|
||||||
id_card_data JSON,
|
id_card_data JSON,
|
||||||
id_card_data_edited_at TIMESTAMPTZ,
|
id_card_data_at TIMESTAMPTZ,
|
||||||
id_card_data_edited_by UUID REFERENCES users(id),
|
id_card_data_by UUID REFERENCES users(id),
|
||||||
front_camera_path TEXT,
|
front_camera_path TEXT,
|
||||||
front_camera_edited_at TIMESTAMPTZ,
|
front_camera_at TIMESTAMPTZ,
|
||||||
front_camera_edited_by UUID REFERENCES users(id),
|
front_camera_by UUID REFERENCES users(id),
|
||||||
id_card_photo_path TEXT,
|
id_card_photo_path TEXT,
|
||||||
id_card_photo_edited_at TIMESTAMPTZ,
|
id_card_photo_at TIMESTAMPTZ,
|
||||||
id_card_photo_edited_by UUID REFERENCES users(id),
|
id_card_photo_by UUID REFERENCES users(id),
|
||||||
subscriber_info JSON,
|
subscriber_info JSON,
|
||||||
subscriber_info_edited_at TIMESTAMPTZ,
|
subscriber_info_at TIMESTAMPTZ,
|
||||||
subscriber_info_edited_by UUID REFERENCES users(id),
|
subscriber_info_by UUID REFERENCES users(id),
|
||||||
name TEXT,
|
name TEXT,
|
||||||
name_edited_at TIMESTAMPTZ,
|
name_at TIMESTAMPTZ,
|
||||||
name_edited_by UUID REFERENCES users(id),
|
name_by UUID REFERENCES users(id),
|
||||||
us_ssn TEXT,
|
us_ssn TEXT,
|
||||||
us_ssn_edited_at TIMESTAMPTZ,
|
us_ssn_at TIMESTAMPTZ,
|
||||||
us_ssn_edited_by UUID REFERENCES users(id),
|
us_ssn_by UUID REFERENCES users(id),
|
||||||
created TIMESTAMPTZ NOT NULL DEFAULT now() )`
|
created TIMESTAMPTZ NOT NULL DEFAULT now() )`
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,9 +148,9 @@ const DELETE_EDITED_CUSTOMER = gql`
|
||||||
mutation deleteEditedData($customerId: ID!, $customerEdit: CustomerEdit) {
|
mutation deleteEditedData($customerId: ID!, $customerEdit: CustomerEdit) {
|
||||||
deleteEditedData(customerId: $customerId, customerEdit: $customerEdit) {
|
deleteEditedData(customerId: $customerId, customerEdit: $customerEdit) {
|
||||||
id
|
id
|
||||||
frontCamera
|
frontCameraPath
|
||||||
idCardData
|
idCardData
|
||||||
idCardPhoto
|
idCardPhotoPath
|
||||||
usSsn
|
usSsn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,14 @@ export default {
|
||||||
justifyContent: 'space-between'
|
justifyContent: 'space-between'
|
||||||
},
|
},
|
||||||
replace: {
|
replace: {
|
||||||
marginTop: 30
|
marginTop: 30,
|
||||||
|
marginRight: 5
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
display: 'none'
|
display: 'none'
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
marginRight: 8
|
marginRight: 5
|
||||||
},
|
},
|
||||||
editingButtons: {
|
editingButtons: {
|
||||||
marginTop: 30,
|
marginTop: 30,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue