fix: .then() on non-Promise
This commit is contained in:
parent
b03901ddd4
commit
724e8c05b1
1 changed files with 9 additions and 6 deletions
|
|
@ -330,6 +330,13 @@ function camelize (customer) {
|
|||
return customer ? _.mapKeys(_.camelCase, customer) : null
|
||||
}
|
||||
|
||||
function camelizeDeep (customer) {
|
||||
return _.flow(
|
||||
camelize,
|
||||
it => ({ ...it, notes: (it.notes ?? []).map(camelize) })
|
||||
)(customer)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all available complianceTypes
|
||||
* that can be overriden (excluding hard_limit)
|
||||
|
|
@ -513,10 +520,7 @@ function getCustomersList (phone = null, name = null, address = null, id = null)
|
|||
AND ($7 IS NULL OR id_card_data::json->>'documentNumber' = $7)
|
||||
limit $3`
|
||||
return db.any(sql, [ passableErrorCodes, anonymous.uuid, NUM_RESULTS, phone, name, address, id ])
|
||||
.then(customers => Promise.all(_.map(customer => {
|
||||
return camelize(customer)
|
||||
.then(it => ({ ...it, notes: (it.notes ?? []).map(camelize) }))
|
||||
}, customers)))
|
||||
.then(customers => Promise.all(_.map(camelizeDeep, customers)))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -565,8 +569,7 @@ function getCustomerById (id) {
|
|||
) AS cl WHERE rn = 1`
|
||||
return db.oneOrNone(sql, [passableErrorCodes, id])
|
||||
.then(assignCustomerData)
|
||||
.then(camelize)
|
||||
.then(it => ({ ...it, notes: (it.notes ?? []).map(camelize) }))
|
||||
.then(camelizeDeep)
|
||||
}
|
||||
|
||||
function assignCustomerData (customer) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue