admin list api added

This commit was merged in pull request #48.
This commit is contained in:
victorAnumudu
2024-09-04 18:02:07 +01:00
parent 237be24476
commit 2a7c25d160
8 changed files with 41 additions and 70 deletions
@@ -11,7 +11,7 @@ import {
stringifyRequestQuery,
WithChildren,
} from '../../../../../../_digifi/helpers'
import {getCustomerList} from './_requests'
import {getAdminUserList} from './_requests'
import {User} from './_models'
import {useQueryRequest} from './QueryRequestProvider'
@@ -32,9 +32,9 @@ const QueryResponseProvider: FC<WithChildren> = ({children}) => {
refetch,
data: response,
} = useQuery(
`${QUERIES.CUSTOMERS_LIST}-${query}`,
`${QUERIES.ADMIN_USERS_LIST}-${query}`,
() => {
return getCustomerList(query)
return getAdminUserList(query)
},
{cacheTime: 0, keepPreviousData: true, refetchOnWindowFocus: false}
)
@@ -30,6 +30,7 @@ export type User = {
added?: string
updated?: string
bvn?: string
username?: string
}
export type UsersQueryResponse = Response<Array<User>>
@@ -19,6 +19,12 @@ const getCustomerList = (query: string): Promise<UsersQueryResponse> => { // FUN
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
};
const getAdminUserList = (query: string): Promise<UsersQueryResponse> => { // FUNCTION TO GET USERS THAT HAVE STARTED LOAN APPLICATION
return axios
.get(`${NEW_USER_ENDPOINT}/users`)
.then((d: AxiosResponse<UsersQueryResponse>) => d.data);
};
const getUserById = (id: ID): Promise<User | undefined> => {
return axios
.get(`${USER_URL}/${id}`)
@@ -54,6 +60,7 @@ export {
deleteUser,
deleteSelectedUsers,
getUserById,
getAdminUserList,
createUser,
updateUser,
};
@@ -20,17 +20,6 @@ const usersColumns: ReadonlyArray<Column<User>> = [
id: 'firstname',
Cell: ({...props}) => <UserInfoCell user={props.data[props.row.index]} />,
},
{
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='Status' className='min-w-125px' />