fix: edge case with suspensions shorter than 1 day
This commit is contained in:
parent
c0218e672f
commit
fe665f1e9c
5 changed files with 15 additions and 10 deletions
|
|
@ -451,7 +451,7 @@ function batch () {
|
||||||
* @returns {array} Array of customers with it's transactions aggregations
|
* @returns {array} Array of customers with it's transactions aggregations
|
||||||
*/
|
*/
|
||||||
function getCustomersList () {
|
function getCustomersList () {
|
||||||
const sql = `select id, authorized_override, days_suspended, front_camera_path, front_camera_override,
|
const sql = `select id, authorized_override, days_suspended, is_suspended, front_camera_path, front_camera_override,
|
||||||
phone, sms_override, id_card_data, id_card_data_override, id_card_data_expiration,
|
phone, sms_override, id_card_data, id_card_data_override, id_card_data_expiration,
|
||||||
id_card_photo_path, id_card_photo_override, us_ssn, us_ssn_override, sanctions, sanctions_at,
|
id_card_photo_path, id_card_photo_override, us_ssn, us_ssn_override, sanctions, sanctions_at,
|
||||||
sanctions_override, total_txs, total_spent, created as last_active, fiat as last_tx_fiat,
|
sanctions_override, total_txs, total_spent, created as last_active, fiat as last_tx_fiat,
|
||||||
|
|
@ -459,6 +459,7 @@ function getCustomersList () {
|
||||||
from (
|
from (
|
||||||
select c.id, c.authorized_override,
|
select c.id, c.authorized_override,
|
||||||
greatest(0, date_part('day', c.suspended_until - now())) as days_suspended,
|
greatest(0, date_part('day', c.suspended_until - now())) as days_suspended,
|
||||||
|
c.suspended_until > now() as is_suspended,
|
||||||
c.front_camera_path, c.front_camera_override,
|
c.front_camera_path, c.front_camera_override,
|
||||||
c.phone, c.sms_override, c.id_card_data, c.id_card_data_override, c.id_card_data_expiration,
|
c.phone, c.sms_override, c.id_card_data, c.id_card_data_override, c.id_card_data_expiration,
|
||||||
c.id_card_photo_path, c.id_card_photo_override, c.us_ssn, c.us_ssn_override, c.sanctions,
|
c.id_card_photo_path, c.id_card_photo_override, c.us_ssn, c.us_ssn_override, c.sanctions,
|
||||||
|
|
@ -489,7 +490,7 @@ function getCustomersList () {
|
||||||
* @returns {array} Array of customers with it's transactions aggregations
|
* @returns {array} Array of customers with it's transactions aggregations
|
||||||
*/
|
*/
|
||||||
function getCustomerById (id) {
|
function getCustomerById (id) {
|
||||||
const sql = `select id, authorized_override, days_suspended, front_camera_path, front_camera_override,
|
const sql = `select id, authorized_override, days_suspended, is_suspended, front_camera_path, front_camera_override,
|
||||||
phone, sms_override, id_card_data, id_card_data_override, id_card_data_expiration,
|
phone, sms_override, id_card_data, id_card_data_override, id_card_data_expiration,
|
||||||
id_card_photo_path, id_card_photo_override, us_ssn, us_ssn_override, sanctions, sanctions_at,
|
id_card_photo_path, id_card_photo_override, us_ssn, us_ssn_override, sanctions, sanctions_at,
|
||||||
sanctions_override, total_txs, total_spent, created as last_active, fiat as last_tx_fiat,
|
sanctions_override, total_txs, total_spent, created as last_active, fiat as last_tx_fiat,
|
||||||
|
|
@ -497,6 +498,7 @@ function getCustomerById (id) {
|
||||||
from (
|
from (
|
||||||
select c.id, c.authorized_override,
|
select c.id, c.authorized_override,
|
||||||
greatest(0, date_part('day', c.suspended_until - now())) as days_suspended,
|
greatest(0, date_part('day', c.suspended_until - now())) as days_suspended,
|
||||||
|
c.suspended_until > now() as is_suspended,
|
||||||
c.front_camera_path, c.front_camera_override,
|
c.front_camera_path, c.front_camera_override,
|
||||||
c.phone, c.sms_override, c.id_card_data, c.id_card_data_override, c.id_card_data_expiration,
|
c.phone, c.sms_override, c.id_card_data, c.id_card_data_override, c.id_card_data_expiration,
|
||||||
c.id_card_photo_path, c.id_card_photo_override, c.us_ssn, c.us_ssn_override, c.sanctions,
|
c.id_card_photo_path, c.id_card_photo_override, c.us_ssn, c.us_ssn_override, c.sanctions,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const typeDef = gql`
|
||||||
id: ID!
|
id: ID!
|
||||||
authorizedOverride: String
|
authorizedOverride: String
|
||||||
daysSuspended: Int
|
daysSuspended: Int
|
||||||
|
isSuspended: Boolean
|
||||||
frontCameraPath: String
|
frontCameraPath: String
|
||||||
frontCameraOverride: String
|
frontCameraOverride: String
|
||||||
phone: String
|
phone: String
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ const GET_CUSTOMER = gql`
|
||||||
lastTxFiatCode
|
lastTxFiatCode
|
||||||
lastTxClass
|
lastTxClass
|
||||||
daysSuspended
|
daysSuspended
|
||||||
|
isSuspended
|
||||||
transactions {
|
transactions {
|
||||||
txClass
|
txClass
|
||||||
id
|
id
|
||||||
|
|
@ -136,7 +137,7 @@ const CustomerProfile = memo(() => {
|
||||||
const blocked =
|
const blocked =
|
||||||
R.path(['authorizedOverride'])(customerData) === OVERRIDE_REJECTED
|
R.path(['authorizedOverride'])(customerData) === OVERRIDE_REJECTED
|
||||||
|
|
||||||
const suspended = R.gt(R.path(['daysSuspended'])(customerData), 0)
|
const isSuspended = customerData.isSuspended
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -173,13 +174,11 @@ const CustomerProfile = memo(() => {
|
||||||
<div>
|
<div>
|
||||||
<Label1 className={classes.actionLabel}>Actions</Label1>
|
<Label1 className={classes.actionLabel}>Actions</Label1>
|
||||||
<div className={classes.customerActions}>
|
<div className={classes.customerActions}>
|
||||||
{suspended && (
|
{isSuspended && (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
color="primary"
|
color="primary"
|
||||||
Icon={suspended ? AuthorizeIcon : BlockIcon}
|
Icon={AuthorizeIcon}
|
||||||
InverseIcon={
|
InverseIcon={AuthorizeReversedIcon}
|
||||||
suspended ? AuthorizeReversedIcon : BlockReversedIcon
|
|
||||||
}
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
updateCustomer({
|
updateCustomer({
|
||||||
suspendedUntil: null
|
suspendedUntil: null
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ const GET_CUSTOMERS = gql`
|
||||||
lastTxClass
|
lastTxClass
|
||||||
authorizedOverride
|
authorizedOverride
|
||||||
daysSuspended
|
daysSuspended
|
||||||
|
isSuspended
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ const CUSTOMER_BLOCKED = 'blocked'
|
||||||
const getAuthorizedStatus = it =>
|
const getAuthorizedStatus = it =>
|
||||||
it.authorizedOverride === CUSTOMER_BLOCKED
|
it.authorizedOverride === CUSTOMER_BLOCKED
|
||||||
? { label: 'Blocked', type: 'error' }
|
? { label: 'Blocked', type: 'error' }
|
||||||
: it.daysSuspended > 0
|
: it.isSuspended
|
||||||
|
? it.daysSuspended > 0
|
||||||
? { label: `${it.daysSuspended} day suspension`, type: 'warning' }
|
? { label: `${it.daysSuspended} day suspension`, type: 'warning' }
|
||||||
|
: { label: `< 1 day suspension`, type: 'warning' }
|
||||||
: { label: 'Authorized', type: 'success' }
|
: { label: 'Authorized', type: 'success' }
|
||||||
|
|
||||||
const getFormattedPhone = (phone, country) => {
|
const getFormattedPhone = (phone, country) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue