Merge pull request #1051 from chaotixkilla/fix-identify-customers-with-pending-data
Identify customers with manual pending data
This commit is contained in:
commit
96f202e868
3 changed files with 54 additions and 8 deletions
|
|
@ -45,6 +45,16 @@ const GET_CUSTOMERS = gql`
|
||||||
lastTxFiatCode
|
lastTxFiatCode
|
||||||
lastTxClass
|
lastTxClass
|
||||||
authorizedOverride
|
authorizedOverride
|
||||||
|
frontCameraPath
|
||||||
|
frontCameraOverride
|
||||||
|
idCardPhotoPath
|
||||||
|
idCardPhotoOverride
|
||||||
|
idCardData
|
||||||
|
idCardDataOverride
|
||||||
|
usSsn
|
||||||
|
usSsnOverride
|
||||||
|
sanctions
|
||||||
|
sanctionsOverride
|
||||||
daysSuspended
|
daysSuspended
|
||||||
isSuspended
|
isSuspended
|
||||||
}
|
}
|
||||||
|
|
@ -101,6 +111,7 @@ const Customers = () => {
|
||||||
|
|
||||||
const configData = R.path(['config'])(customersResponse) ?? []
|
const configData = R.path(['config'])(customersResponse) ?? []
|
||||||
const locale = configData && fromNamespace(namespaces.LOCALE, configData)
|
const locale = configData && fromNamespace(namespaces.LOCALE, configData)
|
||||||
|
const triggers = configData && fromNamespace(namespaces.TRIGGERS, configData)
|
||||||
const customersData = R.sortWith([
|
const customersData = R.sortWith([
|
||||||
R.descend(it => new Date(R.prop('lastActive', it) ?? '0'))
|
R.descend(it => new Date(R.prop('lastActive', it) ?? '0'))
|
||||||
])(filteredCustomers ?? [])
|
])(filteredCustomers ?? [])
|
||||||
|
|
@ -195,6 +206,7 @@ const Customers = () => {
|
||||||
locale={locale}
|
locale={locale}
|
||||||
onClick={handleCustomerClicked}
|
onClick={handleCustomerClicked}
|
||||||
loading={customerLoading}
|
loading={customerLoading}
|
||||||
|
triggers={triggers}
|
||||||
/>
|
/>
|
||||||
<CreateCustomerModal
|
<CreateCustomerModal
|
||||||
showModal={showCreationModal}
|
showModal={showCreationModal}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import { getAuthorizedStatus, getFormattedPhone, getName } from './helper'
|
||||||
|
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const CustomersList = ({ data, locale, onClick, loading }) => {
|
const CustomersList = ({ data, locale, onClick, loading, triggers }) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
|
|
@ -66,7 +66,7 @@ const CustomersList = ({ data, locale, onClick, loading }) => {
|
||||||
{
|
{
|
||||||
header: 'Status',
|
header: 'Status',
|
||||||
width: 191,
|
width: 191,
|
||||||
view: it => <MainStatus statuses={[getAuthorizedStatus(it)]} />
|
view: it => <MainStatus statuses={[getAuthorizedStatus(it, triggers)]} />
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import * as Yup from 'yup'
|
||||||
import { RadioGroup, TextInput } from 'src/components/inputs/formik'
|
import { RadioGroup, TextInput } from 'src/components/inputs/formik'
|
||||||
import { H4 } from 'src/components/typography'
|
import { H4 } from 'src/components/typography'
|
||||||
import { errorColor } from 'src/styling/variables'
|
import { errorColor } from 'src/styling/variables'
|
||||||
|
import { MANUAL } from 'src/utils/constants'
|
||||||
|
|
||||||
import { Upload } from './components'
|
import { Upload } from './components'
|
||||||
|
|
||||||
|
|
@ -39,14 +40,47 @@ const useStyles = makeStyles({
|
||||||
|
|
||||||
const CUSTOMER_BLOCKED = 'blocked'
|
const CUSTOMER_BLOCKED = 'blocked'
|
||||||
|
|
||||||
const getAuthorizedStatus = it =>
|
const getAuthorizedStatus = (it, triggers) => {
|
||||||
it.authorizedOverride === CUSTOMER_BLOCKED
|
const fields = [
|
||||||
? { label: 'Blocked', type: 'error' }
|
'frontCameraPath',
|
||||||
: it.isSuspended
|
'idCardData',
|
||||||
? it.daysSuspended > 0
|
'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: `${it.daysSuspended} day suspension`, type: 'warning' }
|
||||||
: { label: `< 1 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 getFormattedPhone = (phone, country) => {
|
||||||
const phoneNumber =
|
const phoneNumber =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue