Office code

This commit is contained in:
CHIEFSOFT\ameye
2025-08-21 12:00:39 -04:00
parent 43effd4895
commit c68a5a2c99
14 changed files with 341 additions and 5 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

+1 -1
View File
@@ -3,7 +3,7 @@ const RouteLinks = {
homePage: '/',
loansPage: '/loans',
transactionsPage: '/transactions',
repaymentsPage: '/repayments',
customerPage: '/customer',
loanChargesPage: '/loan-charges',
offers: '/offers',
transaction_details_page: '/transaction/details',
+2 -2
View File
@@ -9,7 +9,7 @@ import LoginPage from './pages/LoginPage' // LOGIN PAGE
import HomePage from './pages/HomePage' // Home PAGE
import LoansPage from './pages/LoansPage' // SELECTED LOANS PAGE
import TransactionsPage from './pages/TransactionsPage' // TRANSACTIONS PAGE
import RepaymentsPage from './pages/RepaymentsPage' // REPAYMENTS PAGE
import CustomerPage from './pages/CustomerPage' // REPAYMENTS PAGE
import LoanChargesPage from './pages/LoanChargesPage' // LOAN CHARGES PAGE
import TransactionDetailsPage from './pages/TransactionDetailsPage' // TRANSACTION DETAILS PAGE
import OffersPage from './pages/OffersPage' // LOAN OFFERS PAGE
@@ -27,7 +27,7 @@ export default function SiteRoutes() {
<Route path={RouteLinks.homePage} element={<HomePage />} /> {`*/HOME PAGE*/`}
<Route path={RouteLinks.loansPage} element={<LoansPage />} /> {`*/LOANS PAGE*/`}
<Route path={RouteLinks.transactionsPage} element={<TransactionsPage />} /> {`*/Transactions PAGE*/`}
<Route path={RouteLinks.repaymentsPage} element={<RepaymentsPage />} /> {`*/REPAYMENTS PAGE*/`}
<Route path={RouteLinks.customerPage} element={<CustomerPage />} /> {`*/CUSTOMER PAGE*/`}
<Route path={RouteLinks.loanChargesPage} element={<LoanChargesPage />} /> {`*/LOAN CHARGES PAGE*/`}
<Route path={RouteLinks.transaction_details_page} element={<TransactionDetailsPage />} /> {`*/TRANSACTION PAGE*/`}
<Route path={RouteLinks.offers} element={<OffersPage />} /> {`*/LOAN OFFERS PAGE*/`}
+159
View File
@@ -0,0 +1,159 @@
import { useEffect, useState } from 'react'
import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons'
import { getCustomers } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
import RouteLinks from '../../RouteLinks';
export default function CustomerCom() {
const [page, setPage] = useState(1)
const [allTransactions, setAllTransaction] = 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}))
}
const handleFilterByParams = () => {
if(filter.type && !filter.id){
return
}else if(!filter.type){
setPage(1)
setWillFilter(prev => !prev)
setFilter({type: '', id: ''})
}else{
setPage(1)
setWillFilter(prev => !prev)
}
}
const transactions = allTransactions?.data?.transactions // TRANSACTIONS LIST
const pagination = allTransactions?.data?.pagination
const isFetching = allTransactions?.loading
const isError = allTransactions?.error
useEffect(()=>{
setAllTransaction(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}))
return
}
setAllTransaction({loading:false, error:'', data:res?.data})
}).catch(err => {
setAllTransaction({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']} />
<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>
:
<>
{/* filter section */}
<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}>
<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} />
</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={transactions} 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
</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>
</tr>
</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?.transaction_id}</div>
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)} {getTimeFromDateString(item?.created_at)}</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>
</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={4}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
</>
}
</div>
</div>
)
}
+163
View File
@@ -0,0 +1,163 @@
import React, { useState } from 'react'
import { useQuery, useQueryClient } from "@tanstack/react-query";
import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import {getCustomers} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
import RouteLinks from '../../RouteLinks';
export default function CustomerCom() {
const queryClient = useQueryClient()
const [page, setPage] = useState(1)
const [filter, setFilter] = useState({transaction_id: '', account_id: ''})
const handleFilter = ({target:{name, value}}) => {
setFilter(prev => ({...prev, [name]:value}))
}
const handleFilterByParams = () => {
// setPage(1)
queryClient.invalidateQueries({ queryKey: [...queryKeys.customer] })
}
const {data, isFetching, isError, error, isPlaceholderData, isPending} = useQuery({
queryKey: [...queryKeys.customer, page],
queryFn: () => getCustomers({...filter, page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const transactions = data?.data?.transactions // TRANSACTIONS LIST
const pagination = data?.data?.pagination
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Transactions' paths={['Dashboard', 'Customer']} />
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{isFetching ?
<>
<p className='text-slate-800'>Loading...</p>
</>
: isError ?
<p className='text-red-500'>{error.message}</p>
:
<>
{/* filter section */}
<div className='px-2 py-2 mb-4 flex items-end gap-2'>
<Icons name='filter' className='text-3xl' />
<div className='flex gap-4 items-center'>
<div className=''>
<p>Transaction ID</p>
<select name='transaction_id' value={filter?.transaction_id} className='p-2' onChange={handleFilter}>
<option value=''>select</option>
<>
{transactions.map((item, index) => (
<option key={index} value={item?.transaction_id}>{item?.transaction_id}</option>
))}
</>
</select>
</div>
<div className=''>
<p>Account ID</p>
<select name='account_id' value={filter?.account_id} className='p-2' onChange={handleFilter}>
<option value=''>select</option>
<>
{transactions.map((item, index) => (
<option key={index} value={item?.account_id}>{item?.account_id}</option>
))}
</>
</select>
</div>
</div>
<button onClick={handleFilterByParams} className={`bg-primary px-2 py-1 rounded-md text-white font-medium`}>Submit</button>
</div>
{/* end of filter section */}
<TablePaginatedWrapper data={transactions} 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
</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>
</tr>
</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?.transaction_id}</div>
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)} {getTimeFromDateString(item?.created_at)}</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>
</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={4}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
</>
}
</div>
</div>
)
}
@@ -137,10 +137,10 @@ export default function DashboardAside() {
const asideNavLinks = [
{name:'Dashboard', status:1, icon: 'dashboard', to: RouteLinks.homePage},
{name:'Deployments', title:'Loan', 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: 'System', status:1, icon: 'dot', to: RouteLinks.loansPage},
{name: 'Customers', status:1, icon: 'dot', to: RouteLinks.repaymentsPage},
{name: 'Customers', status:1, icon: 'dot', to: RouteLinks.customerPage},
{name: 'Billings', status:1, icon: 'dot', to: RouteLinks.loanChargesPage},
{name: 'Configurations', status:1, icon: 'arrow-right', subLinks: [
{name: 'Product Settings', status:1, icon: 'dot', to: RouteLinks.offers },
+7
View File
@@ -0,0 +1,7 @@
import React from 'react'
import CustomerCom from '../components/customer/CustomerCom'
export default function CustomerPage() {
return (
<CustomerCom />
)
}
+1
View File
@@ -1,5 +1,6 @@
const queryKeys = {
dashboard: ['dashboard'],
customer:['customer'],
loans: ['loans'],
transactions: ['transactions'],
repayment_schedule: ['repayment-schedule'],
+6
View File
@@ -62,6 +62,12 @@ export const getLoans = (reqData) => {
return getAuxEnd(`/loans`, postData)
}
// FUNCTION TO GET TRANSACTIONS TABLE
export const getCustomers = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/customers`, postData)
}
// FUNCTION TO GET TRANSACTIONS TABLE
export const getTransactions = (reqData) => {
const postData = { ...reqData }