Feat: user compliance saving to DB

This commit is contained in:
Cesar 2020-12-16 19:12:47 +00:00 committed by Josh Harvey
parent 204e421b3d
commit 2a9e8dadba
7 changed files with 79 additions and 29 deletions

View file

@ -115,12 +115,22 @@ async function updateCustomer (id, data, userToken) {
const sql = Pgp.helpers.update(updateData, _.keys(updateData), 'customers') +
' where id=$1'
invalidateCustomerNotifications(id, formattedData)
await db.none(sql, [id])
return getCustomerById(id)
}
const invalidateCustomerNotifications = (id, data) => {
let detail = '';
if(data.authorized_override === 'verified') {
detail = `BLOCKED_${id}`
}
const sql = `UPDATE notifications SET valid = 'f', read = 't' WHERE valid = 't' AND detail = $1`
return db.none(sql, [detail])
}
/**
* Get customer by id
*