From ebfdbbb3fc8ca098ca5e5eb09761d2b2fe613434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Fri, 14 Jan 2022 21:05:55 +0000 Subject: [PATCH] fix: identify customers with manual pending data --- .../src/pages/Customers/Customers.js | 12 +++++ .../src/pages/Customers/CustomersList.js | 4 +- .../src/pages/Customers/helper.js | 46 ++++++++++++++++--- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/new-lamassu-admin/src/pages/Customers/Customers.js b/new-lamassu-admin/src/pages/Customers/Customers.js index 70e182f6..ea584f9c 100644 --- a/new-lamassu-admin/src/pages/Customers/Customers.js +++ b/new-lamassu-admin/src/pages/Customers/Customers.js @@ -43,6 +43,16 @@ const GET_CUSTOMERS = gql` lastTxFiatCode lastTxClass authorizedOverride + frontCameraPath + frontCameraOverride + idCardPhotoPath + idCardPhotoOverride + idCardData + idCardDataOverride + usSsn + usSsnOverride + sanctions + sanctionsOverride daysSuspended isSuspended } @@ -80,6 +90,7 @@ const Customers = () => { const configData = R.path(['config'])(customersResponse) ?? [] const locale = configData && fromNamespace(namespaces.LOCALE, configData) + const triggers = configData && fromNamespace(namespaces.TRIGGERS, configData) const customersData = R.sortWith([ R.descend(it => new Date(R.prop('lastActive', it) ?? '0')) ])(filteredCustomers ?? []) @@ -168,6 +179,7 @@ const Customers = () => { locale={locale} onClick={handleCustomerClicked} loading={customerLoading} + triggers={triggers} /> ) diff --git a/new-lamassu-admin/src/pages/Customers/CustomersList.js b/new-lamassu-admin/src/pages/Customers/CustomersList.js index 43e40c2a..2684e36e 100644 --- a/new-lamassu-admin/src/pages/Customers/CustomersList.js +++ b/new-lamassu-admin/src/pages/Customers/CustomersList.js @@ -13,7 +13,7 @@ import { getAuthorizedStatus, getFormattedPhone, getName } from './helper' const useStyles = makeStyles(styles) -const CustomersList = ({ data, locale, onClick, loading }) => { +const CustomersList = ({ data, locale, onClick, loading, triggers }) => { const classes = useStyles() const elements = [ @@ -66,7 +66,7 @@ const CustomersList = ({ data, locale, onClick, loading }) => { { 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 719ae628..c21f1d7e 100644 --- a/new-lamassu-admin/src/pages/Customers/helper.js +++ b/new-lamassu-admin/src/pages/Customers/helper.js @@ -8,6 +8,7 @@ import * as Yup from 'yup' import { RadioGroup, TextInput } from 'src/components/inputs/formik' import { H4 } from 'src/components/typography' import { errorColor } from 'src/styling/variables' +import { MANUAL } from 'src/utils/constants' import { Upload } from './components' @@ -39,14 +40,47 @@ const useStyles = makeStyles({ const CUSTOMER_BLOCKED = 'blocked' -const getAuthorizedStatus = it => - it.authorizedOverride === CUSTOMER_BLOCKED - ? { label: 'Blocked', type: 'error' } - : it.isSuspended - ? it.daysSuspended > 0 +const getAuthorizedStatus = (it, triggers) => { + const fields = [ + 'frontCameraPath', + 'idCardData', + 'idCardPhotoPath', + 'usSsn', + 'sanctions' + ] + + const isManualField = fieldName => { + const manualOverrides = R.filter( + ite => R.equals(R.toLower(ite.automation), MANUAL), + triggers?.overrides ?? [] + ) + + return ( + !!R.find(ite => R.equals(ite.requirement, fieldName), manualOverrides) || + R.equals(triggers.automation, MANUAL) + ) + } + + const pendingFieldStatus = R.map( + ite => + !R.isNil(it[`${ite}`]) + ? isManualField(ite) + ? R.equals(it[`${ite}Override`], 'automatic') + : false + : false, + fields + ) + + if (it.authorizedOverride === CUSTOMER_BLOCKED) + return { label: 'Blocked', type: 'error' } + if (it.isSuspended) + return it.daysSuspended > 0 ? { label: `${it.daysSuspended} day suspension`, type: 'warning' } : { label: `< 1 day suspension`, type: 'warning' } - : { label: 'Authorized', type: 'success' } + if (R.any(ite => ite === true, pendingFieldStatus)) + return { label: 'Pending', type: 'warning' } + return { label: 'Authorized', type: 'success' } +} const getFormattedPhone = (phone, country) => { const phoneNumber =