Some code fix

This commit is contained in:
CHIEFSOFT\ameye
2025-09-12 19:00:17 -04:00
parent ace8bf7ec8
commit 7445e06841
4 changed files with 425 additions and 384 deletions
+23 -11
View File
@@ -44,7 +44,7 @@ export default function CustomerCom() {
setAllCustomers(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getCustomers({...payload, page}).then(res => {
if(res?.status != 200){
if (res?.status !== 200) {
setAllCustomers(prev => ({...prev, error: 'Opps, an error occurred', loading: false}))
return
}
@@ -68,20 +68,26 @@ export default function CustomerCom() {
<div className='px-2 py-2 mb-4 flex flex-col sm:flex-row flex-wrap sm:items-center gap-2'>
<Icons name='filter' className='text-3xl'/>
<div className='w-full sm:max-w-48'>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md' onChange={handleFilter}>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md'
onChange={handleFilter}>
<option value=''>All</option>
<option value='username'>Username</option>
<option value='email'>Email</option>
</select>
</div>
<div className='w-full sm:max-w-48'>
<input name='id' value={filter?.id} disabled={!filter.type} className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`} onChange={handleFilter} />
<input name='id' value={filter?.id} disabled={!filter.type}
className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`}
onChange={handleFilter}/>
</div>
<button onClick={handleFilterByParams} disabled={filter.type && !filter.id} className={`h-10 bg-primary px-2 py-1 rounded-md text-white font-medium sm:self-end ${(filter.type && !filter.id) && 'opacity-50'}`}>Refresh</button>
<button onClick={handleFilterByParams} disabled={filter.type && !filter.id}
className={`h-10 bg-primary px-2 py-1 rounded-md text-white font-medium sm:self-end ${(filter.type && !filter.id) && 'opacity-50'}`}>Refresh
</button>
</div>
{/* end of filter section */}
<TablePaginatedWrapper data={customers} 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">
@@ -102,11 +108,14 @@ export default function CustomerCom() {
{(data && data.length > 0) ? data?.map((item, index) => (
<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'>
<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" /> */}
<div className="text-left">
<div className="text-base font-semibold">{item?.firstname} {item?.lastname}</div>
<div className="font-normal text-gray-500">{item?.email}</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>
@@ -114,13 +123,16 @@ export default function CustomerCom() {
<td className="px-2">
<div className="text-left">
<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
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'>
<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={''} state={{customerID: item?.id}}>
<Icons name='eye'/>
</Link>
@@ -53,7 +53,8 @@ export default function DashboardAside() {
{link.title &&
<h1 className="px-4 py-2 text-sm sm:text-sm text-slate-500 dark:text-white font-semibold uppercase mt-3 mb-1 border-b border-slate-500 dark:border-white">{link.title}</h1>
}
<AsideLinkWithSubLinks name={link.name} icon={link.icon} isOpen={subLinkList.includes(pathname) || index===1} >
<AsideLinkWithSubLinks name={link.name} icon={link.icon}
isOpen={subLinkList.includes(pathname) || index === 1}>
<>
{link.subLinks.map((subItem, index) => {
let active = subItem.status === 1 ? true : false
@@ -61,7 +62,8 @@ export default function DashboardAside() {
if (active && !hasSubLinks) {
return (
<div key={subItem.name}>
<AsideLink to={subItem.to} name={subItem.name} icon={subItem.icon} />
<AsideLink to={subItem.to} name={subItem.name}
icon={subItem.icon}/>
</div>
)
} else if (active && hasSubLinks) {
@@ -71,14 +73,18 @@ export default function DashboardAside() {
}
})
return (
<AsideLinkWithSubLinks key={subItem.name} name={subItem.name} icon={subItem.icon} isOpen={subLinkList.includes(pathname)}>
<AsideLinkWithSubLinks key={subItem.name} name={subItem.name}
icon={subItem.icon}
isOpen={subLinkList.includes(pathname)}>
<>
{subItem.subLinks.map((item, index) => {
let active = item.status === 1 ? true : false
if (active) {
return (
<div key={index}>
<AsideLink key={index} to={item.to} name={item.name} icon={item.icon} />
<AsideLink key={index} to={item.to}
name={item.name}
icon={item.icon}/>
</div>
)
} else {
@@ -111,10 +117,12 @@ export default function DashboardAside() {
<p className="text-12 text-black-box/90 dark:text-white-body/80">username@gmail.com</p>
</div>
</div>
<button onClick={()=>handleActiveMenu('settings')} className="peer text-slate-500 dark:text-white-body">
<button onClick={() => handleActiveMenu('settings')}
className="peer text-slate-500 dark:text-white-body">
<Icons name='settings' className='text-3xl'/>
</button>
<div className="hidden group-hover:block pop-modal-down absolute p-4 w-full bg-white dark:bg-black-box left-0 bottom-[60%] rounded shadow-round_black dark:shadow-round_white">
<div
className="hidden group-hover:block pop-modal-down absolute p-4 w-full bg-white dark:bg-black-box left-0 bottom-[60%] rounded shadow-round_black dark:shadow-round_white">
<div className="w-full min-h-48 flex flex-col justify-between gap-4">
<div className="w-full h-full">
<div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
@@ -141,12 +149,14 @@ export default function DashboardAside() {
const asideNavLinks = [
{name: 'Dashboard', status: 1, icon: 'dashboard', to: RouteLinks.homePage},
{name:'Deployments', title:'Activities', status:1, icon: 'arrow-right', subLinks: [
{
name: 'Deployments', title: 'Activities', status: 1, icon: 'arrow-right', subLinks: [
{name: 'Active', status: 1, icon: 'dot', to: RouteLinks.transactionsPage},
{name: 'Provisions', status: 1, icon: 'dot', to: RouteLinks.subscriptions},
{name: 'Customers', status: 1, icon: 'dot', to: RouteLinks.customerPage},
{name: 'Billings', status: 1, icon: 'dot', to: RouteLinks.billings},
{name: 'Configurations', status:1, icon: 'arrow-right', subLinks: [
{
name: 'Configurations', status: 1, icon: 'arrow-right', subLinks: [
{name: 'Product Settings', status: 1, icon: 'dot', to: RouteLinks.offers},
{name: 'Admin Manager', status: 1, icon: 'dot', to: RouteLinks.offers},
]
+33 -16
View File
@@ -43,7 +43,7 @@ export default function LoansCom() {
setAllLoans(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getLoans({...payload, page}).then(res => {
if(res?.status != 200){
if (res?.status !== 200) {
setAllLoans(prev => ({...prev, loading: false}))
return
}
@@ -67,20 +67,26 @@ export default function LoansCom() {
<div className='px-2 py-2 mb-4 flex flex-col sm:flex-row flex-wrap sm:items-center gap-2'>
<Icons name='filter' className='text-3xl'/>
<div className='w-full sm:max-w-48'>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md' onChange={handleFilter}>
<select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md'
onChange={handleFilter}>
<option value=''>All</option>
<option value='transaction_id'>Transaction ID</option>
<option value='account_id'>Account ID</option>
</select>
</div>
<div className='w-full sm:max-w-48'>
<input name='id' value={filter?.id} disabled={!filter.type} className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`} onChange={handleFilter} />
<input name='id' value={filter?.id} disabled={!filter.type}
className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`}
onChange={handleFilter}/>
</div>
<button onClick={handleFilterByParams} disabled={filter.type && !filter.id} className={`h-10 bg-primary px-2 py-1 rounded-md text-white font-medium sm:self-end ${(filter.type && !filter.id) && 'opacity-50'}`}>Submit</button>
<button onClick={handleFilterByParams} disabled={filter.type && !filter.id}
className={`h-10 bg-primary px-2 py-1 rounded-md text-white font-medium sm:self-end ${(filter.type && !filter.id) && 'opacity-50'}`}>Submit
</button>
</div>
{/* end of filter section */}
<TablePaginatedWrapper data={loans} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination}>
<TablePaginatedWrapper data={loans} isFetching={isFetching} setPage={setPage}
itemsPerPage={pagination?.limit} pagination={pagination}>
{({data}) => (
<>
<table className="table-auto py-2 w-full text-sm">
@@ -110,41 +116,52 @@ export default function LoansCom() {
{(data && data.length > 0) ? data?.map((item, index) => (
<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'>
<div
className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
<img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese"/>
<div className="text-left">
<div className="text-base font-semibold">{item?.account_id || ''}</div>
<div className="font-normal text-gray-500">{item?.id} : {item?.transaction_id}</div>
<div
className="text-base font-semibold">{item?.account_id || ''}</div>
<div
className="font-normal text-gray-500">{item?.id} : {item?.transaction_id}</div>
</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
{/* <div className="text-base font-semibold">{formatNumber(item?.initial_loan_amount)}</div> */}
<div className="font-normal text-gray-500">{formatNumber(item?.initial_loan_amount)}</div>
<div
className="font-normal text-gray-500">{formatNumber(item?.initial_loan_amount)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.product_id)}</div>
<div className="font-normal text-gray-500">{item?.tenor} days</div>
<div
className="font-normal text-gray-500">{formatNumber(item?.product_id)}</div>
<div className="font-normal text-gray-500">{item?.tenor} days
</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.repayment_amount)}</div>
<div className="font-normal text-gray-500">{formatNumber(item?.installment_amount)}</div>
<div
className="font-normal text-gray-500">{formatNumber(item?.repayment_amount)}</div>
<div
className="font-normal text-gray-500">{formatNumber(item?.installment_amount)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)}</div>
<div
className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)}</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}}>
<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}}>
<Icons name='eye'/>
</Link>
</div>
@@ -62,7 +62,8 @@ export default function LoanChargeDetails({transactionID}) {
<div className="text-left">
<div className="text-base font-semibold">{item?.transaction_id || ''}</div>
{/* <div className="font-normal text-gray-500 line-clamp-1">{item?.description}</div> */}
<div className="font-normal text-gray-500">{item?.loan_id} : {item?.code}</div>
<div
className="font-normal text-gray-500">{item?.loan_id} : {item?.code}</div>
</div>
</div>
</td>
@@ -74,7 +75,8 @@ export default function LoanChargeDetails({transactionID}) {
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{item?.created_at ? getDateFromDateString(item?.created_at) : 'Not available'}</div>
<div
className="font-normal text-gray-500">{item?.created_at ? getDateFromDateString(item?.created_at) : 'Not available'}</div>
</div>
</td>
{/* <td className="px-2 text-right">