feat: sort customers by status, pending first
This commit is contained in:
parent
d62db527de
commit
1acc8ad65b
1 changed files with 15 additions and 3 deletions
|
|
@ -16,6 +16,7 @@ import { fromNamespace, namespaces } from 'src/utils/config'
|
||||||
|
|
||||||
import CustomersList from './CustomersList'
|
import CustomersList from './CustomersList'
|
||||||
import CreateCustomerModal from './components/CreateCustomerModal'
|
import CreateCustomerModal from './components/CreateCustomerModal'
|
||||||
|
import { getAuthorizedStatus } from './helper'
|
||||||
|
|
||||||
const GET_CUSTOMER_FILTERS = gql`
|
const GET_CUSTOMER_FILTERS = gql`
|
||||||
query filters {
|
query filters {
|
||||||
|
|
@ -130,9 +131,20 @@ const Customers = () => {
|
||||||
R.path(['customInfoRequests'], customersResponse) ?? []
|
R.path(['customInfoRequests'], customersResponse) ?? []
|
||||||
const locale = configData && fromNamespace(namespaces.LOCALE, configData)
|
const locale = configData && fromNamespace(namespaces.LOCALE, configData)
|
||||||
const triggers = configData && fromNamespace(namespaces.TRIGGERS, configData)
|
const triggers = configData && fromNamespace(namespaces.TRIGGERS, configData)
|
||||||
const customersData = R.sortWith([
|
|
||||||
R.descend(it => new Date(R.prop('lastActive', it) ?? '0'))
|
const setAuthorizedStatus = c =>
|
||||||
])(filteredCustomers ?? [])
|
R.assoc(
|
||||||
|
'authorizedStatus',
|
||||||
|
getAuthorizedStatus(c, triggers, customRequirementsData),
|
||||||
|
c
|
||||||
|
)
|
||||||
|
|
||||||
|
const byAuthorized = c => (c.authorizedStatus.label === 'Pending' ? 0 : 1)
|
||||||
|
const byLastActive = c => new Date(R.prop('lastActive', c) ?? '0')
|
||||||
|
const customersData = R.pipe(
|
||||||
|
R.map(setAuthorizedStatus),
|
||||||
|
R.sortWith([R.ascend(byAuthorized), R.descend(byLastActive)])
|
||||||
|
)(filteredCustomers ?? [])
|
||||||
|
|
||||||
const onFilterChange = filters => {
|
const onFilterChange = filters => {
|
||||||
const filtersObject = getFiltersObj(filters)
|
const filtersObject = getFiltersObj(filters)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue