diff --git a/new-lamassu-admin/package-lock.json b/new-lamassu-admin/package-lock.json index b54297ef..99d52c11 100644 --- a/new-lamassu-admin/package-lock.json +++ b/new-lamassu-admin/package-lock.json @@ -27467,9 +27467,9 @@ "dev": true }, "uuid": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", - "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==" + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" }, "v8-compile-cache": { "version": "2.2.0", diff --git a/new-lamassu-admin/package.json b/new-lamassu-admin/package.json index ab5f4f1c..aa4c0382 100644 --- a/new-lamassu-admin/package.json +++ b/new-lamassu-admin/package.json @@ -49,7 +49,7 @@ "react-virtualized": "^9.21.2", "sanctuary": "^2.0.1", "ua-parser-js": "^1.0.2", - "uuid": "^7.0.2", + "uuid": "^8.3.2", "yup": "0.32.9" }, "devDependencies": { diff --git a/new-lamassu-admin/src/pages/Customers/Customers.js b/new-lamassu-admin/src/pages/Customers/Customers.js index 16cefc5d..a5bed041 100644 --- a/new-lamassu-admin/src/pages/Customers/Customers.js +++ b/new-lamassu-admin/src/pages/Customers/Customers.js @@ -57,6 +57,22 @@ const GET_CUSTOMERS = gql` sanctionsOverride daysSuspended isSuspended + customInfoRequests { + customerId + infoRequestId + override + overrideAt + overrideBy + customerData + customInfoRequest { + id + enabled + customRequest + } + } + } + customInfoRequests { + id } } ` @@ -110,6 +126,8 @@ const Customers = () => { }) const configData = R.path(['config'])(customersResponse) ?? [] + const customRequirementsData = + R.path(['customInfoRequests'], customersResponse) ?? [] const locale = configData && fromNamespace(namespaces.LOCALE, configData) const triggers = configData && fromNamespace(namespaces.TRIGGERS, configData) const customersData = R.sortWith([ @@ -207,6 +225,7 @@ const Customers = () => { onClick={handleCustomerClicked} loading={customerLoading} triggers={triggers} + customRequests={customRequirementsData} /> { +const CustomersList = ({ + data, + locale, + onClick, + loading, + triggers, + customRequests +}) => { const classes = useStyles() const elements = [ @@ -66,7 +73,11 @@ const CustomersList = ({ data, locale, onClick, loading, triggers }) => { { header: 'Status', width: 191, - view: it => + view: it => ( + + ) } ] diff --git a/new-lamassu-admin/src/pages/Customers/helper.js b/new-lamassu-admin/src/pages/Customers/helper.js index cba19de8..e39265ae 100644 --- a/new-lamassu-admin/src/pages/Customers/helper.js +++ b/new-lamassu-admin/src/pages/Customers/helper.js @@ -4,6 +4,7 @@ import { parse, isValid, format } from 'date-fns/fp' import { Field, useFormikContext } from 'formik' import { parsePhoneNumberFromString } from 'libphonenumber-js' import * as R from 'ramda' +import * as uuid from 'uuid' import * as Yup from 'yup' import { @@ -56,14 +57,11 @@ const CUSTOM = 'custom' const REQUIREMENT = 'requirement' const ID_CARD_DATA = 'idCardData' -const getAuthorizedStatus = (it, triggers) => { - const fields = [ - 'frontCamera', - 'idCardData', - 'idCardPhoto', - 'usSsn', - 'sanctions' - ] +const getAuthorizedStatus = (it, triggers, customRequests) => { + const fields = R.concat( + ['frontCamera', 'idCardData', 'idCardPhoto', 'usSsn', 'sanctions'], + R.map(ite => ite.id, customRequests) + ) const fieldsWithPathSuffix = ['frontCamera', 'idCardPhoto'] const isManualField = fieldName => { @@ -83,17 +81,24 @@ const getAuthorizedStatus = (it, triggers) => { ) } - const pendingFieldStatus = R.map( - ite => - !R.isNil( - R.includes(ite, fieldsWithPathSuffix) ? it[`${ite}Path`] : it[`${ite}`] - ) - ? isManualField(ite) - ? R.equals(it[`${ite}Override`], 'automatic') - : false - : false, - fields - ) + const pendingFieldStatus = R.map(ite => { + if (isManualField(ite)) { + if (uuid.validate(ite)) { + const request = R.find( + iter => iter.infoRequestId === ite, + it.customInfoRequests + ) + return !R.isNil(request) && R.equals(request.override, 'automatic') + } + + const regularFieldValue = R.includes(ite, fieldsWithPathSuffix) + ? it[`${ite}Path`] + : it[`${ite}`] + if (R.isNil(regularFieldValue)) return false + return R.equals(it[`${ite}Override`], 'automatic') + } + return false + }, fields) if (it.authorizedOverride === CUSTOMER_BLOCKED) return { label: 'Blocked', type: 'error' }