fix: admin ui
This commit is contained in:
parent
04eea85a0d
commit
11e0a03df1
6 changed files with 57 additions and 30 deletions
|
|
@ -45,6 +45,7 @@ const getStatusMap = (settings, customerExternalCompliance) => {
|
|||
_.uniq
|
||||
)(triggers)
|
||||
|
||||
const meta = {}
|
||||
const applicantPromises = _.map(service => {
|
||||
return getStatus(settings, service, customerExternalCompliance)
|
||||
})(services)
|
||||
|
|
@ -81,7 +82,6 @@ const getApplicantByExternalId = (settings, externalService, customerId) => {
|
|||
|
||||
module.exports = {
|
||||
getStatusMap,
|
||||
getStatus,
|
||||
createApplicant,
|
||||
getApplicantByExternalId,
|
||||
createLink
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ function getById (id) {
|
|||
return db.oneOrNone(sql, [id])
|
||||
.then(assignCustomerData)
|
||||
.then(getCustomInfoRequestsData)
|
||||
.then(getExternalCustomerData)
|
||||
.then(getExternalComplianceMachine)
|
||||
.then(camelize)
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +344,11 @@ function camelize (customer) {
|
|||
function camelizeDeep (customer) {
|
||||
return _.flow(
|
||||
camelize,
|
||||
it => ({ ...it, notes: (it.notes ?? []).map(camelize) })
|
||||
it => ({
|
||||
...it,
|
||||
notes: (it.notes ?? []).map(camelize),
|
||||
externalCompliance: (it.externalCompliance ?? []).map(camelize)
|
||||
})
|
||||
)(customer)
|
||||
}
|
||||
|
||||
|
|
@ -589,9 +593,9 @@ function getCustomerById (id) {
|
|||
return db.oneOrNone(sql, [passableErrorCodes, id])
|
||||
.then(assignCustomerData)
|
||||
.then(getCustomInfoRequestsData)
|
||||
.then(getExternalCompliance)
|
||||
.then(camelizeDeep)
|
||||
.then(formatSubscriberInfo)
|
||||
.then(getExternalCustomerData)
|
||||
}
|
||||
|
||||
function assignCustomerData (customer) {
|
||||
|
|
@ -930,7 +934,7 @@ function updateLastAuthAttempt (customerId) {
|
|||
return db.none(sql, [customerId])
|
||||
}
|
||||
|
||||
function getExternalCustomerData (customer) {
|
||||
function getExternalComplianceMachine (customer) {
|
||||
return settingsLoader.loadLatest()
|
||||
.then(settings => externalCompliance.getStatusMap(settings, customer.id))
|
||||
.then(statusMap => {
|
||||
|
|
@ -950,6 +954,17 @@ function updateExternalCompliance(customerId, serviceMap) {
|
|||
return Promise.all(promises)
|
||||
}
|
||||
|
||||
function getExternalCompliance(customer) {
|
||||
const sql = `SELECT external_id, service, last_known_status, last_updated
|
||||
FROM customer_external_compliance where customer_id=$1`
|
||||
return db.manyOrNone(sql, [customer.id])
|
||||
.then(compliance => {
|
||||
console.log(compliance)
|
||||
customer.externalCompliance = compliance
|
||||
})
|
||||
.then(() => customer)
|
||||
}
|
||||
|
||||
function addExternalCompliance(customerId, service, id) {
|
||||
const sql = `INSERT INTO customer_external_compliance (customer_id, external_id, service) VALUES ($1, $2, $3)`
|
||||
return db.none(sql, [customerId, id, service])
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const typeDef = gql`
|
|||
customInfoRequests: [CustomRequestData]
|
||||
notes: [CustomerNote]
|
||||
isTestCustomer: Boolean
|
||||
externalCompliance: JSONObject
|
||||
externalCompliance: [JSONObject]
|
||||
}
|
||||
|
||||
input CustomerInput {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ const createLink = (account, userId, level) => {
|
|||
}
|
||||
|
||||
const getApplicantByExternalId = (account, id) => {
|
||||
console.log('id', id)
|
||||
if (!id) {
|
||||
return Promise.reject('Missing required fields: id')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,18 +31,17 @@ const getApplicantStatus = (account, userId) => {
|
|||
const reviewStatus = _.get('data.review.reviewStatus', r)
|
||||
const reviewAnswer = _.get('data.review.reviewResult.reviewAnswer', r)
|
||||
const reviewRejectType = _.get('data.review.reviewResult.reviewRejectType', r)
|
||||
const sumsubUserId = _.get('data.review.reviewResult.reviewRejectType', r)
|
||||
|
||||
console.log('levelName', levelName)
|
||||
console.log('reviewStatus', reviewStatus)
|
||||
console.log('reviewAnswer', reviewAnswer)
|
||||
console.log('reviewRejectType', reviewRejectType)
|
||||
// if last review was from a different level, return the current level and RETRY
|
||||
if (levelName !== account.applicantLevel) return { thirdPartyId: sumsubUserId, level: account.applicantLevel, answer: RETRY }
|
||||
|
||||
let answer = WAIT
|
||||
if (reviewAnswer === 'GREEN') answer = APPROVED
|
||||
if (reviewAnswer === 'GREEN' && reviewStatus === 'completed') answer = APPROVED
|
||||
if (reviewAnswer === 'RED' && reviewRejectType === 'RETRY') answer = RETRY
|
||||
if (reviewAnswer === 'RED' && reviewRejectType === 'FINAL') answer = REJECTED
|
||||
|
||||
return { level: levelName, answer }
|
||||
return { thirdPartyId: sumsubUserId, level: levelName, answer }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -400,22 +400,34 @@ const CustomerData = ({
|
|||
})
|
||||
}, R.keys(smsData) ?? [])
|
||||
|
||||
// TODO - add external compliance data
|
||||
// R.forEach(outer => {
|
||||
// initialValues.
|
||||
// externalCompliance.push({
|
||||
// fields: [
|
||||
// {
|
||||
// name: 'lastKnownStatus',
|
||||
// label: 'Last Known Status',
|
||||
// component: TextInput
|
||||
// }
|
||||
// ],
|
||||
// titleIcon: <CardIcon className={classes.cardIcon} />,
|
||||
// state: outer.state,
|
||||
// title: 'External Info'
|
||||
// })
|
||||
// })(R.keys(customer.externalCompliance))
|
||||
R.forEach(it => {
|
||||
externalCompliance.push({
|
||||
fields: [
|
||||
{
|
||||
name: 'externalId',
|
||||
label: 'Third Party ID',
|
||||
editable: false
|
||||
},
|
||||
{
|
||||
name: 'lastKnownStatus',
|
||||
label: 'Last Known Status',
|
||||
editable: false
|
||||
},
|
||||
{
|
||||
name: 'lastUpdated',
|
||||
label: 'Last Updated',
|
||||
editable: false
|
||||
}
|
||||
],
|
||||
titleIcon: <CardIcon className={classes.cardIcon} />,
|
||||
title: `External Info [${it.service}]`,
|
||||
initialValues: it ?? {
|
||||
externalId: '',
|
||||
lastKnownStatus: '',
|
||||
lastUpdated: ''
|
||||
}
|
||||
})
|
||||
})(customer.externalCompliance ?? [])
|
||||
|
||||
const editableCard = (
|
||||
{
|
||||
|
|
@ -459,7 +471,7 @@ const CustomerData = ({
|
|||
}
|
||||
|
||||
const nonEditableCard = (
|
||||
{ title, state, titleIcon, fields, hasImage },
|
||||
{ title, state, titleIcon, fields, hasImage, initialValues, children },
|
||||
idx
|
||||
) => {
|
||||
return (
|
||||
|
|
@ -467,6 +479,8 @@ const CustomerData = ({
|
|||
title={title}
|
||||
key={idx}
|
||||
state={state}
|
||||
children={children}
|
||||
initialValues={initialValues}
|
||||
titleIcon={titleIcon}
|
||||
editable={false}
|
||||
hasImage={hasImage}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue