fix: allow for custom info requests to be allowed or blocked
fix: improve custom info requests backend fix: add custom info requests to trigger overrides
This commit is contained in:
parent
08bcf03a1e
commit
87a3b718db
11 changed files with 167 additions and 88 deletions
|
|
@ -35,8 +35,10 @@ const getAllCustomInfoRequestsForCustomer = (customerId) => {
|
|||
return db.any(sql, [customerId]).then(res => res.map(item => ({
|
||||
customerId: item.customer_id,
|
||||
infoRequestId: item.info_request_id,
|
||||
approved: item.approved,
|
||||
customerData: item.customer_data
|
||||
customerData: item.customer_data,
|
||||
override: item.override,
|
||||
overrideAt: item.override_at,
|
||||
overrideBy: item.override_by
|
||||
})))
|
||||
}
|
||||
|
||||
|
|
@ -46,8 +48,10 @@ const getCustomInfoRequestForCustomer = (customerId, infoRequestId) => {
|
|||
return {
|
||||
customerId: item.customer_id,
|
||||
infoRequestId: item.info_request_id,
|
||||
approved: item.approved,
|
||||
customerData: item.customer_data
|
||||
customerData: item.customer_data,
|
||||
override: item.override,
|
||||
overrideAt: item.override_at,
|
||||
overrideBy: item.override_by
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -61,8 +65,10 @@ const batchGetAllCustomInfoRequestsForCustomer = (customerIds) => {
|
|||
return items.map(item => ({
|
||||
customerId: item.customer_id,
|
||||
infoRequestId: item.info_request_id,
|
||||
approved: item.approved,
|
||||
customerData: item.customer_data
|
||||
customerData: item.customer_data,
|
||||
override: item.override,
|
||||
overrideAt: item.override_at,
|
||||
overrideBy: item.override_by
|
||||
}))
|
||||
})
|
||||
})
|
||||
|
|
@ -93,9 +99,9 @@ const batchGetCustomInfoRequest = (infoRequestIds) => {
|
|||
})
|
||||
}
|
||||
|
||||
const setAuthorizedCustomRequest = (customerId, infoRequestId, isAuthorized) => {
|
||||
const sql = `UPDATE customers_custom_info_requests SET approved = $1 WHERE customer_id = $2 AND info_request_id = $3`
|
||||
return db.none(sql, [isAuthorized, customerId, infoRequestId]).then(() => true)
|
||||
const setAuthorizedCustomRequest = (customerId, infoRequestId, override, token) => {
|
||||
const sql = `UPDATE customers_custom_info_requests SET override = $1, override_by = $2, override_at = now() WHERE customer_id = $3 AND info_request_id = $4`
|
||||
return db.none(sql, [override, token, customerId, infoRequestId]).then(() => true)
|
||||
}
|
||||
|
||||
const setCustomerData = (customerId, infoRequestId, data) => {
|
||||
|
|
@ -103,7 +109,7 @@ const setCustomerData = (customerId, infoRequestId, data) => {
|
|||
INSERT INTO customers_custom_info_requests (customer_id, info_request_id, customer_data)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (customer_id, info_request_id)
|
||||
DO UPDATE SET customer_data = $3, approved = null`
|
||||
DO UPDATE SET customer_data = $3`
|
||||
return db.none(sql, [customerId, infoRequestId, data])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue