customer API added #46

Merged
ameye merged 1 commits from customer-list into master 2024-07-18 00:34:30 +00:00
8 changed files with 34 additions and 32 deletions
@@ -6,6 +6,7 @@ const QUERIES = {
PENDING_LIST: 'pending-list',
APPROVED_LIST: 'approved-list',
REJECTED_LIST: 'rejected-list',
CUSTOMERS_LIST: 'customers-list',
EMPLOYERS_LIST: 'employers-list',
SIGNATORY_LIST: 'signatory-list',
}
@@ -4,7 +4,7 @@ import {UsersListWrapper} from './users-list/UsersList'
const usersBreadcrumbs: Array<PageLink> = [
{
title: 'User Management',
title: 'Customer Management',
path: '/tools/user-management/users',
isSeparator: false,
isActive: false,
@@ -25,7 +25,7 @@ const UsersPage = () => {
path='users'
element={
<>
<PageTitle breadcrumbs={usersBreadcrumbs}>Users list</PageTitle>
<PageTitle breadcrumbs={usersBreadcrumbs}>Customer list</PageTitle>
<UsersListWrapper />
</>
}
@@ -11,7 +11,7 @@ import {
stringifyRequestQuery,
WithChildren,
} from '../../../../../../_digifi/helpers'
import {getStartedUsers} from './_requests'
import {getCustomerList} from './_requests'
import {User} from './_models'
import {useQueryRequest} from './QueryRequestProvider'
@@ -32,9 +32,9 @@ const QueryResponseProvider: FC<WithChildren> = ({children}) => {
refetch,
data: response,
} = useQuery(
`${QUERIES.USERS_LIST}-${query}`,
`${QUERIES.CUSTOMERS_LIST}-${query}`,
() => {
return getStartedUsers(query)
return getCustomerList(query)
},
{cacheTime: 0, keepPreviousData: true, refetchOnWindowFocus: false}
)
@@ -29,6 +29,7 @@ export type User = {
status?: string
added?: string
updated?: string
bvn?: string
}
export type UsersQueryResponse = Response<Array<User>>
@@ -13,9 +13,9 @@ const NEW_USER_ENDPOINT = import.meta.env.VITE_APP_USER_ENDPOINT
// .get(`${GET_USERS_URL}?${query}`)
// .then((d: AxiosResponse<UsersQueryResponse>) => d.data);
// };
const getStartedUsers = (query: string): Promise<UsersQueryResponse> => { // FUNCTION TO GET USERS THAT HAVE STARTED LOAN APPLICATION
const getCustomerList = (query: string): Promise<UsersQueryResponse> => { // FUNCTION TO GET USERS THAT HAVE STARTED LOAN APPLICATION
return axios
.get(`${NEW_USER_ENDPOINT}/loan/started`)
.get(`${NEW_USER_ENDPOINT}/customers`)
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
};
@@ -50,7 +50,7 @@ const deleteSelectedUsers = (userIds: Array<ID>): Promise<void> => {
};
export {
getStartedUsers,
getCustomerList,
deleteUser,
deleteSelectedUsers,
getUserById,
@@ -1,11 +0,0 @@
import {FC} from 'react'
type Props = {
agent?: string
}
const AgentCell: FC<Props> = ({agent}) => (
<> {agent && <div className='badge badge-light-success fw-bolder'>{agent}</div>}</>
)
export {AgentCell}
@@ -0,0 +1,11 @@
import {FC} from 'react'
type Props = {
status?: string
}
const Status: FC<Props> = ({status}) => (
<> {status && <div className='badge badge-light-success fw-bolder'>{status}</div>}</>
)
export {Status}
@@ -1,7 +1,7 @@
import {Column} from 'react-table'
import {UserInfoCell} from './UserInfoCell'
import { PaymentMonthCell } from './UserLastLoginCell'
import {AgentCell} from './AgentCell'
import {Status} from './Status'
import {UserActionsCell} from './UserActionsCell'
import {UserSelectionCell} from './UserSelectionCell'
import {UserCustomHeader} from './UserCustomHeader'
@@ -21,22 +21,22 @@ const usersColumns: ReadonlyArray<Column<User>> = [
Cell: ({...props}) => <UserInfoCell user={props.data[props.row.index]} />,
},
{
Header: (props) => <UserCustomHeader tableProps={props} title='Amount' className='min-w-125px' />,
accessor: 'loan_amount',
Header: (props) => <UserCustomHeader tableProps={props} title='BVN' className='min-w-125px' />,
accessor: 'bvn',
},
// {
// Header: (props) => (
// <UserCustomHeader tableProps={props} title='Payment Terms' className='min-w-125px' />
// ),
// id: 'payment_month',
// Cell: ({...props}) => <PaymentMonthCell payment_month={props.data[props.row.index].payment_month} />,
// },
{
Header: (props) => (
<UserCustomHeader tableProps={props} title='Payment Terms' className='min-w-125px' />
<UserCustomHeader tableProps={props} title='Status' className='min-w-125px' />
),
id: 'payment_month',
Cell: ({...props}) => <PaymentMonthCell payment_month={props.data[props.row.index].payment_month} />,
},
{
Header: (props) => (
<UserCustomHeader tableProps={props} title='Agent' className='min-w-125px' />
),
id: 'sales_agent',
Cell: ({...props}) => <AgentCell agent={props.data[props.row.index].sales_agent} />,
id: 'status',
Cell: ({...props}) => <Status status={props.data[props.row.index].status} />,
},
{
Header: (props) => (