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
+108 -96
View File
@@ -1,10 +1,10 @@
import { useEffect, useState } from 'react' import {useEffect, useState} from 'react'
import {Link} from 'react-router-dom' import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom' import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper' import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons' import Icons from '../Icons'
import { getCustomers } from '../../services/siteServices' import {getCustomers} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString'; import getDateFromDateString from '../../helpers/GetDateFromDateString';
// import getTimeFromDateString from '../../helpers/GetTimeFromDateString'; // import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
// import localImgLoader from '../../helpers/localImageLoader'; // import localImgLoader from '../../helpers/localImageLoader';
@@ -13,23 +13,23 @@ import getDateFromDateString from '../../helpers/GetDateFromDateString';
export default function CustomerCom() { export default function CustomerCom() {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [allCustomers, setAllCustomers] = useState({loading:true, error:'', data:{}}) const [allCustomers, setAllCustomers] = useState({loading: true, error: '', data: {}})
const [willFilter, setWillFilter] = useState(false) const [willFilter, setWillFilter] = useState(false)
const [filter, setFilter] = useState({type: '', id: ''}) const [filter, setFilter] = useState({type: '', id: ''})
const handleFilter = ({target:{name, value}}) => { const handleFilter = ({target: {name, value}}) => {
setFilter(prev => ({...prev, [name]:value})) setFilter(prev => ({...prev, [name]: value}))
} }
const handleFilterByParams = () => { const handleFilterByParams = () => {
if(filter.type && !filter.id){ if (filter.type && !filter.id) {
return return
}else if(!filter.type){ } else if (!filter.type) {
setPage(1) setPage(1)
setWillFilter(prev => !prev) setWillFilter(prev => !prev)
setFilter({type: '', id: ''}) setFilter({type: '', id: ''})
}else{ } else {
setPage(1) setPage(1)
setWillFilter(prev => !prev) setWillFilter(prev => !prev)
} }
@@ -40,110 +40,122 @@ export default function CustomerCom() {
const isFetching = allCustomers?.loading const isFetching = allCustomers?.loading
const isError = allCustomers?.error const isError = allCustomers?.error
useEffect(()=>{ useEffect(() => {
setAllCustomers(prev => ({...prev, loading:true})) setAllCustomers(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {} const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getCustomers({...payload, page}).then(res => { getCustomers({...payload, page}).then(res => {
if(res?.status != 200){ if (res?.status !== 200) {
setAllCustomers(prev => ({...prev, error:'Opps, an error occurred', loading:false})) setAllCustomers(prev => ({...prev, error: 'Opps, an error occurred', loading: false}))
return return
} }
setAllCustomers({loading:false, error:'', data:res?.data}) setAllCustomers({loading: false, error: '', data: res?.data})
}).catch(err => { }).catch(err => {
setAllCustomers({loading:false, error:'error occurred', data:{}}) setAllCustomers({loading: false, error: 'error occurred', data: {}})
console.log('ERR', err) console.log('ERR', err)
}) })
},[page, willFilter]) }, [page, willFilter])
return ( return (
<div className='w-full flex flex-col gap-8'> <div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Customers' paths={['Dashboard', 'Customers']} /> <BreadcrumbCom title='Customers' paths={['Dashboard', 'Customers']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'> <div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{ isError ? {isError ?
<p className='text-red-500'>{allCustomers?.error}</p> <p className='text-red-500'>{allCustomers?.error}</p>
: :
<> <>
{/* filter section */} {/* filter section */}
<div className='px-2 py-2 mb-4 flex flex-col sm:flex-row flex-wrap sm:items-center gap-2'> <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' /> <Icons name='filter' className='text-3xl'/>
<div className='w-full sm:max-w-48'> <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'
<option value=''>All</option> onChange={handleFilter}>
<option value='username'>Username</option> <option value=''>All</option>
<option value='email'>Email</option> <option value='username'>Username</option>
</select> <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}/>
</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>
</div> </div>
<div className='w-full sm:max-w-48'> {/* end of filter section */}
<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>
</div>
{/* end of filter section */}
<TablePaginatedWrapper data={customers} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination} > <TablePaginatedWrapper data={customers} isFetching={isFetching} setPage={setPage}
{({ data }) => ( 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"> <table className="py-2 w-full text-sm">
<tr> <thead className="py-2 text-sm text-slate-500 text-left">
<th scope="col" className="px-2 py-2"> <tr>
Name <th scope="col" className="px-2 py-2">
</th> Name
<th scope="col" className="px-2"> </th>
Account <th scope="col" className="px-2">
</th> Account
<th scope="col" className="px-2 text-right"> </th>
Action <th scope="col" className="px-2 text-right">
</th> Action
</tr> </th>
</thead>
<tbody>
{(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'>
{/* <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="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?.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={''} state={{customerID: item?.id}}>
<Icons name='eye' />
</Link>
</div>
</div>
</td>
</tr> </tr>
)) </thead>
: <tbody>
<tr className="py-2 border-t border-dashed border-slate-300"> {(data && data.length > 0) ? data?.map((item, index) => (
<td className="px-3 py-2" colSpan={3}> <tr key={index} className="py-2 border-t border-dashed border-slate-300">
<div className="flex justify-center items-center"> <td className="px-2 py-2">
No Record Found <div
</div> className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
</td> {/* <img className="w-10 h-10 rounded-md" src={localImgLoader(`loan_icons/${item?.type}.png`)} alt="Icon" /> */}
</tr> <div className="text-left">
} <div
</tbody> className="text-base font-semibold">{item?.firstname} {item?.lastname}</div>
</table> <div
</> className="font-normal text-gray-500">{item?.email}</div>
)} <div className="font-normal text-gray-500">{item?.id}</div>
</TablePaginatedWrapper> </div>
</> </div>
</td>
<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>
</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={''} state={{customerID: item?.id}}>
<Icons name='eye'/>
</Link>
</div>
</div>
</td>
</tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={3}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
</>
} }
</div> </div>
</div> </div>
+130 -120
View File
@@ -5,8 +5,8 @@ import MainBtn from "../../MainBtn";
import AsideLink from "./AsideLink"; import AsideLink from "./AsideLink";
import AsideLinkWithSubLinks from "./AsideLinkWithSubLinks"; import AsideLinkWithSubLinks from "./AsideLinkWithSubLinks";
// import { useSelector } from "react-redux"; // import { useSelector } from "react-redux";
import { GeneralLayoutContext } from "../../../context/GeneralLayoutContext"; import {GeneralLayoutContext} from "../../../context/GeneralLayoutContext";
import { TbLogout2 } from "react-icons/tb"; import {TbLogout2} from "react-icons/tb";
import UserAvatar from '../../../assets/user_avatar.jpg' import UserAvatar from '../../../assets/user_avatar.jpg'
import Icons from "../../Icons"; import Icons from "../../Icons";
@@ -19,138 +19,148 @@ export default function DashboardAside() {
// const {userDetails} = useSelector((state) => state.userDetails) // GETS LOGGED IN USER ROLE DETAILS // const {userDetails} = useSelector((state) => state.userDetails) // GETS LOGGED IN USER ROLE DETAILS
// const {role}= userDetails // const {role}= userDetails
return ( return (
<div className='w-full h-full flex flex-col'> <div className='w-full h-full flex flex-col'>
<div className="mb-3 w-full h-24 logo flex items-center"> <div className="mb-3 w-full h-24 logo flex items-center">
<DummyLogo /> <DummyLogo/>
</div> </div>
{/* <hr className="border-slate-400" /> */} {/* <hr className="border-slate-400" /> */}
<div className="aside-scroll-design w-full flex flex-col gap-2 h-full overflow-y-auto"> <div className="aside-scroll-design w-full flex flex-col gap-2 h-full overflow-y-auto">
{asideNavLinks.map((link, index) => { {asideNavLinks.map((link, index) => {
let active = link.status === 1 ? true : false let active = link.status === 1 ? true : false
let hasSubLinks = (link.subLinks && link.subLinks.length > 0) ? true : false let hasSubLinks = (link.subLinks && link.subLinks.length > 0) ? true : false
if(active && !hasSubLinks){ if (active && !hasSubLinks) {
return ( return (
<div key={link.name}> <div key={link.name}>
<AsideLink to={link.to} name={link.name} icon={link.icon} /> <AsideLink to={link.to} name={link.name} icon={link.icon}/>
</div> </div>
) )
} }
if(active && hasSubLinks){ if (active && hasSubLinks) {
let subLinkList = [] let subLinkList = []
link.subLinks.forEach(item =>{ link.subLinks.forEach(item => {
if(item.to){ if (item.to) {
subLinkList.push(item.to)
}else if(item.subLinks?.length > 0){
item.subLinks.forEach(item => {
subLinkList.push(item.to) subLinkList.push(item.to)
}) } else if (item.subLinks?.length > 0) {
} item.subLinks.forEach(item => {
}) subLinkList.push(item.to)
return ( })
<div key={link.name} className="w-full"> }
{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> return (
} <div key={link.name} className="w-full">
<AsideLinkWithSubLinks name={link.name} icon={link.icon} isOpen={subLinkList.includes(pathname) || index===1} > {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>
{link.subLinks.map((subItem, index)=>{ }
let active = subItem.status === 1 ? true : false <AsideLinkWithSubLinks name={link.name} icon={link.icon}
let hasSubLinks = (subItem.subLinks && subItem.subLinks.length > 0) ? true : false isOpen={subLinkList.includes(pathname) || index === 1}>
if(active && !hasSubLinks){ <>
return ( {link.subLinks.map((subItem, index) => {
<div key={subItem.name}> let active = subItem.status === 1 ? true : false
<AsideLink to={subItem.to} name={subItem.name} icon={subItem.icon} /> let hasSubLinks = (subItem.subLinks && subItem.subLinks.length > 0) ? true : false
</div> if (active && !hasSubLinks) {
) return (
}else if(active && hasSubLinks){ <div key={subItem.name}>
let subLinkList = subItem.subLinks.filter(value => value.to).map(item => { // specific open <AsideLink to={subItem.to} name={subItem.name}
if(item.to){ icon={subItem.icon}/>
return item.to
}
})
return(
<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} />
</div> </div>
) )
}else{ } else if (active && hasSubLinks) {
return null let subLinkList = subItem.subLinks.filter(value => value.to).map(item => { // specific open
} if (item.to) {
})} return item.to
</> }
</AsideLinkWithSubLinks> })
) return (
}else{ <AsideLinkWithSubLinks key={subItem.name} name={subItem.name}
return null icon={subItem.icon}
} isOpen={subLinkList.includes(pathname)}>
})} <>
</> {subItem.subLinks.map((item, index) => {
</AsideLinkWithSubLinks> let active = item.status === 1 ? true : false
</div> if (active) {
) return (
}else{ <div key={index}>
return null <AsideLink key={index} to={item.to}
} name={item.name}
})} icon={item.icon}/>
</div> </div>
)
<div className='py-2 mt-4 relative'> } else {
<div className="group w-full flex items-center gap-2"> return null
<div className="w-full flex items-center gap-2"> }
<img src={UserAvatar} alt='user avatar' className='w-12 h-12 p-1 rounded-full' /> })}
<div> </>
<p className="text-sm font-bold text-black-body dark:text-white-body">Username</p> </AsideLinkWithSubLinks>
<p className="text-12 text-black-box/90 dark:text-white-body/80">username@gmail.com</p> )
</div> } else {
</div> return null
<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"> </AsideLinkWithSubLinks>
<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">
<h1 className="font-semibold">Username</h1>
<p className="-mt-2">username@gmail.com</p>
</div> </div>
)
} else {
return null
}
})}
</div>
<div className='py-2 mt-4 relative'>
<div className="group w-full flex items-center gap-2">
<div className="w-full flex items-center gap-2">
<img src={UserAvatar} alt='user avatar' className='w-12 h-12 p-1 rounded-full'/>
<div>
<p className="text-sm font-bold text-black-body dark:text-white-body">Username</p>
<p className="text-12 text-black-box/90 dark:text-white-body/80">username@gmail.com</p>
</div> </div>
<div className="rounded w-full flex items-center gap-2"> </div>
<MainBtn <button onClick={() => handleActiveMenu('settings')}
text='Logout' className="peer text-slate-500 dark:text-white-body">
className="w-full text-center text-black-body hover:text-red-500 dark:text-white-body font-bold text-lg flex justify-center gap-2 items-center" <Icons name='settings' className='text-3xl'/>
onClick={()=>setLogoutModal(true)} </button>
> <div
<TbLogout2 className="text-base" /> 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">
</MainBtn> <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">
<h1 className="font-semibold">Username</h1>
<p className="-mt-2">username@gmail.com</p>
</div>
</div>
<div className="rounded w-full flex items-center gap-2">
<MainBtn
text='Logout'
className="w-full text-center text-black-body hover:text-red-500 dark:text-white-body font-bold text-lg flex justify-center gap-2 items-center"
onClick={() => setLogoutModal(true)}
>
<TbLogout2 className="text-base"/>
</MainBtn>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> )
)
} }
const asideNavLinks = [ const asideNavLinks = [
{name:'Dashboard', status:1, icon: 'dashboard', to: RouteLinks.homePage}, {name: 'Dashboard', status: 1, icon: 'dashboard', to: RouteLinks.homePage},
{name:'Deployments', title:'Activities', status:1, icon: 'arrow-right', subLinks: [ {
{name: 'Active', status:1, icon: 'dot', to: RouteLinks.transactionsPage}, name: 'Deployments', title: 'Activities', status: 1, icon: 'arrow-right', subLinks: [
{name: 'Provisions', status:1, icon: 'dot', to: RouteLinks.subscriptions}, {name: 'Active', status: 1, icon: 'dot', to: RouteLinks.transactionsPage},
{name: 'Customers', status:1, icon: 'dot', to: RouteLinks.customerPage}, {name: 'Provisions', status: 1, icon: 'dot', to: RouteLinks.subscriptions},
{name: 'Billings', status:1, icon: 'dot', to: RouteLinks.billings}, {name: 'Customers', status: 1, icon: 'dot', to: RouteLinks.customerPage},
{name: 'Configurations', status:1, icon: 'arrow-right', subLinks: [ {name: 'Billings', status: 1, icon: 'dot', to: RouteLinks.billings},
{name: 'Product Settings', status:1, icon: 'dot', to: RouteLinks.offers }, {
{name: 'Admin Manager', status:1, icon: 'dot', to: RouteLinks.offers }, 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},
]
},
], ],
}, },
] ]
+137 -120
View File
@@ -1,10 +1,10 @@
import { useEffect, useState } from 'react' import {useEffect, useState} from 'react'
import {Link} from 'react-router-dom' import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom' import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper' import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons' import Icons from '../Icons'
import { getLoans } from '../../services/siteServices' import {getLoans} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString'; import getDateFromDateString from '../../helpers/GetDateFromDateString';
import Avatar from '../../assets/user_avatar.jpg' import Avatar from '../../assets/user_avatar.jpg'
import RouteLinks from '../../RouteLinks'; import RouteLinks from '../../RouteLinks';
@@ -13,22 +13,22 @@ import formatNumber from '../../helpers/formatNumber'
export default function LoansCom() { export default function LoansCom() {
const [page, setPage] = useState(1) const [page, setPage] = useState(1)
const [allLoans, setAllLoans] = useState({loading:true, error:'', data:{}}) const [allLoans, setAllLoans] = useState({loading: true, error: '', data: {}})
const [willFilter, setWillFilter] = useState(false) const [willFilter, setWillFilter] = useState(false)
const [filter, setFilter] = useState({type: '', id: ''}) const [filter, setFilter] = useState({type: '', id: ''})
const handleFilter = ({target:{name, value}}) => { const handleFilter = ({target: {name, value}}) => {
setFilter(prev => ({...prev, [name]:value})) setFilter(prev => ({...prev, [name]: value}))
} }
const handleFilterByParams = () => { const handleFilterByParams = () => {
if(filter.type && !filter.id){ if (filter.type && !filter.id) {
return return
}else if(!filter.type){ } else if (!filter.type) {
setPage(1) setPage(1)
setWillFilter(prev => !prev) setWillFilter(prev => !prev)
setFilter({type: '', id: ''}) setFilter({type: '', id: ''})
}else{ } else {
setPage(1) setPage(1)
setWillFilter(prev => !prev) setWillFilter(prev => !prev)
} }
@@ -39,134 +39,151 @@ export default function LoansCom() {
const isFetching = allLoans?.loading const isFetching = allLoans?.loading
const isError = allLoans?.error const isError = allLoans?.error
useEffect(()=>{ useEffect(() => {
setAllLoans(prev => ({...prev, loading:true})) setAllLoans(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {} const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getLoans({...payload, page}).then(res => { getLoans({...payload, page}).then(res => {
if(res?.status != 200){ if (res?.status !== 200) {
setAllLoans(prev => ({...prev, loading:false})) setAllLoans(prev => ({...prev, loading: false}))
return return
} }
setAllLoans({loading:false, error:'', data:res?.data}) setAllLoans({loading: false, error: '', data: res?.data})
}).catch(err => { }).catch(err => {
setAllLoans({loading:false, error:'error occurred', data:{}}) setAllLoans({loading: false, error: 'error occurred', data: {}})
console.log('ERR', err) console.log('ERR', err)
}) })
},[page, willFilter]) }, [page, willFilter])
return ( return (
<div className='w-full flex flex-col gap-8'> <div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Transactions' paths={['Dashboard', 'Transactions']} /> <BreadcrumbCom title='Transactions' paths={['Dashboard', 'Transactions']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'> <div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{ isError ? {isError ?
<p className='text-red-500'>{allLoans?.error}</p> <p className='text-red-500'>{allLoans?.error}</p>
: :
<> <>
{/* filter section */} {/* filter section */}
<div className='px-2 py-2 mb-4 flex flex-col sm:flex-row flex-wrap sm:items-center gap-2'> <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' /> <Icons name='filter' className='text-3xl'/>
<div className='w-full sm:max-w-48'> <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'
<option value=''>All</option> onChange={handleFilter}>
<option value='transaction_id'>Transaction ID</option> <option value=''>All</option>
<option value='account_id'>Account ID</option> <option value='transaction_id'>Transaction ID</option>
</select> <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}/>
</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>
</div> </div>
<div className='w-full sm:max-w-48'> {/* end of filter section */}
<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>
</div>
{/* end of filter section */}
<TablePaginatedWrapper data={loans} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination}> <TablePaginatedWrapper data={loans} isFetching={isFetching} setPage={setPage}
{({ data }) => ( itemsPerPage={pagination?.limit} pagination={pagination}>
<> {({data}) => (
<table className="table-auto py-2 w-full text-sm"> <>
<thead className="py-2 text-sm text-slate-500 text-left"> <table className="table-auto py-2 w-full text-sm">
<tr> <thead className="py-2 text-sm text-slate-500 text-left">
<th scope="col" className="px-2 py-2"> <tr>
Name <th scope="col" className="px-2 py-2">
</th> Name
<th scope="col" className="px-2 text-right"> </th>
Loan Amount <th scope="col" className="px-2 text-right">
</th> Loan Amount
<th scope="col" className="px-2 text-right"> </th>
Product/Tenor <th scope="col" className="px-2 text-right">
</th> Product/Tenor
<th scope="col" className="px-2 text-right"> </th>
Repay/Install Amount <th scope="col" className="px-2 text-right">
</th> Repay/Install Amount
<th scope="col" className="px-2 text-right"> </th>
Added <th scope="col" className="px-2 text-right">
</th> Added
<th scope="col" className="px-2 text-right"> </th>
Action <th scope="col" className="px-2 text-right">
</th> Action
</tr> </th>
</thead>
<tbody>
{(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'>
<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>
</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>
</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>
</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>
</td>
<td className="px-2">
<div className="text-right">
<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}}>
<Icons name='eye' />
</Link>
</div>
</div>
</td>
</tr> </tr>
)) </thead>
: <tbody>
<tr className="py-2 border-t border-dashed border-slate-300"> {(data && data.length > 0) ? data?.map((item, index) => (
<td className="px-3 py-2" colSpan={6}> <tr key={index} className="py-2 border-t border-dashed border-slate-300">
<div className="flex justify-center items-center"> <td className="px-2 py-2">
No Record Found <div
</div> className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
</td> <img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese"/>
</tr> <div className="text-left">
} <div
</tbody> className="text-base font-semibold">{item?.account_id || ''}</div>
</table> <div
</> className="font-normal text-gray-500">{item?.id} : {item?.transaction_id}</div>
)} </div>
</TablePaginatedWrapper> </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>
</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>
</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>
</td>
<td className="px-2">
<div className="text-right">
<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}}>
<Icons name='eye'/>
</Link>
</div>
</div>
</td>
</tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={6}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
</>
} }
</div> </div>
</div> </div>
@@ -1,5 +1,5 @@
import React, { useState } from 'react' import React, {useState} from 'react'
import { useQuery } from "@tanstack/react-query"; import {useQuery} from "@tanstack/react-query";
// import Icons from '../Icons' // import Icons from '../Icons'
@@ -27,14 +27,14 @@ export default function LoanChargeDetails({transactionID}) {
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'> <div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<p className='pb-4 font-bold text-base'>Loan Charges</p> <p className='pb-4 font-bold text-base'>Loan Charges</p>
{isFetching ? {isFetching ?
<> <>
<p className='text-slate-800'>Loading...</p> <p className='text-slate-800'>Loading...</p>
</> </>
: isError ? : isError ?
<p className='text-red-500'>{error.message}</p> <p className='text-red-500'>{error.message}</p>
: :
<table className="py-2 w-full text-sm"> <table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left"> <thead className="py-2 text-sm text-slate-500 text-left">
<tr> <tr>
<th scope="col" className="px-2 py-2"> <th scope="col" className="px-2 py-2">
Name Name
@@ -52,51 +52,53 @@ export default function LoanChargeDetails({transactionID}) {
Action Action
</th> */} </th> */}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{(loanCharges && loanCharges.length > 0) ? loanCharges?.map((item, index) => ( {(loanCharges && loanCharges.length > 0) ? loanCharges?.map((item, index) => (
<tr key={index} className="py-2 border-t border-dashed border-slate-300"> <tr key={index} className="py-2 border-t border-dashed border-slate-300">
<td className="px-2 py-2"> <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" /> <img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese"/>
<div className="text-left"> <div className="text-left">
<div className="text-base font-semibold">{item?.transaction_id || ''}</div> <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 line-clamp-1">{item?.description}</div> */}
<div className="font-normal text-gray-500">{item?.loan_id} : {item?.code}</div> <div
</div> className="font-normal text-gray-500">{item?.loan_id} : {item?.code}</div>
</div> </div>
</td> </div>
<td className="px-2"> </td>
<div className="text-right"> <td className="px-2">
{/* <div className="text-base font-semibold">{formatNumber(item?.initial_loan_amount)}</div> */} <div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.amount)}</div> {/* <div className="text-base font-semibold">{formatNumber(item?.initial_loan_amount)}</div> */}
</div> <div className="font-normal text-gray-500">{formatNumber(item?.amount)}</div>
</td> </div>
<td className="px-2"> </td>
<div className="text-right"> <td className="px-2">
<div className="font-normal text-gray-500">{item?.created_at ? getDateFromDateString(item?.created_at) : 'Not available'}</div> <div className="text-right">
</div> <div
</td> className="font-normal text-gray-500">{item?.created_at ? getDateFromDateString(item?.created_at) : 'Not available'}</div>
{/* <td className="px-2 text-right"> </div>
</td>
{/* <td className="px-2 text-right">
<div className='flex items-center justify-end gap-3 md:gap-4'> <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'>
<Icons name='eye' /> <Icons name='eye' />
</div> </div>
</div> </div>
</td> */} </td> */}
</tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={3}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr> </tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={3}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
} }
</tbody> </tbody>
</table> </table>
} }
</div> </div>
) )