Merge pull request #1387 from siiky/feat/lam-587/sort-by-pending-rel8.1
feat: sort customers by status, pending first
This commit is contained in:
commit
1e74c9dcf2
2 changed files with 17 additions and 9 deletions
|
|
@ -16,6 +16,7 @@ import { fromNamespace, namespaces } from 'src/utils/config'
|
|||
|
||||
import CustomersList from './CustomersList'
|
||||
import CreateCustomerModal from './components/CreateCustomerModal'
|
||||
import { getAuthorizedStatus } from './helper'
|
||||
|
||||
const GET_CUSTOMER_FILTERS = gql`
|
||||
query filters {
|
||||
|
|
@ -130,9 +131,20 @@ const Customers = () => {
|
|||
R.path(['customInfoRequests'], 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 ?? [])
|
||||
|
||||
const setAuthorizedStatus = c =>
|
||||
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 filtersObject = getFiltersObj(filters)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { ReactComponent as TxInIcon } from 'src/styling/icons/direction/cash-in.
|
|||
import { ReactComponent as TxOutIcon } from 'src/styling/icons/direction/cash-out.svg'
|
||||
|
||||
import styles from './CustomersList.styles'
|
||||
import { getAuthorizedStatus, getFormattedPhone, getName } from './helper'
|
||||
import { getFormattedPhone, getName } from './helper'
|
||||
|
||||
const useStyles = makeStyles(styles)
|
||||
|
||||
|
|
@ -73,11 +73,7 @@ const CustomersList = ({
|
|||
{
|
||||
header: 'Status',
|
||||
width: 191,
|
||||
view: it => (
|
||||
<MainStatus
|
||||
statuses={[getAuthorizedStatus(it, triggers, customRequests)]}
|
||||
/>
|
||||
)
|
||||
view: it => <MainStatus statuses={[it.authorizedStatus]} />
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue