fixed customer page table
This commit was merged in pull request #1.
This commit is contained in:
@@ -13,10 +13,11 @@ import RouteLinks from '../../RouteLinks';
|
||||
export default function CustomerCom() {
|
||||
|
||||
const [page, setPage] = useState(1)
|
||||
const [allTransactions, setAllTransaction] = useState({loading:true, error:'', data:{}})
|
||||
const [allCustomers, setAllCustomers] = useState({loading:true, error:'', data:{}})
|
||||
|
||||
const [willFilter, setWillFilter] = useState(false)
|
||||
const [filter, setFilter] = useState({type: '', id: ''})
|
||||
|
||||
const handleFilter = ({target:{name, value}}) => {
|
||||
setFilter(prev => ({...prev, [name]:value}))
|
||||
}
|
||||
@@ -34,33 +35,33 @@ export default function CustomerCom() {
|
||||
}
|
||||
}
|
||||
|
||||
const transactions = allTransactions?.data?.transactions // TRANSACTIONS LIST
|
||||
const pagination = allTransactions?.data?.pagination
|
||||
const isFetching = allTransactions?.loading
|
||||
const isError = allTransactions?.error
|
||||
const customers = allCustomers?.data?.customers // TRANSACTIONS LIST
|
||||
const pagination = allCustomers?.data?.pagination
|
||||
const isFetching = allCustomers?.loading
|
||||
const isError = allCustomers?.error
|
||||
|
||||
useEffect(()=>{
|
||||
setAllTransaction(prev => ({...prev, loading:true}))
|
||||
setAllCustomers(prev => ({...prev, loading:true}))
|
||||
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
|
||||
getCustomers({...payload, page}).then(res => {
|
||||
if(res?.status != 200){
|
||||
setAllTransaction(prev => ({...prev, loading:false}))
|
||||
setAllCustomers(prev => ({...prev, error:'Opps, an error occurred', loading:false}))
|
||||
return
|
||||
}
|
||||
setAllTransaction({loading:false, error:'', data:res?.data})
|
||||
setAllCustomers({loading:false, error:'', data:res?.data})
|
||||
}).catch(err => {
|
||||
setAllTransaction({loading:false, error:'error occurred', data:{}})
|
||||
setAllCustomers({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='Customers' paths={['Dashboard', 'Customers']} />
|
||||
|
||||
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
|
||||
{ isError ?
|
||||
<p className='text-red-500'>{allTransactions?.error}</p>
|
||||
<p className='text-red-500'>{allCustomers?.error}</p>
|
||||
:
|
||||
<>
|
||||
{/* filter section */}
|
||||
@@ -80,21 +81,18 @@ export default function CustomerCom() {
|
||||
</div>
|
||||
{/* end of filter section */}
|
||||
|
||||
<TablePaginatedWrapper data={transactions} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination} >
|
||||
<TablePaginatedWrapper data={customers} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination} >
|
||||
{({ data }) => (
|
||||
<>
|
||||
<table className="py-2 w-full text-sm">
|
||||
<thead className="py-2 text-sm text-slate-500 text-left">
|
||||
<tr>
|
||||
<th scope="col" className="px-2 py-2">
|
||||
Request
|
||||
Name
|
||||
</th>
|
||||
<th scope="col" className="px-2">
|
||||
Account
|
||||
</th>
|
||||
<th scope="col" className="px-2">
|
||||
Activity
|
||||
</th>
|
||||
<th scope="col" className="px-2 text-right">
|
||||
Action
|
||||
</th>
|
||||
@@ -105,31 +103,25 @@ export default function CustomerCom() {
|
||||
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
|
||||
<td className="px-2 py-2">
|
||||
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
|
||||
<img className="w-10 h-10 rounded-md" src={localImgLoader(`loan_icons/${item?.type}.png`)} alt="Icon" />
|
||||
{/* <img className="w-10 h-10 rounded-md" src={localImgLoader(`loan_icons/${item?.type}.png`)} alt="Icon" /> */}
|
||||
<div className="text-left">
|
||||
<div className="text-base font-semibold">{item?.transaction_id}</div>
|
||||
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)} {getTimeFromDateString(item?.created_at)}</div>
|
||||
<div className="text-base font-semibold">{item?.firstname} {item?.lastname}</div>
|
||||
<div className="font-normal text-gray-500">{item?.email}</div>
|
||||
<div className="font-normal text-gray-500">{item?.id}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-2">
|
||||
<div className="text-left">
|
||||
<div className="text-base font-semibold">{item?.account_id}</div>
|
||||
<div className="font-normal text-gray-500">{item?.type}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-2">
|
||||
<div className="text-left">
|
||||
<div className="font-normal text-gray-500">50%</div>
|
||||
<div className="relative h-[6px] w-full bg-white-body dark:bg-black-body rounded-full overflow-hidden">
|
||||
<div className={`absolute left-0 h-full w-1/2 bg-emerald-600`}></div>
|
||||
</div>
|
||||
<div className="text-base font-semibold">{item?.username}</div>
|
||||
<div className="font-normal text-gray-500">{item?.member_uid}</div>
|
||||
<div className="font-normal text-gray-500">{getDateFromDateString(item?.profile_completed)}</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-2 text-right">
|
||||
<div className='flex items-center justify-end gap-3 md:gap-4'>
|
||||
<div className='p-2 flex justify-center items-center text-slate-500 bg-white-body dark:text-white-body dark:bg-black-body rounded-md'>
|
||||
<Link to={RouteLinks.transaction_details_page} state={{transactionID: item?.transaction_id}}>
|
||||
<Link to={''} state={{customerID: item?.id}}>
|
||||
<Icons name='eye' />
|
||||
</Link>
|
||||
</div>
|
||||
@@ -139,7 +131,7 @@ export default function CustomerCom() {
|
||||
))
|
||||
:
|
||||
<tr className="py-2 border-t border-dashed border-slate-300">
|
||||
<td className="px-3 py-2" colSpan={4}>
|
||||
<td className="px-3 py-2" colSpan={3}>
|
||||
<div className="flex justify-center items-center">
|
||||
No Record Found
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user