diff --git a/lib/compliance-external.js b/lib/compliance-external.js
index e8e817c9..26e6b60f 100644
--- a/lib/compliance-external.js
+++ b/lib/compliance-external.js
@@ -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
diff --git a/lib/customers.js b/lib/customers.js
index 164bf807..34ac8020 100644
--- a/lib/customers.js
+++ b/lib/customers.js
@@ -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])
diff --git a/lib/new-admin/graphql/types/customer.type.js b/lib/new-admin/graphql/types/customer.type.js
index 0259d6eb..fe140032 100644
--- a/lib/new-admin/graphql/types/customer.type.js
+++ b/lib/new-admin/graphql/types/customer.type.js
@@ -40,7 +40,7 @@ const typeDef = gql`
customInfoRequests: [CustomRequestData]
notes: [CustomerNote]
isTestCustomer: Boolean
- externalCompliance: JSONObject
+ externalCompliance: [JSONObject]
}
input CustomerInput {
diff --git a/lib/plugins/compliance/sumsub/sumsub.api.js b/lib/plugins/compliance/sumsub/sumsub.api.js
index f611678f..a7d7557a 100644
--- a/lib/plugins/compliance/sumsub/sumsub.api.js
+++ b/lib/plugins/compliance/sumsub/sumsub.api.js
@@ -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')
}
diff --git a/lib/plugins/compliance/sumsub/sumsub.js b/lib/plugins/compliance/sumsub/sumsub.js
index 8f036f97..a0a42e3b 100644
--- a/lib/plugins/compliance/sumsub/sumsub.js
+++ b/lib/plugins/compliance/sumsub/sumsub.js
@@ -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 }
})
}
diff --git a/new-lamassu-admin/src/pages/Customers/CustomerData.js b/new-lamassu-admin/src/pages/Customers/CustomerData.js
index 8c6d5bc0..55d0f32d 100644
--- a/new-lamassu-admin/src/pages/Customers/CustomerData.js
+++ b/new-lamassu-admin/src/pages/Customers/CustomerData.js
@@ -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: ,
- // 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: ,
+ 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}