fixed customer page table
This commit was merged in pull request #1.
This commit is contained in:
+15
-15
@@ -3,16 +3,16 @@ import { useEffect, useState } from 'react'
|
||||
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
|
||||
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
|
||||
import Icons from '../Icons'
|
||||
import { getLoanCharges } from '../../services/siteServices'
|
||||
import { getBillings } from '../../services/siteServices'
|
||||
import getDateFromDateString from '../../helpers/GetDateFromDateString';
|
||||
import formatNumber from '../../helpers/formatNumber'
|
||||
import Avatar from '../../assets/user_avatar.jpg'
|
||||
|
||||
|
||||
export default function LoansChargesCom() {
|
||||
export default function BillingsCom() {
|
||||
|
||||
const [page, setPage] = useState(1)
|
||||
const [allLoanCharges, setAllLoanCharges] = useState({loading:true, error:'', data:{}})
|
||||
const [allBillings, setAllBillings] = useState({loading:true, error:'', data:{}})
|
||||
|
||||
const [willFilter, setWillFilter] = useState(false)
|
||||
const [filter, setFilter] = useState({type: '', id: ''})
|
||||
@@ -33,33 +33,33 @@ export default function LoansChargesCom() {
|
||||
}
|
||||
}
|
||||
|
||||
const loanCharges = allLoanCharges?.data?.loan_charges // LOAN CHARGES LIST
|
||||
const pagination = allLoanCharges?.data?.pagination
|
||||
const isFetching = allLoanCharges?.loading
|
||||
const isError = allLoanCharges?.error
|
||||
const billings = allBillings?.data?.loan_charges // LOAN CHARGES LIST
|
||||
const pagination = allBillings?.data?.pagination
|
||||
const isFetching = allBillings?.loading
|
||||
const isError = allBillings?.error
|
||||
|
||||
useEffect(()=>{
|
||||
setAllLoanCharges(prev => ({...prev, loading:true}))
|
||||
setAllBillings(prev => ({...prev, loading:true}))
|
||||
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
|
||||
getLoanCharges({...payload, page}).then(res => {
|
||||
getBillings({...payload, page}).then(res => {
|
||||
if(res?.status != 200){
|
||||
setAllLoanCharges(prev => ({...prev, loading:false}))
|
||||
setAllBillings(prev => ({...prev, error:'Opps, an error occurred', loading:false}))
|
||||
return
|
||||
}
|
||||
setAllLoanCharges({loading:false, error:'', data:res?.data})
|
||||
setAllBillings({loading:false, error:'', data:res?.data})
|
||||
}).catch(err => {
|
||||
setAllLoanCharges({loading:false, error:'error occurred', data:{}})
|
||||
setAllBillings({loading:false, error:'error occurred', data:{}})
|
||||
console.log('ERR', err)
|
||||
})
|
||||
},[page, willFilter])
|
||||
|
||||
return (
|
||||
<div className='w-full flex flex-col gap-8'>
|
||||
<BreadcrumbCom title='Transactions' paths={['Dashboard', 'Transactions']} />
|
||||
<BreadcrumbCom title='Billings' paths={['Dashboard', 'Billings']} />
|
||||
|
||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
{ isError ?
|
||||
<p className='text-red-500'>{allLoanCharges?.error}</p>
|
||||
<p className='text-red-500'>{allBillings?.error}</p>
|
||||
:
|
||||
<>
|
||||
{/* filter section */}
|
||||
@@ -79,7 +79,7 @@ export default function LoansChargesCom() {
|
||||
</div>
|
||||
{/* end of filter section */}
|
||||
|
||||
<TablePaginatedWrapper data={loanCharges} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination}>
|
||||
<TablePaginatedWrapper data={billings} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination}>
|
||||
{({ data }) => (
|
||||
<>
|
||||
<table className="py-2 w-full text-sm">
|
||||
Reference in New Issue
Block a user