Compare commits

...

72 Commits

Author SHA1 Message Date
CHIEFSOFT\ameye e26b8ee02a Merge branch 'master' of https://gitlab.chiefsoft.net/DigiFi/digifi-FirstOffice 2025-11-13 11:09:57 -05:00
CHIEFSOFT\ameye 1d576c9e81 eligibility page 2025-11-13 11:09:41 -05:00
ameye 1bc07694e9 Merge branch 'confirmation-modal' of DigiFi/digifi-FirstOffice into master 2025-11-10 16:09:43 +00:00
victorAnumudu 4b2e73949e confirmation-modal 2025-11-10 13:16:14 +01:00
CHIEFSOFT\ameye 090892b51e Loan data 2025-11-09 14:30:11 -05:00
CHIEFSOFT\ameye 976c95b5fd Loan Repayment 2025-11-09 14:26:20 -05:00
ameye c8365d2cb6 Merge branch 'transaction-details-page-bugfix' of DigiFi/digifi-FirstOffice into master 2025-11-04 11:38:17 +00:00
victorAnumudu 6cc5230680 refreshes transaction details page on new transaction link click 2025-11-04 10:50:41 +01:00
CHIEFSOFT\ameye 8d24356163 loans icons 2025-11-03 15:11:31 -05:00
ameye 96ce3e4b1c Merge branch 'recent-loan-fix' of DigiFi/digifi-FirstOffice into master 2025-11-03 20:03:32 +00:00
victorAnumudu 633e88f44b fix recent loan list 2025-11-03 20:50:01 +01:00
CHIEFSOFT\ameye b58153d059 repay page 2025-11-03 14:39:30 -05:00
ameye 482612a8a6 Merge branch 'recent-loans' of DigiFi/digifi-FirstOffice into master 2025-11-03 19:17:33 +00:00
victorAnumudu e9edc036eb added recent-loans endpoint 2025-11-03 20:13:02 +01:00
CHIEFSOFT\ameye c8e15a1cc3 improved repayment listung 2025-11-03 14:10:54 -05:00
CHIEFSOFT\ameye 3c8a738454 Update to icons 2025-11-03 13:08:52 -05:00
CHIEFSOFT\ameye 3a0c27a60a fix e 2025-11-03 12:08:07 -05:00
CHIEFSOFT\ameye a2c6a1fd20 Loan details updates 2025-11-02 21:34:57 -05:00
CHIEFSOFT\ameye 2b22d7132a Loan details updates 2025-11-02 21:23:21 -05:00
CHIEFSOFT\ameye 53092d1ad7 Loan details updates 2025-11-02 19:34:32 -05:00
CHIEFSOFT\ameye 27e4b1601c fix fata 2025-11-02 13:55:22 -05:00
CHIEFSOFT\ameye dfc2165432 Loan details updates 2025-11-02 12:12:08 -05:00
CHIEFSOFT\ameye 2852d5654e fix parts 2025-11-02 11:46:29 -05:00
CHIEFSOFT\ameye d5cd2a6360 Loan details updates 2025-11-02 10:43:02 -05:00
CHIEFSOFT\ameye 2abcfa6671 no need for network 2025-10-30 21:32:23 -04:00
ameye 74cf8a522a Merge branch 'offer-amount-fix' of DigiFi/digifi-FirstOffice into master 2025-09-25 22:41:46 +00:00
victorAnumudu 645d752702 fixed max and min amount 2025-09-25 16:42:57 +01:00
ameye 0df1e401c9 Merge branch 'homepage-number-readings' of DigiFi/digifi-FirstOffice into master 2025-05-28 15:27:14 +00:00
victorAnumudu 7d207813d2 home page number reading updated 2025-05-28 16:17:44 +01:00
ameye 82551d2c27 Merge branch 'filter-compnent' of DigiFi/digifi-FirstOffice into master 2025-05-28 12:40:42 +00:00
victorAnumudu cf409cbac2 added filter component 2025-05-28 13:27:33 +01:00
ameye fcc60a6e46 Merge branch 'filter-update' of DigiFi/digifi-FirstOffice into master 2025-05-26 17:38:35 +00:00
victorAnumudu eee60e0462 updated filter section 2025-05-26 18:09:22 +01:00
ameye 62ff68d254 Merge branch 'table-filter' of DigiFi/digifi-FirstOffice into master 2025-05-26 10:53:18 +00:00
victorAnumudu 2a5d6b5b39 added table filter 2025-05-26 11:07:33 +01:00
CHIEFSOFT\ameye b3a73942bc Best Ticket 2025-05-25 05:14:53 -04:00
CHIEFSOFT\ameye c66662653e Text changes 2025-05-25 05:13:24 -04:00
ameye 164cd4b59e Merge branch 'loan-offers' of DigiFi/digifi-FirstOffice into master 2025-05-22 15:09:25 +00:00
victorAnumudu 7cb5e06fbc loan offer tenor field fixed 2025-05-22 12:53:21 +01:00
ameye e15bc9db4b Merge branch 'transaction_time' of DigiFi/digifi-FirstOffice into master 2025-05-21 19:29:15 +00:00
victorAnumudu 1423057bdf added transaction time to request table 2025-05-21 12:45:33 +01:00
ameye 9e4c8271d1 Merge branch 'update-loan-page' of DigiFi/digifi-FirstOffice into master 2025-05-05 16:07:55 +00:00
victorAnumudu 6f8615ebc5 updated loan and loan details page 2025-05-05 12:29:26 +01:00
CHIEFSOFT\ameye dc4b8b67c0 TENOR ADDED 2025-05-03 20:47:44 -04:00
CHIEFSOFT\ameye 6f9393606f Paid At 2025-05-03 08:05:16 -04:00
CHIEFSOFT\ameye 7bc0e90fe7 Added loan origin 2025-05-03 07:40:15 -04:00
ameye db3afdda2f Merge branch 'offer-page' of DigiFi/digifi-FirstOffice into master 2025-04-30 19:41:26 +00:00
victorAnumudu 3c0f8938fc added offer page 2025-04-30 19:53:35 +01:00
ameye ee1e6586c3 Merge branch 'loan-page-update' of DigiFi/digifi-FirstOffice into master 2025-04-30 13:40:30 +00:00
victorAnumudu 26401f8664 updated transaction details page 2025-04-30 13:55:41 +01:00
ameye eb9ec59eb2 Merge branch 'transaction-details-modification' of DigiFi/digifi-FirstOffice into master 2025-04-30 08:07:05 +00:00
victorAnumudu 397146d4c6 modified transaction details page 2025-04-30 09:02:55 +01:00
ameye 3a5f3662aa Merge branch 'transaction-details-page' of DigiFi/digifi-FirstOffice into master 2025-04-29 08:30:59 +00:00
victorAnumudu 59c1ce6ae7 added transaction details page 2025-04-29 09:24:48 +01:00
ameye d0847b4096 Merge branch 'dashboard-update' of DigiFi/digifi-FirstOffice into master 2025-04-28 14:09:27 +00:00
victorAnumudu 0109809b42 updated dashboard page 2025-04-28 14:32:24 +01:00
ameye 83cf0a9770 Merge branch 'unused-page-removal' of DigiFi/digifi-FirstOffice into master 2025-04-27 10:10:55 +00:00
victorAnumudu 945e756276 removed unused pages and aside links 2025-04-25 08:23:47 +01:00
ameye 457d48cd3b Merge branch 'transactions-endpoint' of DigiFi/digifi-FirstOffice into master 2025-04-24 13:32:29 +00:00
ameye aed12d4ce9 Merge branch 'base-url-update' of DigiFi/digifi-FirstOffice into master 2025-04-24 13:32:25 +00:00
victorAnumudu c2bda67ab1 table update 2025-04-24 14:29:55 +01:00
victorAnumudu cea0ebfe82 transactions endpoint added 2025-04-24 14:18:51 +01:00
victorAnumudu e4d161c0a9 updated base url 2025-04-24 12:10:31 +01:00
ameye f3b09a0ea2 Merge branch 'login-endpoint-resolved' of DigiFi/digifi-FirstOffice into master 2025-04-23 01:59:43 +00:00
victorAnumudu 321122258a added key to map function 2025-04-22 19:12:08 +01:00
victorAnumudu fc9925a837 loans API added 2025-04-22 19:03:02 +01:00
victorAnumudu 239b912585 login resolved 2025-04-22 17:34:40 +01:00
tokslaw db2fe102f8 Merge branch 'unresolved-package-removal' of DigiFi/digifi-FirstOffice into master 2025-04-17 12:33:14 +00:00
victorAnumudu d1524b84d3 removed unresolved packages 2025-04-17 13:19:53 +01:00
ameye 669ba34a8b Merge branch 'warning-bug-fix' of DigiFi/digifi-FirstOffice into master 2025-04-17 11:56:11 +00:00
victorAnumudu e0e227ec02 fixed some warning bug 2025-04-17 11:55:39 +01:00
ameye 7325d8eeb1 Merge branch 'login-api' of DigiFi/digifi-FirstOffice into master 2025-04-16 20:05:43 +00:00
81 changed files with 3387 additions and 1014 deletions
+6 -2
View File
@@ -6,7 +6,8 @@ TWITTER_URL=https://twitter.com
INSTAGRAM_URL=https://www.instagram.com INSTAGRAM_URL=https://www.instagram.com
# BACKEND END POINTS # BACKEND END POINTS
REACT_APP_MAIN_API='http://backoffice-apidev.simbrellang.net:14700' REACT_APP_MAIN_API='https://backoffice-apidev.simbrellang.net'
REACT_APP_EVENT_API='https://event-core.simbrellang.net'
# ENQUIRIES CONTACTS # ENQUIRIES CONTACTS
VITE_CALL_ENDPOINT='09099000000' VITE_CALL_ENDPOINT='09099000000'
@@ -14,4 +15,7 @@ VITE_EMAIL_ENDPOINT='fcmbloan@support.com'
#BANK NAME #BANK NAME
VITE_BANK_NAME='First City Monument Bank' VITE_BANK_NAME='First City Monument Bank'
VITE_BANK_NAME_SHORT='FCMB' VITE_BANK_NAME_SHORT='FCMB'
# Inactivity timeout/logout AT 10MINS
REACT_APP_TIMEOUT=600000
+6 -2
View File
@@ -6,7 +6,8 @@ VITE_TWITTER_URL=https://twitter.com
VITE_INSTAGRAM_URL=https://www.instagram.com VITE_INSTAGRAM_URL=https://www.instagram.com
# BACKEND END POINTS # BACKEND END POINTS
REACT_APP_MAIN_API='http://backoffice-apidev.simbrellang.net:14700' REACT_APP_MAIN_API='https://backoffice-apidev.simbrellang.net'
REACT_APP_EVENT_API='https://event-core.simbrellang.net'
# ENQUIRIES CONTACTS # ENQUIRIES CONTACTS
VITE_CALL_ENDPOINT='09099000000' VITE_CALL_ENDPOINT='09099000000'
@@ -14,4 +15,7 @@ VITE_EMAIL_ENDPOINT='fcmbloan@support.com'
#BANK NAME #BANK NAME
VITE_BANK_NAME='First City Monument Bank' VITE_BANK_NAME='First City Monument Bank'
VITE_BANK_NAME_SHORT='FCMB' VITE_BANK_NAME_SHORT='FCMB'
# Inactivity timeout/logout AT 10MINS
REACT_APP_TIMEOUT=600000
+6 -2
View File
@@ -6,7 +6,8 @@ TWITTER_URL=https://twitter.com
INSTAGRAM_URL=https://www.instagram.com INSTAGRAM_URL=https://www.instagram.com
# BACKEND END POINTS # BACKEND END POINTS
REACT_APP_MAIN_API='http://backoffice-apidev.simbrellang.net:14700' REACT_APP_MAIN_API='https://backoffice-apidev.simbrellang.net'
REACT_APP_EVENT_API='https://event-core.simbrellang.net'
# ENQUIRIES CONTACTS # ENQUIRIES CONTACTS
VITE_CALL_ENDPOINT='09099000000' VITE_CALL_ENDPOINT='09099000000'
@@ -14,4 +15,7 @@ VITE_EMAIL_ENDPOINT='fcmbloan@support.com'
#BANK NAME #BANK NAME
VITE_BANK_NAME='First City Monument Bank' VITE_BANK_NAME='First City Monument Bank'
VITE_BANK_NAME_SHORT='FCMB' VITE_BANK_NAME_SHORT='FCMB'
# Inactivity timeout/logout AT 10MINS
REACT_APP_TIMEOUT=600000
+6 -6
View File
@@ -24,9 +24,9 @@ services:
volumes: volumes:
src: src:
networks: #networks:
default: # default:
driver: bridge # driver: bridge
ipam: # ipam:
config: # config:
- subnet: 172.15.56.0/24 # - subnet: 172.15.56.0/24
+12 -10
View File
@@ -8,6 +8,18 @@ import { generalLayoutContext } from './context/GeneralLayoutContext';
import './App.css'; import './App.css';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 3,
staleTime: 300000 //5 mins
// refetchOnMount: false,
// staleTime: Infinity // can also be a number in millisecond
},
},
})
function App() { function App() {
const {pathname} = useLocation() const {pathname} = useLocation()
@@ -18,16 +30,6 @@ function App() {
window.scrollTo(0,0) window.scrollTo(0,0)
},[pathname]) },[pathname])
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 3,
// refetchOnMount: false,
staleTime: Infinity // can also be a number in millisecond
},
},
})
return ( return (
<> <>
+7 -8
View File
@@ -1,15 +1,14 @@
const RouteLinks = { const RouteLinks = {
loginPage: '/auth/login', loginPage: '/auth/login',
errorPage: '*',
homePage: '/', homePage: '/',
usersPage: '/users',
approvedLoansPage: '/loans/approved',
applicationsLoanPage: '/loans/apply',
disbursementsLoanPage: '/loans/disbursements',
selectedLoanPage: '/loans/select',
loanOffersPage: '/loans/offers',
loansPage: '/loans', loansPage: '/loans',
requestPage: '/request', transactionsPage: '/transactions',
repaymentsPage: '/repayments',
loanChargesPage: '/loan-charges',
eligibility: '/eligibility',
offers: '/offers',
transaction_details_page: '/transaction/details',
errorPage: '*',
} }
export default RouteLinks export default RouteLinks
+34 -35
View File
@@ -1,5 +1,5 @@
import { lazy, Suspense } from 'react' import {lazy, Suspense} from 'react'
import { Routes, Route } from 'react-router-dom' import {Routes, Route} from 'react-router-dom'
import RouteLinks from './RouteLinks' import RouteLinks from './RouteLinks'
import UserExist from './authorization/UserExist' import UserExist from './authorization/UserExist'
@@ -7,45 +7,44 @@ import PageLoader from './components/PageLoader'
import LoginPage from './pages/LoginPage' // LOGIN PAGE import LoginPage from './pages/LoginPage' // LOGIN PAGE
import HomePage from './pages/HomePage' // Home PAGE import HomePage from './pages/HomePage' // Home PAGE
import UsersPage from './pages/UsersPage' // Users PAGE
import ApprovedLoansPage from './pages/ApprovedLoansPage' // APPROVED LOANS PAGE
import DisbursementsLoanPage from './pages/DisbursementsLoanPage' // DISBURSEMENTS LOANS PAGE
import ApplicationsLoanPage from './pages/ApplicationsLoanPage' // APPLICATIONS LOANS PAGE
import SelectedLoanPage from './pages/SelectedLoanPage' // SELECTED LOANS PAGE
import LoanOffersPage from './pages/LoanOffersPage' // SELECTED LOANS PAGE
import LoansPage from './pages/LoansPage' // SELECTED LOANS PAGE import LoansPage from './pages/LoansPage' // SELECTED LOANS PAGE
import RequestPage from './pages/RequestPage' // SELECTED LOANS PAGE import TransactionsPage from './pages/TransactionsPage' // TRANSACTIONS PAGE
import RepaymentsPage from './pages/RepaymentsPage' // 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
import ErrorPage from './pages/ErrorPage'
import EligibilityPage from "./pages/EligibilityPage"; // ERROR PAGE
// const Home = lazy(() => import('./pages/Home')); // const Home = lazy(() => import('./pages/Home'));
export default function SiteRoutes() { export default function SiteRoutes() {
return ( return (
<Routes> <Routes>
<Route path={RouteLinks.loginPage} element={<LoginPage />} /> {`*/LOGIN PAGE*/`} <Route path={RouteLinks.loginPage} element={<LoginPage/>}/> {`*/LOGIN PAGE*/`}
<Route element={<UserExist />}> <Route element={<UserExist/>}>
<Route path={RouteLinks.homePage} element={<HomePage />} /> {`*/HOME PAGE*/`} <Route path={RouteLinks.homePage} element={<HomePage/>}/> {`*/HOME PAGE*/`}
<Route path={RouteLinks.usersPage} element={<UsersPage />} /> {`*/USERS PAGE*/`} <Route path={RouteLinks.loansPage} element={<LoansPage/>}/> {`*/LOANS PAGE*/`}
<Route path={RouteLinks.approvedLoansPage} element={<ApprovedLoansPage />} /> {`*/APPROVED LOANS PAGE*/`} <Route path={RouteLinks.transactionsPage} element={<TransactionsPage/>}/> {`*/Transactions PAGE*/`}
<Route path={RouteLinks.disbursementsLoanPage} element={<DisbursementsLoanPage />} /> {`*/DISBURSEMENTS LOANS PAGE*/`} <Route path={RouteLinks.repaymentsPage} element={<RepaymentsPage/>}/> {`*/REPAYMENTS PAGE*/`}
<Route path={RouteLinks.applicationsLoanPage} element={<ApplicationsLoanPage />} /> {`*/APPLICATIONS LOANS PAGE*/`} <Route path={RouteLinks.loanChargesPage} element={<LoanChargesPage/>}/> {`*/LOAN CHARGES PAGE*/`}
<Route path={RouteLinks.selectedLoanPage} element={<SelectedLoanPage />} /> {`*/SELECTED LOANS PAGE*/`} <Route path={RouteLinks.eligibility} element={<EligibilityPage/>}/> {`*/ELIGIBILITY PAGE*/`}
<Route path={RouteLinks.loanOffersPage} element={<LoanOffersPage />} /> {`*/LOANS OFFERS PAGE*/`} <Route path={RouteLinks.transaction_details_page}
element={<TransactionDetailsPage/>}/> {`*/TRANSACTION PAGE*/`}
<Route path={RouteLinks.offers} element={<OffersPage/>}/> {`*/LOAN OFFERS PAGE*/`}
</Route>
<Route path={RouteLinks.loansPage} element={<LoansPage />} /> {`*/LOANS PAGE*/`} {/* ERROR PAGE */}
<Route path={RouteLinks.requestPage} element={<RequestPage />} /> {`*/Request PAGE*/`} <Route
</Route> path={RouteLinks.errorPage} // error page
element={
{/* ERROR PAGE */} <Suspense fallback={<PageLoader/>}>
<Route <ErrorPage/>
path={RouteLinks.errorPage} // error page </Suspense>
element={ }
<Suspense fallback={<PageLoader />}> />
<p>Error Page 1</p> </Routes>
</Suspense> )
}
/>
</Routes>
)
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

+41
View File
@@ -6,15 +6,56 @@ import DashboardLayout from "../components/layouts/DashboardLayout"
import PageLoader from "../components/PageLoader" import PageLoader from "../components/PageLoader"
import { updateUserDetails } from "../store/UserDetails" import { updateUserDetails } from "../store/UserDetails"
import RouteLinks from "../RouteLinks" import RouteLinks from "../RouteLinks"
import debounceFunction from '../helpers/debounceFunction'
export default function UserExist() { export default function UserExist() {
const dispatch = useDispatch() const dispatch = useDispatch()
const navigate = useNavigate() const navigate = useNavigate()
const [lastActivityTime, setLastActivityTime] = useState(Date.now()); // HOLDS THE INITIAL TIME USER LOGS IN
const [pageIsLoading, setPageIsLoading] = useState(true) const [pageIsLoading, setPageIsLoading] = useState(true)
const {userDetails} = useSelector((state) => state.userDetails) const {userDetails} = useSelector((state) => state.userDetails)
// Function to log the user out
const logoutUser = () => {
localStorage.clear()
navigate(RouteLinks.login, {replace:true})
window.location.reload()
};
// Function to reset the activity time
const resetTimer = () => {
debounceFunction(setLastActivityTime(Date.now()), 1000)
};
useEffect(()=>{
const timer = setTimeout(()=>{
if(Date.now() - Number(lastActivityTime) >= Number(process.env.REACT_APP_TIMEOUT)){
logoutUser()
}
}, Number(process.env.REACT_APP_TIMEOUT))
// Listen for activity events
const events = ['mousemove', 'keydown', 'click', 'scroll', 'touchstart'];
// Adding event listeners
events.forEach(event => {
window.addEventListener(event, resetTimer);
});
return () => {
clearTimeout(timer)
events.forEach(event => {
window.removeEventListener(event, resetTimer);
})
}
},[lastActivityTime])
useEffect(()=>{ useEffect(()=>{
const loadUser = (token) =>{ const loadUser = (token) =>{
const userExist = [{name:'dummy'}] const userExist = [{name:'dummy'}]
+4 -3
View File
@@ -29,11 +29,12 @@
// export default CustomCounter; // export default CustomCounter;
import React from 'react'; // import React from 'react';
import CountUp from 'react-countup'; // import CountUp from 'react-countup';
const CustomCounter = ({ targetNumber, timeInSeconds }) => { const CustomCounter = ({ targetNumber, timeInSeconds }) => {
return <CountUp end={targetNumber} duration={timeInSeconds} />; // return <CountUp end={targetNumber} duration={timeInSeconds} />;
return targetNumber
}; };
export default CustomCounter; export default CustomCounter;
+3 -1
View File
@@ -11,7 +11,7 @@ import { LuPanelRight } from "react-icons/lu";
import { FcGoogle } from "react-icons/fc"; import { FcGoogle } from "react-icons/fc";
import { IoLogoApple } from "react-icons/io5"; import { IoLogoApple } from "react-icons/io5";
import { FcSalesPerformance } from "react-icons/fc"; import { FcSalesPerformance } from "react-icons/fc";
import { FaLongArrowAltRight } from "react-icons/fa"; import { FaLongArrowAltRight, FaFilter } from "react-icons/fa";
export default function Icons({name, className}) { export default function Icons({name, className}) {
return ( return (
@@ -50,6 +50,8 @@ export default function Icons({name, className}) {
<FcSalesPerformance className={`text-base ${className}`} /> <FcSalesPerformance className={`text-base ${className}`} />
:name.toLowerCase() == 'arrow-right' ? :name.toLowerCase() == 'arrow-right' ?
<FaLongArrowAltRight className={`text-base ${className}`} /> <FaLongArrowAltRight className={`text-base ${className}`} />
:name.toLowerCase() == 'filter' ?
<FaFilter className={`text-base ${className}`} />
: :
null null
} }
+9 -4
View File
@@ -11,6 +11,7 @@ import { loginUser } from '../../services/siteServices'
import RouteLinks from '../../RouteLinks' import RouteLinks from '../../RouteLinks'
import Icons from '../Icons' import Icons from '../Icons'
import localImgLoader from '../../helpers/localImageLoader'
const initialValues = { const initialValues = {
@@ -83,13 +84,17 @@ export default function LoginCom() {
{(props)=>( {(props)=>(
<Form> <Form>
<div className='flex flex-col gap-8 w-full bg-white rounded-xl p-16 sm:px-20 sm:py-16 shadow'> <div className='flex flex-col gap-8 w-full bg-white rounded-xl p-16 sm:px-20 sm:py-16 shadow'>
<div className='flex justify-center w-full mb-10'>
<img className='w-auto h-8 xs:h-16' src={localImgLoader('simbrella-bko-logo.png')} />
</div>
<div className='w-full flex flex-col gap-1 items-center'> <div className='w-full flex flex-col gap-1 items-center'>
<h1 className='text-2xl md:text-3xl font-bold text-black-body'>Sign In</h1> <h1 className='text-2xl md:text-3xl font-bold text-black-body'>Sign In</h1>
<p className='text-sm font-medium text-slate-500'>Welcome back, please login to your account</p> <p className='text-sm font-medium text-slate-500'>Welcome back, please login to your account</p>
</div> </div>
{/* social login */} {/* social login */}
<div className='grid grid-cols-2 gap-4 text-sm'> {/* <div className='grid grid-cols-2 gap-4 text-sm'>
<div className='px-4 py-2 flex gap-2 items-center justify-center text-black-body font-medium border border-slate-300/50 rounded-md hover:text-primary hover:bg-sky-50 cursor-pointer'> <div className='px-4 py-2 flex gap-2 items-center justify-center text-black-body font-medium border border-slate-300/50 rounded-md hover:text-primary hover:bg-sky-50 cursor-pointer'>
<Icons name='google' /> <Icons name='google' />
<span>Sign in with Google</span> <span>Sign in with Google</span>
@@ -102,7 +107,7 @@ export default function LoginCom() {
<div className='relative h-[1px] bg-slate-300/50'> <div className='relative h-[1px] bg-slate-300/50'>
<p className='absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 bg-white p-4 text-12 text-slate-500'>Or with email</p> <p className='absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 bg-white p-4 text-12 text-slate-500'>Or with email</p>
</div> </div> */}
<div className='flex flex-col gap-6'> <div className='flex flex-col gap-6'>
<div className='relative text-input flex flex-col gap-2'> <div className='relative text-input flex flex-col gap-2'>
@@ -146,11 +151,11 @@ export default function LoginCom() {
{/* <p className='text-sm text-center font-medium text-slate-500'>Not yet a member? <span className='text-primary'>Sign Up</span></p> */} {/* <p className='text-sm text-center font-medium text-slate-500'>Not yet a member? <span className='text-primary'>Sign Up</span></p> */}
<div className='flex justify-end gap-4 mt-6 text-[13px] font-medium'> {/* <div className='flex justify-end gap-4 mt-6 text-[13px] font-medium'>
<Link className='text-primary' to=''>Terms</Link> <Link className='text-primary' to=''>Terms</Link>
<Link className='text-primary' to=''>Plans</Link> <Link className='text-primary' to=''>Plans</Link>
<Link className='text-primary' to=''>Contact Us</Link> <Link className='text-primary' to=''>Contact Us</Link>
</div> </div> */}
</div> </div>
+1 -3
View File
@@ -8,8 +8,6 @@ export default function BreadcrumbCom({title, span, paths}) {
const [stickNav, setStickNav] = useState(false) const [stickNav, setStickNav] = useState(false)
useEffect(()=>{ useEffect(()=>{
console.log('tru')
// var rect = navRef?.current?.getBoundingClientRect()?.bottom; // var rect = navRef?.current?.getBoundingClientRect()?.bottom;
var rect = 10; var rect = 10;
window.addEventListener('scroll', ()=>{ window.addEventListener('scroll', ()=>{
@@ -30,7 +28,7 @@ export default function BreadcrumbCom({title, span, paths}) {
<div className='flex flex-col gap-2'> <div className='flex flex-col gap-2'>
<div className='flex flex-col md:flex-row gap-1 md:items-center'> <div className='flex flex-col md:flex-row gap-1 md:items-center'>
<h1 className='text-12 sm:text-lg md:text-2xl text-black dark:text-white-body font-semibold'>{title}</h1> <h1 className='text-12 sm:text-lg md:text-2xl text-black dark:text-white-body font-semibold'>{title}</h1>
<span className='text-red-500 text-10 sm:text-base md:text-xl'>{span && span}</span> <span className='text-red-500 text-10 sm:text-base'>{span && span}</span>
</div> </div>
<div className='flex gap-2 items-center text-black-gray dark:text-white-body text-base'> <div className='flex gap-2 items-center text-black-gray dark:text-white-body text-base'>
<TiHomeOutline className='text-black dark:text-white-body' /> <TiHomeOutline className='text-black dark:text-white-body' />
@@ -0,0 +1,169 @@
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 getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber'
import Avatar from '../../assets/repay.png'
export default function EligibilityCom() {
const [page, setPage] = useState(1)
const [allLoanCharges, setAllLoanCharges] = 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 loanCharges = allLoanCharges?.data?.loan_charges // LOAN CHARGES LIST
const pagination = allLoanCharges?.data?.pagination
const isFetching = allLoanCharges?.loading
const isError = allLoanCharges?.error
useEffect(() => {
setAllLoanCharges(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getLoanCharges({...payload, page}).then(res => {
if (res?.status != 200) {
setAllLoanCharges(prev => ({...prev, loading: false}))
return
}
setAllLoanCharges({loading: false, error: '', data: res?.data})
}).catch(err => {
setAllLoanCharges({loading: false, error: 'error occurred', data: {}})
console.log('ERR', err)
})
}, [page, willFilter])
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Eligibility' paths={['Dashboard', 'Eligibility']}/>
<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>
:
<>
{/* 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='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}/>
</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={loanCharges} 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">
TransactionID/Fee Type
</th>
{/* <th scope="col" className="px-2">
Loan
</th> */}
<th scope="col" className="px-2 text-right">
Amount
</th>
<th scope="col" className="px-2 text-right">
Added
</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={Avatar}
alt="Jese image"/>
<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?.code}</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-semibold text-green-500">#{formatNumber(item?.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'>
<Icons name='eye'/>
</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>
)
}
@@ -0,0 +1,119 @@
import React, {useState} from 'react'
import {useQuery} from "@tanstack/react-query";
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 {getLoanCharges} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber';
export default function LoanChargesCom() {
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.loan_charges, page],
queryFn: () => getLoanCharges({page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const loanCharges = data?.data?.loan_charges // LOAN CHARGES LIST
const pagination = data?.data?.pagination
return (
<div className='w-full flex flex-col gap-8' style={{backgroundColor: 'aliceblue'}}>
<BreadcrumbCom title='Loan Charges' paths={['Dashboard', 'Loan Charges']}/>
<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>
:
<TablePaginatedWrapper data={loanCharges} 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">
Name
</th>
{/* <th scope="col" className="px-2">
Loan
</th> */}
<th scope="col" className="px-2 text-right">
Amount
</th>
<th scope="col" className="px-2 text-right">
Added
</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'>
<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?.code}</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?.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'>
<Icons name='eye'/>
</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>
)
}
+37
View File
@@ -0,0 +1,37 @@
import React from 'react'
import { useNavigate } from 'react-router-dom'
import ErrorLogo from '../../assets/404-error.png'
export default function ErrorCom() {
const navigate = useNavigate()
return (
<>
<div className={`h-screen bg-sky-300 flex flex-col items-center justify-center bg-[url('./assets/login-bg.jpg')] bg-cover bg-center bg-no-repeat`}>
<div className='p-4 sm:p-8 w-full max-w-7xl mx-auto grid gap-8 place-content-center'>
<div className='w-4/5 md:w-[650px] h-full'>
<div className='flex flex-col gap-8 w-full bg-white rounded-xl p-16 sm:px-20 sm:py-16 shadow'>
<div className='w-full flex flex-col gap-1 items-center'>
<h1 className='text-2xl md:text-3xl font-bold text-black-body'>Oops!</h1>
<p className='text-sm font-medium text-slate-500'>We can't find that page.</p>
</div>
{/* <div className='relative h-[1px] bg-slate-300/50'>
<p className='absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 bg-white p-4 text-12 text-slate-500'>Or with email</p>
</div> */}
<div className='flex flex-col items-center gap-6'>
<img src={ErrorLogo} className='w-4/5 md:w-80 h-auto' alt='error logo' />
<div className='h-10 mb-10 flex justify-center'>
<button onClick={()=>navigate('/', {replace:true})} className='px-2 h-full bg-primary text-sm text-white font-medium rounded-md'>Return Home</button>
</div>
</div>
</div>
</div>
</div>
</div>
</>
)
}
+167 -136
View File
@@ -1,96 +1,105 @@
import React from 'react' import React from 'react'
import { useQuery } from "@tanstack/react-query"; import {Link} from 'react-router-dom'
import {useQuery} from "@tanstack/react-query";
import BreadcrumbCom from '../../components/breadcrumb/BreadcrumbCom' import BreadcrumbCom from '../../components/breadcrumb/BreadcrumbCom'
import CustomCounter from '../../components/CustomCounter' import CustomCounter from '../../components/CustomCounter'
import Icons from '../../components/Icons' import Icons from '../../components/Icons'
import TableWrapper from '../../components/tableWrapper/TableWrapper'
import Avatar from '../../assets/user_avatar.jpg'
import { Widget1 } from './Widget1'
import { Widget2 } from './Widget2'
import formatNumber from '../../helpers/formatNumber' import formatNumber from '../../helpers/formatNumber'
import queryKeys from '../../services/queryKeys' import queryKeys from '../../services/queryKeys'
import { getDashData } from '../../services/siteServices' import {getDashData} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
import localSiteIcons from "../../helpers/localSiteIcons";
import RouteLinks from '../../RouteLinks';
export default function HomeCom() { export default function HomeCom() {
const {data, isFetching, isError, error} = useQuery({ const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.dashboard, queryKey: queryKeys.dashboard,
queryFn: () => getDashData() queryFn: () => getDashData(),
}) })
const dashData = data?.data // DASHBOARD DATA const dashData = data?.data // DASHBOARD DATA
// console.log('dashData', dashData) // console.log('dashData', dashData)
// loans, payments, recent_transactions [], request_summary // loans, payments, recent_transactions [], request_summary
return ( return (
<div className='w-full flex flex-col gap-8'> <div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Dashboard' paths={['Home', 'Dashboard']} /> <BreadcrumbCom title='Dashboard' paths={['Home', 'Dashboard']}/>
{(isFetching || isError) ? {(isFetching || isError) ?
<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 ? <p className='text-red-500'>{error.message}</p> : <p className='text-slate-800'>Loading...</p>} {isError ? <p className='text-red-500'>{error.message}</p> :
</div> <p className='text-slate-800'>Loading...</p>}
: </div>
<div className='grid grid-cols-1 gap-8'> :
<div className='w-full grid grid-cols-1 xl:grid-cols-3 gap-8'> <div className='grid grid-cols-1 gap-8'>
<div className='box min-h-[230] justify-between bg-[#F7D9E3] dark:bg-black-box text-black-body dark:text-white-body'> <div className='w-full grid grid-cols-1 xl:grid-cols-3 gap-8'>
<p className='text-base sm:text-lg font-bold hover:text-primary'>Loans</p> <div
<Widget1 /> className='box min-h-[230] justify-between bg-[#F7D9E3] dark:bg-black-box text-black-body dark:text-white-body'>
<div className='flex gap-2 items-end font-bold'> <p className='text-base sm:text-lg font-bold hover:text-primary'>Loans</p>
{/* <p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={formatNumber(dashData?.loans?.value)} timeInSeconds='1' /></p> */} <div className='flex flex-wrap gap-2 items-end font-bold'>
<p className='text-base sm:text-lg'><span className='text-sm'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={formatNumber(dashData?.loans?.value)} timeInSeconds='1' /></p> {/* <p className='text-3xl sm:text-[39px]'><span className='text-xl sm:text-2xl'>{dashData?.loans?.currency_text}</span><CustomCounter targetNumber={dashData?.loans?.value} timeInSeconds='1' /></p> */}
<p className='sm:text-[13.9px]'>{dashData?.loans?.text}</p> <p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
</div> {dashData?.loans?.currency_text}
</div> </span><CustomCounter targetNumber={formatNumber(dashData?.loans?.value)} timeInSeconds='1'/>
<div className='box min-h-[230] justify-between bg-[#CBF0F5] dark:bg-black-box text-black-body dark:text-white-body'> </p>
<p className='text-base sm:text-lg font-bold hover:text-primary'>Payments</p> <p className='sm:text-[13.9px]'>{dashData?.loans?.text}</p>
{/* <Widget2 /> */} </div>
<div className='flex gap-2 items-end font-bold'> </div>
<p className='text-sm sm:text-base'><span className='text-sm'>{dashData?.payments?.currency_text}</span><CustomCounter targetNumber={formatNumber(dashData?.payments?.value)} timeInSeconds='1' /></p> <div
<p className='sm:text-[13.9px]'>{dashData?.payments?.text}</p> className='box min-h-[230] justify-between bg-[#CBF0F5] dark:bg-black-box text-black-body dark:text-white-body'>
</div> <p className='text-base sm:text-lg font-bold hover:text-primary'>Payments</p>
</div> <div className='flex flex-wrap gap-2 items-end font-bold'>
<div className='box min-h-[230] justify-between bg-[#CBD4F4] dark:bg-black-box text-black-body dark:text-white-body'> <p className='text-xl sm:text-[30px]'><span className='text-lg sm:text-xl'>
<p className='mb-4 text-base sm:text-lg font-bold hover:text-primary'>Request Summary</p> {dashData?.payments?.currency_text}
<div className='grid grid-cols-2 gap-4 font-bold'> </span><CustomCounter targetNumber={formatNumber(dashData?.payments?.value)} timeInSeconds='1'/>
{ </p>
Object.values(dashData?.request_summary).map((item, index) => { <p className='sm:text-[13.9px]'>{dashData?.payments?.text}</p>
return ( </div>
<div key={index} className='flex items-center gap-2'> </div>
<div className='min-w-10 min-h-10 bg-white-body dark:bg-black-box dark:shadow-[0_0_0_1px_#f9f9f9] rounded-md flex justify-center items-center'> <div
<Icons name='sales' /> className='box min-h-[230] justify-between bg-[#CBD4F4] dark:bg-black-box text-black-body dark:text-white-body'>
<p className='mb-4 text-base sm:text-lg font-bold hover:text-primary'>Request Summary</p>
<div className='grid grid-cols-2 gap-4 font-bold'>
{
Object.values(dashData?.request_summary).map((item, index) => {
return (
<div key={index} className='flex items-center gap-2'>
<div
className='min-w-10 min-h-10 bg-white-body dark:bg-black-box dark:shadow-[0_0_0_1px_#f9f9f9] rounded-md flex justify-center items-center'>
<Icons name='sales'/>
</div>
<div>
<p className='font-bold text-base'><CustomCounter
targetNumber={Object.values(item)[0]} timeInSeconds='1'/></p>
<p className='text-12 text-slate-500'>{Object.keys(item)[0]}</p>
</div>
</div>
)
})
}
</div>
</div>
</div> </div>
<div>
<p className='font-bold text-base'>$<CustomCounter targetNumber={formatNumber(Object.values(item)[0])} timeInSeconds='1' />K</p>
<p className='text-12 text-slate-500'>{Object.keys(item)[0]}</p>
</div>
</div>
)
})
}
</div>
</div>
</div>
<div className='w-full'> <div className='w-full'>
<div className='box gap-8 bg-white dark:bg-black-box text-black-body dark:text-white-body'> <div className='box gap-8 bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<div className='grid grid-cols-1 xs:grid-cols-2 gap-4'> <div className='grid grid-cols-1 xs:grid-cols-2 gap-4'>
<div className='flex flex-col gap-1 order-2 xs:order-1'> <div className='flex flex-col gap-1 order-2 xs:order-1'>
<p className='font-bold text-base'>Recent Request</p> <p className='font-bold text-base'>Recent Request</p>
{/* <p className='text-12'>Over 500 members</p> */} {/* <p className='text-12'>Over 500 members</p> */}
</div> </div>
{/* <div className='order-1 xs:order-2 text-left xs:text-right'> {/* <div className='order-1 xs:order-2 text-left xs:text-right'>
<button className='font-bold bg-white-aside text-black-body text-12 px-4 py-2 hover:text-primary hover:bg-sky-50 dark:hover:text-white dark:hover:bg-primary dark:text-white-body dark:bg-black-body rounded-md'>+ New Member</button> <button className='font-bold bg-white-aside text-black-body text-12 px-4 py-2 hover:text-primary hover:bg-sky-50 dark:hover:text-white dark:hover:bg-primary dark:text-white-body dark:bg-black-body rounded-md'>+ New Member</button>
</div> */} </div> */}
</div> </div>
<TableWrapper data={dashData?.recent_transactions} itemsPerPage={10}> <table className="py-2 w-full text-sm">
{({ data }) => ( <thead className="py-2 text-sm text-slate-500 text-left font-semibold">
<>
<table className="py-2 w-full text-sm">
<thead className="py-2 text-sm text-slate-500 text-left font-semibold">
<tr> <tr>
<th scope="col" className="px-2 py-2"> <th scope="col" className="px-2 py-2">
Request Request
@@ -99,72 +108,94 @@ export default function HomeCom() {
Account Account
</th> </th>
<th scope="col" className="px-2"> <th scope="col" className="px-2">
Activity Channel
</th> </th>
<th scope="col" className="px-2 text-right"> <th scope="col" className="px-2 text-right">
Action Action
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{(data && data.length > 0) ? data?.map((item, index) => ( {(dashData?.recent_transactions && dashData?.recent_transactions.length > 0) ? dashData?.recent_transactions?.map((item, index) => {
<tr key={item?.id} className="py-2 border-t border-dashed border-slate-300"> if (index <= 10) {
<td className="px-2 py-2"> return (
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'> <tr key={item?.id} className="py-2 border-t border-dashed border-slate-300">
<img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese image" /> <td className="px-2 py-2">
<div className="text-left"> <div
<div className="text-base font-semibold">{item?.account_id}</div> className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'>
<div className="font-normal text-gray-500">{item?.channel}</div> <img className="w-10 h-10 rounded-md"
</div> src={localSiteIcons(`loan_icons/${item?.type}`)}
</div> alt="Icon"/>
</td> <div className="text-left">
<td className="px-2"> <div
<div className="text-left"> className="text-base font-semibold">{item?.transaction_id}</div>
<div className="text-base font-semibold">{item?.transaction_id}</div> <div
<div className="font-normal text-gray-500">{item?.type}</div> className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)} {getTimeFromDateString(item?.created_at)}</div>
</div> </div>
</td> </div>
<td className="px-2"> </td>
<div className="text-left"> <td className="px-2">
<div className="font-normal text-gray-500">50%</div> <div className="text-left">
<div className="relative h-[6px] w-full bg-white-body dark:bg-black-body rounded-full overflow-hidden"> <div
<div className={`absolute left-0 h-full w-1/2 bg-emerald-600`}></div> className="text-base font-semibold">{item?.account_id}</div>
</div> <div className="font-normal text-gray-500">{item?.type}</div>
</div> </div>
</td> </td>
<td className="px-2 text-right"> <td className="px-2">
<div className='flex items-center justify-end gap-3 md:gap-4'> <div className="text-left">
{/* <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="text-base font-semibold">{item?.channel}</div>
<Icons name='edit' /> </div>
</div> */} </td>
<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'> <td className="px-2 text-right">
<Icons name='eye' /> <div className='flex items-center justify-end gap-3 md:gap-4'>
</div> {/* <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='edit' />
<Icons name='trash' /> </div> */}
</div> */} <div
</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'>
</td> <Link to={RouteLinks.transaction_details_page}
</tr> state={{transactionID: item?.transaction_id}}>
)) <Icons name='eye'/>
: </Link>
<tr className="py-2 border-t border-dashed border-slate-300"> </div>
<td className="px-3 py-2" colSpan={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="flex justify-center items-center"> <Icons name='trash' />
No Record Found </div> */}
</div> </div>
</td> </td>
</tr> </tr>
} )
</tbody> }
</table> }
</> )
)} :
</TableWrapper> <tr className="py-2 border-t border-dashed border-slate-300">
</div> <td className="px-3 py-2" colSpan={4}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
<>
{dashData?.recent_transactions.length > 10 &&
<tr className="py-2 border-t border-dashed text-right text-primary border-slate-300">
<td className="px-3 py-2" colSpan={4}>
<Link to={RouteLinks.transactionsPage}
className="flex justify-end items-center">
More ...
</Link>
</td>
</tr>
}
</>
</tbody>
</table>
</div>
</div>
</div>
}
</div> </div>
</div> )
}
</div>
)
} }
+176 -176
View File
@@ -1,187 +1,187 @@
import {useEffect, useRef} from 'react' // import {useEffect, useRef} from 'react'
import ApexCharts from 'apexcharts' // import ApexCharts from 'apexcharts'
const Widget1 = ({chartHeight='50px'}) => { // const Widget1 = ({chartHeight='50px'}) => {
const chartRef = useRef(null) // const chartRef = useRef(null)
const {mode} = '' // to be replaced by theme mode value later // const {mode} = '' // to be replaced by theme mode value later
useEffect(() => { // useEffect(() => {
const chart = refreshChart() // const chart = refreshChart()
return () => { // return () => {
if (chart) { // if (chart) {
chart.destroy() // chart.destroy()
} // }
} // }
// eslint-disable-next-line react-hooks/exhaustive-deps // // eslint-disable-next-line react-hooks/exhaustive-deps
}, [chartRef, mode]) // }, [chartRef, mode])
const refreshChart = () => { // const refreshChart = () => {
if (!chartRef.current) { // if (!chartRef.current) {
return // return
} // }
const chart = new ApexCharts(chartRef.current, chartOptions(chartHeight)) // const chart = new ApexCharts(chartRef.current, chartOptions(chartHeight))
if (chart) { // if (chart) {
chart.render() // chart.render()
} // }
return chart // return chart
} // }
return ( // return (
<div className='w-full'> // <div className='w-full'>
{/* end::Title */} // {/* end::Title */}
<div // <div
ref={chartRef} // ref={chartRef}
className='mixed-widget-13-chart' // className='mixed-widget-13-chart'
style={{height: chartHeight, minHeight: chartHeight}} // style={{height: chartHeight, minHeight: chartHeight}}
></div> // ></div>
</div> // </div>
) // )
} // }
const chartOptions = (chartHeight) => { // const chartOptions = (chartHeight) => {
// const labelColor = getCSSVariableValue('--bs-gray-800') // // const labelColor = getCSSVariableValue('--bs-gray-800')
// const strokeColor = getCSSVariableValue('--bs-gray-300') // // const strokeColor = getCSSVariableValue('--bs-gray-300')
const labelColor = '#e9e9e9' // const labelColor = '#e9e9e9'
const strokeColor = '#e3e3e3' // const strokeColor = '#e3e3e3'
// const strokeColor = getCSSVariableValue('--bs-gray-300') as string // // const strokeColor = getCSSVariableValue('--bs-gray-300') as string
return { // return {
series: [ // series: [
{ // {
name: 'Loans', // name: 'Loans',
data: [15, 25, 15, 40, 20, 50], // data: [15, 25, 15, 40, 20, 50],
}, // },
], // ],
grid: { // grid: {
show: false, // show: false,
padding: { // padding: {
top: 0, // top: 0,
bottom: 0, // bottom: 0,
left: 0, // left: 0,
right: 0, // right: 0,
}, // },
}, // },
chart: { // chart: {
fontFamily: 'inherit', // fontFamily: 'inherit',
type: 'area', // type: 'area',
height: chartHeight, // height: chartHeight,
toolbar: { // toolbar: {
show: false, // show: false,
}, // },
zoom: { // zoom: {
enabled: false, // enabled: false,
}, // },
sparkline: { // sparkline: {
enabled: true, // enabled: true,
}, // },
}, // },
plotOptions: {}, // plotOptions: {},
legend: { // legend: {
show: false, // show: false,
}, // },
dataLabels: { // dataLabels: {
enabled: false, // enabled: false,
}, // },
fill: { // fill: {
type: 'gradient', // type: 'gradient',
gradient: { // gradient: {
opacityFrom: 0.4, // opacityFrom: 0.4,
opacityTo: 0, // opacityTo: 0,
stops: [20, 120, 120, 120], // stops: [20, 120, 120, 120],
}, // },
}, // },
stroke: { // stroke: {
curve: 'smooth', // curve: 'smooth',
show: true, // show: true,
width: 3, // width: 3,
colors: ['#FFFFFF'], // colors: ['#FFFFFF'],
}, // },
xaxis: { // xaxis: {
categories: ['Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'], // categories: ['Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
axisBorder: { // axisBorder: {
show: false, // show: false,
}, // },
axisTicks: { // axisTicks: {
show: false, // show: false,
}, // },
labels: { // labels: {
show: false, // show: false,
style: { // style: {
colors: labelColor, // colors: labelColor,
fontSize: '12px', // fontSize: '12px',
}, // },
}, // },
crosshairs: { // crosshairs: {
show: false, // show: false,
position: 'front', // position: 'front',
stroke: { // stroke: {
color: strokeColor, // color: strokeColor,
width: 1, // width: 1,
dashArray: 3, // dashArray: 3,
}, // },
}, // },
tooltip: { // tooltip: {
enabled: true, // enabled: true,
formatter: undefined, // formatter: undefined,
offsetY: 0, // offsetY: 0,
style: { // style: {
fontSize: '12px', // fontSize: '12px',
}, // },
}, // },
}, // },
yaxis: { // yaxis: {
min: 0, // min: 0,
max: 60, // max: 60,
labels: { // labels: {
show: false, // show: false,
style: { // style: {
colors: labelColor, // colors: labelColor,
fontSize: '12px', // fontSize: '12px',
}, // },
}, // },
}, // },
states: { // states: {
normal: { // normal: {
filter: { // filter: {
type: 'none', // type: 'none',
value: 0, // value: 0,
}, // },
}, // },
hover: { // hover: {
filter: { // filter: {
type: 'none', // type: 'none',
value: 0, // value: 0,
}, // },
}, // },
active: { // active: {
allowMultipleDataPointsSelection: false, // allowMultipleDataPointsSelection: false,
filter: { // filter: {
type: 'none', // type: 'none',
value: 0, // value: 0,
}, // },
}, // },
}, // },
tooltip: { // tooltip: {
style: { // style: {
fontSize: '12px', // fontSize: '12px',
}, // },
y: { // y: {
formatter: function (val) { // formatter: function (val) {
return '$' + val + ' thousand' // return '$' + val + ' thousand'
}, // },
}, // },
}, // },
colors: ['#ffffff'], // colors: ['#ffffff'],
markers: { // markers: {
colors: [labelColor], // colors: [labelColor],
strokeColors: [strokeColor], // strokeColors: [strokeColor],
strokeWidth: 3, // strokeWidth: 3,
}, // },
} // }
} // }
export {Widget1} // export {Widget1}
+136 -136
View File
@@ -1,147 +1,147 @@
import {useEffect, useRef} from 'react' // import {useEffect, useRef} from 'react'
import ApexCharts from 'apexcharts' // import ApexCharts from 'apexcharts'
const Widget2 = ({chartHeight='100px'}) => { // const Widget2 = ({chartHeight='100px'}) => {
const chartRef = useRef(null) // const chartRef = useRef(null)
const {mode} = '' // to be replaced by theme mode value later // const {mode} = '' // to be replaced by theme mode value later
useEffect(() => { // useEffect(() => {
const chart = refreshChart() // const chart = refreshChart()
return () => { // return () => {
if (chart) { // if (chart) {
chart.destroy() // chart.destroy()
} // }
} // }
// eslint-disable-next-line react-hooks/exhaustive-deps // // eslint-disable-next-line react-hooks/exhaustive-deps
}, [chartRef, mode]) // }, [chartRef, mode])
const refreshChart = () => { // const refreshChart = () => {
if (!chartRef.current) { // if (!chartRef.current) {
return // return
} // }
const chart = new ApexCharts(chartRef.current, chartOptions(chartHeight)) // const chart = new ApexCharts(chartRef.current, chartOptions(chartHeight))
if (chart) { // if (chart) {
chart.render() // chart.render()
} // }
return chart // return chart
} // }
return ( // return (
<div className='w-full'> // <div className='w-full'>
{/* end::Title */} // {/* end::Title */}
<div // <div
ref={chartRef} // ref={chartRef}
className='mixed-widget-13-chart' // className='mixed-widget-13-chart'
style={{height: chartHeight, minHeight: chartHeight}} // style={{height: chartHeight, minHeight: chartHeight}}
></div> // ></div>
</div> // </div>
) // )
} // }
const chartOptions = (chartHeight) => { // const chartOptions = (chartHeight) => {
// const labelColor = getCSSVariableValue('--bs-gray-800') // // const labelColor = getCSSVariableValue('--bs-gray-800')
return { // return {
series: [ // series: [
{ // {
name: 'Payments', // name: 'Payments',
data: [1, 2.1, 1, 2.1, 4.1, 6.1, 4.1, 4.1, 2.1, 4.1, 2.1, 3.1, 1, 1, 2.1], // data: [1, 2.1, 1, 2.1, 4.1, 6.1, 4.1, 4.1, 2.1, 4.1, 2.1, 3.1, 1, 1, 2.1],
}, // },
], // ],
chart: { // chart: {
fontFamily: 'inherit', // fontFamily: 'inherit',
height: chartHeight, // height: chartHeight,
type: 'bar', // type: 'bar',
toolbar: { // toolbar: {
show: false, // show: false,
}, // },
}, // },
grid: { // grid: {
show: false, // show: false,
padding: { // padding: {
top: 0, // top: 0,
bottom: 0, // bottom: 0,
left: 0, // left: 0,
right: 0, // right: 0,
}, // },
}, // },
colors: ['#ffffff'], // colors: ['#ffffff'],
plotOptions: { // plotOptions: {
bar: { // bar: {
borderRadius: 2.5, // borderRadius: 2.5,
dataLabels: { // dataLabels: {
position: 'top', // top, center, bottom // position: 'top', // top, center, bottom
}, // },
columnWidth: '20%', // columnWidth: '20%',
}, // },
}, // },
dataLabels: { // dataLabels: {
enabled: false, // enabled: false,
formatter: function (val) { // formatter: function (val) {
return val + '%' // return val + '%'
}, // },
offsetY: -20, // offsetY: -20,
style: { // style: {
fontSize: '12px', // fontSize: '12px',
colors: ['#304758'], // colors: ['#304758'],
}, // },
}, // },
xaxis: { // xaxis: {
labels: { // labels: {
show: false, // show: false,
}, // },
categories: [ // categories: [
'Jan', // 'Jan',
'Feb', // 'Feb',
'Mar', // 'Mar',
'Apr', // 'Apr',
'May', // 'May',
'Jun', // 'Jun',
'Jul', // 'Jul',
'Aug', // 'Aug',
'Sep', // 'Sep',
'Oct', // 'Oct',
'Nov', // 'Nov',
'Dec', // 'Dec',
'Jan', // 'Jan',
'Feb', // 'Feb',
'Mar', // 'Mar',
], // ],
position: 'top', // position: 'top',
axisBorder: { // axisBorder: {
show: false, // show: false,
}, // },
axisTicks: { // axisTicks: {
show: false, // show: false,
}, // },
crosshairs: { // crosshairs: {
show: false, // show: false,
}, // },
tooltip: { // tooltip: {
enabled: false, // enabled: false,
}, // },
}, // },
yaxis: { // yaxis: {
show: false, // show: false,
axisBorder: { // axisBorder: {
show: false, // show: false,
}, // },
axisTicks: { // axisTicks: {
show: false, // show: false,
// background: labelColor, // // background: labelColor,
}, // },
labels: { // labels: {
show: false, // show: false,
formatter: function (val) { // formatter: function (val) {
return val + '%' // return val + '%'
}, // },
}, // },
}, // },
} // }
} // }
export {Widget2} // export {Widget2}
+5 -5
View File
@@ -5,16 +5,15 @@ import { generalLayoutContext } from "../../context/GeneralLayoutContext"
import UserAvatar from '../../assets/user_avatar.jpg' import UserAvatar from '../../assets/user_avatar.jpg'
import HandBurger from "./HandBurger" import HandBurger from "./HandBurger"
import { Link, useLocation } from "react-router-dom" import { Link } from "react-router-dom"
import RouteLinks from "../../RouteLinks" import RouteLinks from "../../RouteLinks"
import { useState } from "react";
import MainBtn from "../MainBtn"; import MainBtn from "../MainBtn";
import { TbLogout2 } from "react-icons/tb"; import { TbLogout2 } from "react-icons/tb";
import Icons from "../Icons"; import Icons from "../Icons";
export default function DashboardHeader() { export default function DashboardHeader() {
let {pathname} = useLocation() // let {pathname} = useLocation()
const {theme, handleTheme, setLogoutModal, activeMenu, handleActiveMenu, showAsideDrawer, setShowAsideDrawer} = generalLayoutContext() const {theme, handleTheme, setLogoutModal, activeMenu, handleActiveMenu, showAsideDrawer, setShowAsideDrawer} = generalLayoutContext()
@@ -36,11 +35,9 @@ export default function DashboardHeader() {
</Link> </Link>
{/* RIGHT DRAWER BUTTON */} {/* RIGHT DRAWER BUTTON */}
{pathname == '/' &&
<div onClick={()=>setShowAsideDrawer('right-aside')} className='large:hidden w-10 h-10 border border-slate-300 text-slate-500 dark:text-white-body rounded-md px-2 flex justify-center items-center gap-2 cursor-pointer' title='Switch Color Mode'> <div onClick={()=>setShowAsideDrawer('right-aside')} className='large:hidden w-10 h-10 border border-slate-300 text-slate-500 dark:text-white-body rounded-md px-2 flex justify-center items-center gap-2 cursor-pointer' title='Switch Color Mode'>
<Icons name='right-panel' className="text-sm md:text-xl font-bold" /> <Icons name='right-panel' className="text-sm md:text-xl font-bold" />
</div> </div>
}
{/* MESSAGE */} {/* MESSAGE */}
{/* <button onClick={()=>handleDrawer(drawerName.chat)} className="relative px-2 flex justify-center items-center gap-2 cursor-pointer"> {/* <button onClick={()=>handleDrawer(drawerName.chat)} className="relative px-2 flex justify-center items-center gap-2 cursor-pointer">
@@ -60,6 +57,8 @@ export default function DashboardHeader() {
<div onClick={()=>handleActiveMenu('avatar')} className='relative cursor-pointer w-10 h-10 rounded shadow-round_black dark:shadow-round_white'> <div onClick={()=>handleActiveMenu('avatar')} className='relative cursor-pointer w-10 h-10 rounded shadow-round_black dark:shadow-round_white'>
<img src={UserAvatar} alt='user avatar' className='w-full h-full p-1 rounded-full' /> <img src={UserAvatar} alt='user avatar' className='w-full h-full p-1 rounded-full' />
{activeMenu == 'avatar' && {activeMenu == 'avatar' &&
<>
<div className="fixed top-0 left-0 right-0 bottom-0 bg-black/10"></div>
<div className="pop-modal z-[777] absolute p-4 w-52 sm:w-96 bg-white dark:bg-black-box right-0 top-16 rounded shadow-round_black dark:shadow-round_white"> <div className="pop-modal z-[777] absolute p-4 w-52 sm:w-96 bg-white dark:bg-black-box right-0 top-16 rounded shadow-round_black dark:shadow-round_white">
<div className="w-full h-full flex flex-col gap-4"> <div className="w-full h-full flex flex-col gap-4">
<div className="flex flex-col text-black dark:text-white text-base sm:text-lg"> <div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
@@ -77,6 +76,7 @@ export default function DashboardHeader() {
</div> </div>
</div> </div>
</div> </div>
</>
} }
</div> </div>
</div> </div>
+3 -9
View File
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react' import { Outlet } from 'react-router-dom'
import { Outlet, useLocation } from 'react-router-dom'
import DashboardHeader from './DashboardHeader' import DashboardHeader from './DashboardHeader'
import { generalLayoutContext } from '../../context/GeneralLayoutContext' import { generalLayoutContext } from '../../context/GeneralLayoutContext'
@@ -8,7 +7,7 @@ import RightAsideBar from './rightaside/RightAsideBar'
export default function DashboardLayout() { export default function DashboardLayout() {
let {pathname} = useLocation() // let {pathname} = useLocation()
const {showAsideDrawer, setShowAsideDrawer} = generalLayoutContext() const {showAsideDrawer, setShowAsideDrawer} = generalLayoutContext()
@@ -18,9 +17,6 @@ export default function DashboardLayout() {
<DashboardAside /> <DashboardAside />
</div> </div>
{/* <div className={`${showAsideDrawer =='aside' ? 'left-0' : '-left-full'} w-4/5 sm:w-72 px-8 py-4 lg:hidden fixed inset-0 z-[999] bg-white-aside dark:bg-black-aside dark:text-white-light`}>
<DashboardAside />
</div> */}
<div className={`${showAsideDrawer =='aside' ? 'left-0' : '-left-full'} lg:hidden w-full fixed inset-0 z-[999]`}> <div className={`${showAsideDrawer =='aside' ? 'left-0' : '-left-full'} lg:hidden w-full fixed inset-0 z-[999]`}>
<div className={`${showAsideDrawer =='aside' ? 'fixed left-0 top-0 inset-0' : '-left-full'} w-full bg-[rgba(0,_0,_0,_0.2)] dark:bg-[rgba(0,_0,_0,_0.4)] transition-all cursor-pointer`} onClick={()=>setShowAsideDrawer('')} ></div> <div className={`${showAsideDrawer =='aside' ? 'fixed left-0 top-0 inset-0' : '-left-full'} w-full bg-[rgba(0,_0,_0,_0.2)] dark:bg-[rgba(0,_0,_0,_0.4)] transition-all cursor-pointer`} onClick={()=>setShowAsideDrawer('')} ></div>
<div className={`fixed px-8 py-4 h-full w-4/5 sm:w-[400px] bg-white-aside dark:bg-black-aside dark:text-white-light`}> <div className={`fixed px-8 py-4 h-full w-4/5 sm:w-[400px] bg-white-aside dark:bg-black-aside dark:text-white-light`}>
@@ -28,7 +24,7 @@ export default function DashboardLayout() {
</div> </div>
</div> </div>
<div className={`main w-full bg-inherit ${pathname == '/' && 'large:mr-[400px]'}`}> <div className={`main w-full bg-inherit large:mr-[400px]`}>
<div className='fixed top-0 left-0 z-[980] w-full px-8 bg-inherit lg:hidden'> <div className='fixed top-0 left-0 z-[980] w-full px-8 bg-inherit lg:hidden'>
<DashboardHeader /> <DashboardHeader />
</div> </div>
@@ -45,7 +41,6 @@ export default function DashboardLayout() {
</div> </div>
{/* Right Aisde */} {/* Right Aisde */}
{pathname == '/' &&
<> <>
<div className={`px-8 py-4 hidden large:flex fixed right-5 top-0 bottom-0 sm:w-[400px] bg-[#192440] dark:bg-[#1E1E2D] text-white-body`}> <div className={`px-8 py-4 hidden large:flex fixed right-5 top-0 bottom-0 sm:w-[400px] bg-[#192440] dark:bg-[#1E1E2D] text-white-body`}>
<RightAsideBar /> <RightAsideBar />
@@ -57,7 +52,6 @@ export default function DashboardLayout() {
</div> </div>
</div> </div>
</> </>
}
</div> </div>
) )
} }
+130 -120
View File
@@ -4,11 +4,12 @@ import DummyLogo from "../../DummyLogo";
import MainBtn from "../../MainBtn"; 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";
import localImgLoader from '../../../helpers/localImageLoader';
export default function DashboardAside() { export default function DashboardAside() {
@@ -17,138 +18,147 @@ export default function DashboardAside() {
const {setLogoutModal, activeMenu, handleActiveMenu} = generalLayoutContext() const {setLogoutModal, activeMenu, handleActiveMenu} = generalLayoutContext()
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> <img className='w-2/3 h-auto' src={localImgLoader('simbrella-bko-logo.png')}/>
{/* <hr className="border-slate-400" /> */} </div>
{/* <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={index}> <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={index} 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={index}> let active = subItem.status == 1 ? true : false
<AsideLink key={index} 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 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 if (active && hasSubLinks) {
})} let subLinkList = subItem.subLinks.filter(value => value.to).map(item => { // specific open
</> if (item.to) {
</AsideLinkWithSubLinks> return item.to
) }
}else{ })
return null return (
} <AsideLinkWithSubLinks key={subItem.name} name={subItem.name}
})} icon={subItem.icon}
</> isOpen={subLinkList.includes(pathname)}>
</AsideLinkWithSubLinks> <>
</div> {subItem.subLinks.map((item, index) => {
) let active = item.status == 1 ? true : false
} if (active) {
})} return (
</div> <div key={index}>
<AsideLink key={index} to={item.to}
<div className='py-2 mt-4 relative'> name={item.name}
<div className="group w-full flex items-center gap-2"> icon={item.icon}/>
<div className="w-full flex items-center gap-2"> </div>
<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> </AsideLinkWithSubLinks>
</div> )
<button onClick={()=>handleActiveMenu('settings')} className="peer text-slate-500 dark:text-white-body"> } else {
<Icons name='settings' className='text-3xl' /> return null
</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="w-full min-h-48 flex flex-col justify-between gap-4"> </>
<div className="w-full h-full"> </AsideLinkWithSubLinks>
<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>
<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:'First Advance', title:'Loan', status:1, icon: 'arrow-right', subLinks: [ {
{name: 'Request', status:1, icon: 'dot', to: RouteLinks.requestPage}, name: 'First Advance', title: 'Loan', status: 1, icon: 'arrow-right', subLinks: [
{name: 'Loans', status:1, icon: 'dot', to: RouteLinks.loansPage}, {name: 'Transactions', status: 1, icon: 'dot', to: RouteLinks.transactionsPage},
{name: 'Selected Loans', status:1, icon: 'dot', to: RouteLinks.selectedLoanPage}, {name: 'Loans', status: 1, icon: 'dot', to: RouteLinks.loansPage},
{name: 'Applications', status:1, icon: 'dot', to: RouteLinks.applicationsLoanPage}, {name: 'Repayments', status: 1, icon: 'dot', to: RouteLinks.repaymentsPage},
{name: 'Approved Loans', status:1, icon: 'dot', to: RouteLinks.approvedLoansPage}, {name: 'Loan Charges', status: 1, icon: 'dot', to: RouteLinks.loanChargesPage},
{name: 'Disbursements', status:1, icon: 'dot', to: RouteLinks.disbursementsLoanPage}, {name: 'Eligibility', status: 1, icon: 'dot', to: RouteLinks.eligibility},
{name: 'Payments', status:1, icon: 'dot', to: ''}, {
{name: 'Configurations', status:1, icon: 'arrow-right', subLinks: [ name: 'Configurations', status: 1, icon: 'arrow-right', subLinks: [
{name: 'Loan Offers', status:1, icon: 'dot', to: RouteLinks.loanOffersPage }, {name: 'Loan Offers', status: 1, icon: 'dot', to: RouteLinks.offers},
] ]
}, },
], ],
}, },
// {name:'Product 2', title:'Product 2', status:1, icon: 'product', subLinks: [ // {name:'Product 2', title:'Product 2', status:1, icon: 'product', subLinks: [
+24 -69
View File
@@ -1,78 +1,33 @@
import React from 'react' import React from 'react'
import Img from '../../../assets/user_avatar.jpg' import {Link} from 'react-router-dom'
import Img from '../../../assets/loans.png'
import formatNumber from '../../../helpers/formatNumber'
import CustomCounter from '../../CustomCounter' import CustomCounter from '../../CustomCounter'
import RouteLinks from '../../../RouteLinks'
export default function Orders() { export default function Orders({data}) {
return ( return (
<div className='h-full p-2 sm:p-4 large:p-8 flex flex-col gap-16 overflow-y-auto aside-scroll-design'> <div className='h-full flex flex-col gap-16 overflow-y-auto aside-scroll-design'>
<div className='flex flex-col gap-4'> <div className='flex flex-col gap-4'>
<p className='text-base text-white-body font-bold'>Support Ticket</p> <p className='text-base text-white-body font-bold'>Recent Loans</p>
<div className='grid grid-cols-2 gap-4 sm:gap-6 large:gap-8'>
<div className='p-2 sm:p-3 large:p-4 flex flex-col border border-slate-500 border-dashed'>
<p className='text-base font-bold text-white-body'>
<CustomCounter targetNumber={18} timeInSeconds={1} />
</p>
<p className='text-sm text-slate-500'>Pending</p>
</div>
<div className='p-2 sm:p-3 large:p-4 flex flex-col border border-slate-500 border-dashed'>
<p className='text-base font-bold text-white-body'>
<CustomCounter targetNumber={5} timeInSeconds={1} />
</p>
<p className='text-sm text-slate-500'>Approved</p>
</div>
<div className='p-2 sm:p-3 large:p-4 flex flex-col border border-slate-500 border-dashed'>
<p className='text-base font-bold text-white-body'>
<CustomCounter targetNumber={1} timeInSeconds={1} />
</p>
<p className='text-sm text-slate-500'>Rejected</p>
</div>
<div className='p-2 sm:p-3 large:p-4 flex flex-col border border-slate-500 border-dashed'>
<p className='text-base font-bold text-white-body'>
<CustomCounter targetNumber={1} timeInSeconds={1} />
</p>
<p className='text-sm text-slate-500'>Created</p>
</div>
</div>
</div>
<div className='flex flex-col gap-4'>
<p className='text-base text-white-body font-bold'>Best Ticket</p>
<div className='flex flex-col gap-4'> <div className='flex flex-col gap-4'>
<div className='flex gap-3 items-center'> {data.map((item, index)=>{
<div className='px-4 py-2 bg-[#0E172E] rounded-md'> return (
<img src={Img} className='w-8' alt="Order Image" /> <Link
</div> to={RouteLinks.transaction_details_page}
<div className='flex-col'> state={{transactionID: item?.transaction_id}}
<p className='text-base font-bold text-white-body'>Project Briefing</p> key={index} className='flex gap-3 items-center'
<p className='text-sm text-slate-500'>Project Manager</p> >
</div> <div className='px-4 py-2 bg-[#0E172E] rounded-md'>
</div> <img src={Img} className='w-8' alt="Order Image" />
<div className='flex gap-3 items-center'> </div>
<div className='px-4 py-2 bg-[#0E172E] rounded-md'> <div className='flex-col'>
<img src={Img} className='w-8' alt="Order Image" /> <p className='text-sm font-bold text-white-body'>{item?.customer_id}</p>
</div> <p className='text-sm text-slate-500'>{formatNumber(item?.current_loan_amount)}</p>
<div className='flex-col'> </div>
<p className='text-base font-bold text-white-body'>Project Briefing</p> </Link>
<p className='text-sm text-slate-500'>Project Manager</p> )
</div> })}
</div>
<div className='flex gap-3 items-center'>
<div className='px-4 py-2 bg-[#0E172E] rounded-md'>
<img src={Img} className='w-8' alt="Order Image" />
</div>
<div className='flex-col'>
<p className='text-base font-bold text-white-body'>Project Briefing</p>
<p className='text-sm text-slate-500'>Project Manager</p>
</div>
</div>
<div className='flex gap-3 items-center'>
<div className='px-4 py-2 bg-[#0E172E] rounded-md'>
<img src={Img} className='w-8' alt="Order Image" />
</div>
<div className='flex-col'>
<p className='text-base font-bold text-white-body'>Project Briefing</p>
<p className='text-sm text-slate-500'>Project Manager</p>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -1,4 +1,7 @@
import React, { useState } from 'react' import React, { useState } from 'react'
import { useQuery } from "@tanstack/react-query";
import queryKeys from '../../../services/queryKeys'
import { getRecentLoans } from '../../../services/siteServices'
import Icons from '../../Icons' import Icons from '../../Icons'
import Orders from './Orders' import Orders from './Orders'
import Tickets from './Tickets' import Tickets from './Tickets'
@@ -13,25 +16,41 @@ export default function RightAsideBar() {
setActive(lowerStr) setActive(lowerStr)
} }
return ( const {data, isFetching, isError, error} = useQuery({
<div className='w-full h-full flex flex-col gap-8'> queryKey: queryKeys.recent_loans,
{/* Menu */} queryFn: () => getRecentLoans()
<div className='grid grid-cols-3 gap-8'> })
<button name='orders' onClick={() => handleActiveMenu('orders')} className={`flex justify-center items-center px-2 py-3 large:px-4 large:py-5 rounded-md shadow-round_white bg-[#0E172E] text-white-body hover:scale-[1.1] ${active == 'orders' && 'scale-[1.2]'}`}>
<Icons name='dashboard' className='text-3xl' />
</button>
<button name='tickets' onClick={() => handleActiveMenu('tickets')} className={`flex justify-center items-center px-2 py-3 large:px-4 large:py-5 rounded-md shadow-round_white bg-[#0E172E] text-white-body hover:scale-[1.1] ${active == 'tickets' && 'scale-[1.2]'}`}>
<Icons name='settings' className='text-3xl' />
</button>
<button name='tasks' onClick={() => handleActiveMenu('tasks')} className={`flex justify-center items-center px-2 py-3 large:px-4 large:py-5 rounded-md shadow-round_white bg-[#0E172E] text-white-body hover:scale-[1.1] ${active == 'tasks' && 'scale-[1.2]'}`}>
<Icons name='dashboard' className='text-3xl' />
</button>
</div>
{/* Body */} const loanList = data?.data?.loans
{active == 'orders' && <Orders />}
{active == 'tickets' && <Tickets />} return (
{active == 'tasks' && <Tasks />} <div className='w-full h-full flex flex-col gap-8'>
</div> {/* Menu */}
) <div className='grid grid-cols-3 gap-8'>
<button name='orders' onClick={() => handleActiveMenu('orders')} className={`flex justify-center items-center px-2 py-3 large:px-4 large:py-5 rounded-md shadow-round_white bg-[#0E172E] text-white-body hover:scale-[1.1] ${active == 'orders' && 'scale-[1.2]'}`}>
<Icons name='dashboard' className='text-3xl' />
</button>
{/*<button name='tickets' onClick={() => handleActiveMenu('tickets')} className={`flex justify-center items-center px-2 py-3 large:px-4 large:py-5 rounded-md shadow-round_white bg-[#0E172E] text-white-body hover:scale-[1.1] ${active == 'tickets' && 'scale-[1.2]'}`}>*/}
{/* <Icons name='settings' className='text-3xl' />*/}
{/*</button>*/}
{/*<button name='tasks' onClick={() => handleActiveMenu('tasks')} className={`flex justify-center items-center px-2 py-3 large:px-4 large:py-5 rounded-md shadow-round_white bg-[#0E172E] text-white-body hover:scale-[1.1] ${active == 'tasks' && 'scale-[1.2]'}`}>*/}
{/* <Icons name='dashboard' className='text-3xl' />*/}
{/*</button>*/}
</div>
{/* Body */}
{(isFetching || isError) ?
<div className=''>
{isError ? <p className='p-8 bg-white text-red-500'>{error.message}</p> :
<p className='text-white'>Loading...</p>}
</div>
:
<div className='w-full'>
{active === 'orders' && <Orders data={loanList} />}
{/*{active == 'tickets' && <Tickets />}*/}
{/*{active == 'tasks' && <Tasks />}*/}
</div>
}
</div>
)
} }
@@ -6,7 +6,7 @@ export default function Tickets() {
return ( return (
<div className='h-full p-2 sm:p-4 large:p-8 flex flex-col gap-16 overflow-y-auto aside-scroll-design'> <div className='h-full p-2 sm:p-4 large:p-8 flex flex-col gap-16 overflow-y-auto aside-scroll-design'>
<div className='flex flex-col gap-4'> <div className='flex flex-col gap-4'>
<p className='text-base text-white-body font-bold'>Support Ticket</p> <p className='text-base text-white-body font-bold'>Recent Repayment</p>
<div className='grid grid-cols-2 gap-4 sm:gap-6 large:gap-8'> <div className='grid grid-cols-2 gap-4 sm:gap-6 large:gap-8'>
<div className='p-2 sm:p-3 large:p-4 flex flex-col border border-slate-500 border-dashed'> <div className='p-2 sm:p-3 large:p-4 flex flex-col border border-slate-500 border-dashed'>
<p className='text-base font-bold text-white-body'> <p className='text-base font-bold text-white-body'>
@@ -35,7 +35,7 @@ export default function Tickets() {
</div> </div>
</div> </div>
<div className='flex flex-col gap-4'> <div className='flex flex-col gap-4'>
<p className='text-base text-white-body font-bold'>Best Ticket</p> <p className='text-base text-white-body font-bold'>Tracked Errors</p>
<div className='flex flex-col gap-4'> <div className='flex flex-col gap-4'>
<div className='flex gap-3 items-center'> <div className='flex gap-3 items-center'>
<div className='px-4 py-2 bg-[#0E172E] rounded-md'> <div className='px-4 py-2 bg-[#0E172E] rounded-md'>
@@ -0,0 +1,169 @@
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 getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber'
import Avatar from '../../assets/repay.png'
export default function LoansChargesCom() {
const [page, setPage] = useState(1)
const [allLoanCharges, setAllLoanCharges] = 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 loanCharges = allLoanCharges?.data?.loan_charges // LOAN CHARGES LIST
const pagination = allLoanCharges?.data?.pagination
const isFetching = allLoanCharges?.loading
const isError = allLoanCharges?.error
useEffect(() => {
setAllLoanCharges(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getLoanCharges({...payload, page}).then(res => {
if (res?.status != 200) {
setAllLoanCharges(prev => ({...prev, loading: false}))
return
}
setAllLoanCharges({loading: false, error: '', data: res?.data})
}).catch(err => {
setAllLoanCharges({loading: false, error: 'error occurred', data: {}})
console.log('ERR', err)
})
}, [page, willFilter])
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Charges' paths={['Dashboard', 'Charges']}/>
<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>
:
<>
{/* 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='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}/>
</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={loanCharges} 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">
TransactionID/Fee Type
</th>
{/* <th scope="col" className="px-2">
Loan
</th> */}
<th scope="col" className="px-2 text-right">
Amount
</th>
<th scope="col" className="px-2 text-right">
Added
</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={Avatar}
alt="Jese image"/>
<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?.code}</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-semibold text-green-500">#{formatNumber(item?.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'>
<Icons name='eye'/>
</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>
)
}
@@ -0,0 +1,119 @@
import React, {useState} from 'react'
import {useQuery} from "@tanstack/react-query";
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 {getLoanCharges} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber';
export default function LoanChargesCom() {
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.loan_charges, page],
queryFn: () => getLoanCharges({page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const loanCharges = data?.data?.loan_charges // LOAN CHARGES LIST
const pagination = data?.data?.pagination
return (
<div className='w-full flex flex-col gap-8' style={{backgroundColor: 'aliceblue'}}>
<BreadcrumbCom title='Loan Charges' paths={['Dashboard', 'Loan Charges']}/>
<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>
:
<TablePaginatedWrapper data={loanCharges} 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">
Name
</th>
{/* <th scope="col" className="px-2">
Loan
</th> */}
<th scope="col" className="px-2 text-right">
Amount
</th>
<th scope="col" className="px-2 text-right">
Added
</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'>
<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?.code}</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?.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'>
<Icons name='eye'/>
</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>
)
}
+173 -92
View File
@@ -1,110 +1,191 @@
import React from 'react' import {useEffect, useState} from 'react'
import { useQuery } from "@tanstack/react-query";
import {Link} from 'react-router-dom' import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom' import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TableWrapper from '../tableWrapper/TableWrapper' import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons' import Icons from '../Icons'
import {getLoans} from '../../services/siteServices'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import { selectLoan } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString'; import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString'; import Avatar from '../../assets/loans.png'
import RouteLinks from '../../RouteLinks';
import formatNumber from '../../helpers/formatNumber'
export default function LoansCom() { export default function LoansCom() {
const {data, isFetching, isError, error} = useQuery({ const [page, setPage] = useState(1)
queryKey: queryKeys.select_loan, const [allLoans, setAllLoans] = useState({loading: true, error: '', data: {}})
queryFn: () => selectLoan()
})
const selectUsers = data?.data?.result_data?.data // APPLY LOAN LIST 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 loans = allLoans?.data?.loans // LOANS LIST
const pagination = allLoans?.data?.pagination
const isFetching = allLoans?.loading
const isError = allLoans?.error
useEffect(() => {
setAllLoans(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getLoans({...payload, page}).then(res => {
if (res?.status != 200) {
setAllLoans(prev => ({...prev, loading: false}))
return
}
setAllLoans({loading: false, error: '', data: res?.data})
}).catch(err => {
setAllLoans({loading: false, error: 'error occurred', data: {}})
console.log('ERR', err)
})
}, [page, willFilter])
return ( return (
<div className='w-full flex flex-col gap-8'> <div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Loans' paths={['Dashboard', 'Loans']} /> <BreadcrumbCom title='Loans' paths={['Dashboard', 'Loans']}/>
<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'>
{isFetching ? {isError ?
<> <p className='text-red-500'>{allLoans?.error}</p>
<p className='text-slate-800'>Loading...</p> :
</> <>
: isError ? {/* filter section */}
<p className='text-red-500'>{error.message}</p> <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'/>
<TableWrapper data={selectUsers} itemsPerPage={15}> <div className='w-full sm:max-w-48'>
{({ data }) => ( <select name='type' value={filter?.type} className='h-10 w-full p-2 rounded-md'
<> onChange={handleFilter}>
<table className="py-2 w-full text-sm"> <option value=''>All</option>
<thead className="py-2 text-sm text-slate-500 text-left"> <option value='transaction_id'>Transaction ID</option>
<tr> <option value='account_id'>Account ID</option>
<th scope="col" className="px-2 py-2"> </select>
Name </div>
</th> <div className='w-full sm:max-w-48'>
<th scope="col" className="px-2"> <input name='id' value={filter?.id} disabled={!filter.type}
Loan className={`h-10 w-full p-2 rounded-md outline-none border border-black-aside ${!filter.type && 'opacity-30'}`}
</th> onChange={handleFilter}/>
<th scope="col" className="px-2"> </div>
Added <button onClick={handleFilterByParams} disabled={filter.type && !filter.id}
</th> 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
<th scope="col" className="px-2 text-right"> </button>
Action </div>
</th> {/* end of filter section */}
</tr>
</thead> <TablePaginatedWrapper data={loans} isFetching={isFetching} setPage={setPage}
<tbody> itemsPerPage={pagination?.limit} pagination={pagination}>
{(data && data.length > 0) ? data?.map((item, index) => ( {({data}) => (
<tr className="py-2 border-t border-dashed border-slate-300"> <>
<td className="px-2 py-2"> <table className="table-auto py-2 w-full text-sm">
<div className='w-full min-w-48 flex items-center gap-2 whitespace-nowrap'> <thead className="py-2 text-sm text-slate-500 text-left">
<img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese image" /> <tr>
<div className="text-left"> <th scope="col" className="px-2 py-2">
<div className="text-base font-semibold">{item?.name || ''}</div> Name
<div className="font-normal text-gray-500">{item?.bvn}</div> </th>
</div> <th scope="col" className="px-2 text-right">
</div> Loan Amount
</td> </th>
<td className="px-2"> <th scope="col" className="px-2 text-right">
<div className="text-left"> Product/Tenor
<div className="text-base font-semibold">{item?.loan}</div> </th>
<div className="font-normal text-gray-500">{item?.description}</div> <th scope="col" className="px-2 text-right">
</div> Repay/Install Amount
</td> </th>
<td className="px-2"> <th scope="col" className="px-2 text-right">
<div className="text-left"> Added
<div className="font-normal text-gray-500">{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}</div> </th>
</div> <th scope="col" className="px-2 text-right">
</td> Action
<td className="px-2 text-right"> </th>
<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'>
<Icons name='edit' />
</div>
<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' />
</div>
<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='trash' />
</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={4}> <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}
</tr> alt="Jese image"/>
} <div className="text-left">
</tbody> <div
</table> className="text-base font-semibold">{item?.account_id || ''}</div>
</> <div
)} className="font-normal text-gray-500">{item?.id} : {item?.transaction_id}</div>
</TableWrapper> </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-semibold text-green-500">#{formatNumber(item?.initial_loan_amount)}</div>
<div className="font-normal text-red-500">{item?.status}</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-red-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>
+132
View File
@@ -0,0 +1,132 @@
import React, { useState } from 'react'
import { useQuery } from "@tanstack/react-query";
import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
// import TableWrapper from '../tableWrapper/TableWrapper'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper';
import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import { getLoans } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber'
import RouteLinks from '../../RouteLinks';
export default function LoansCom() {
const [page, setPage] = useState(1)
const {data:allLoans, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.loans, page],
queryFn: () => getLoans({page}),
staleTime: 0,
})
const loans = allLoans?.data?.loans // LOANS LIST
const pagination = allLoans?.data?.pagination
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Loans' paths={['Dashboard', 'Loans']} />
<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>
:
<TablePaginatedWrapper data={loans} isFetching={isFetching} setPage={setPage} 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">
<tr>
<th scope="col" className="px-2 py-2">
Name
</th>
<th scope="col" className="px-2 text-right">
Loan Amount
</th>
<th scope="col" className="px-2 text-right">
Product/Tenor
</th>
<th scope="col" className="px-2 text-right">
Repay/Install Amount
</th>
<th scope="col" className="px-2 text-right">
Added
</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={Avatar} alt="Jese image" />
<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 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>
)
}
+151
View File
@@ -0,0 +1,151 @@
import React, { useState } from 'react'
import { useQuery } from "@tanstack/react-query";
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 { getOffers } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber';
export default function OffersCom() {
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.offers, page],
queryFn: () => getOffers({page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const offers = data?.data?.offers // LOAN CHARGES LIST
const pagination = data?.data?.pagination
console.log('offers', offers)
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Offers' paths={['Dashboard', 'Offers']} />
<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>
:
<TablePaginatedWrapper data={offers} 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-1 py-1">
ID
</th>
<th scope="col" className="px-1 py-1">
Name
</th>
<th scope="col" className="px-2 text-right">
Interest Rate
</th>
<th scope="col" className="px-2 text-right">
Insurance Rate
</th>
<th scope="col" className="px-1 text-right">
Mgt. Rate
</th>
<th scope="col" className="px-1 text-right">
Vat. Rate
</th>
<th scope="col" className="px-2 text-right">
Max/Min Amount
</th>
<th scope="col" className="px-2 text-right">
Tenor
</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">
<div className="text-right">
<div className="font-normal text-gray-500">{item?.id || ''}</div>
</div>
</td>
<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 image" />*/}
<div className="text-left">
<div className="text-base font-semibold">{item?.product_id || ''}</div>
{/* <div className="font-normal text-gray-500 line-clamp-1">{item?.description}</div> */}
</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.interest_rate)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.insurance_rate)}</div>
</div>
</td>
<td className="px-1">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.management_rate)}</div>
</div>
</td>
<td className="px-1">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.vat_rate)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{formatNumber(item?.max_amount)}</div>
<div className="font-normal text-gray-500">{formatNumber(item?.min_amount)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="font-normal text-gray-500">{item?.tenor}</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'>*/}
{/* <Icons name='eye' />*/}
{/* </div>*/}
{/* </div>*/}
{/*</td>*/}
</tr>
))
:
<tr className="py-2 border-t border-dashed border-slate-300">
<td className="px-3 py-2" colSpan={7}>
<div className="flex justify-center items-center">
No Record Found
</div>
</td>
</tr>
}
</tbody>
</table>
</>
)}
</TablePaginatedWrapper>
}
</div>
</div>
)
}
+176
View File
@@ -0,0 +1,176 @@
import {useEffect, useState} from 'react'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons'
import {getRepayments} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import Avatar from '../../assets/loans2.png';
export default function RepaymentsCom() {
const [page, setPage] = useState(1)
const [allRepayments, setAllRepayments] = 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 repayments = allRepayments?.data?.repayments // LOAN REPAYMENTS LIST
const pagination = allRepayments?.data?.pagination
const isFetching = allRepayments?.loading
const isError = allRepayments?.error
useEffect(() => {
setAllRepayments(prev => ({...prev, loading: true}))
const payload = filter?.type ? {[filter?.type]: filter.id} : {}
getRepayments({...payload, page}).then(res => {
if (res?.status != 200) {
setAllRepayments(prev => ({...prev, loading: false}))
return
}
setAllRepayments({loading: false, error: '', data: res?.data})
}).catch(err => {
setAllRepayments({loading: false, error: 'error occurred', data: {}})
console.log('ERR', err)
})
}, [page, willFilter])
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Repayments' paths={['Dashboard', 'Repayments']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{isError ?
<p className='text-red-500'>{allRepayments?.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='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}/>
</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={repayments} 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">
CustomerID / ID:TrxID
</th>
<th scope="col" className="px-8 ">
Descriptions
</th>
<th scope="col" className="px-2 text-right">
Date/Result Codes
</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={Avatar}
alt="Jese image"/>
<div className="text-left">
<div
className="text-base font-semibold">{item?.customer_id || ''}</div>
<div
className="font-normal text-blue-500">{item?.loan_id} :<b> {item?.transaction_id}</b>
</div>
<div
className="font-normal text-red-500">{item?.initiated_by}
</div>
<div
className="font-normal text-green-500"><b> {item?.product_id}</b>
</div>
</div>
</div>
</td>
{/* <td className="px-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.loan}</div>
<div className="font-normal text-gray-500">{item?.description}</div>
</div>
</td> */}
<td className="px-8">
<div className="text-left">
<div className="font-normal text-gray-500">Repay Date : {getDateFromDateString(item?.repay_date)}</div>
<div className="font-normal">Repay Desc : {item?.repay_description || ''}</div>
<div className="font-normal text-gray-500">Verify Repay Date : {getDateFromDateString(item?.verify_date)}</div>
<div className="font-normal">Verify Repay Desc : {item?.verify_description || ''}</div>
</div>
</td>
<td className="px-2 text-right">
<div className="text-left">
<div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)}</div>
<div className="font-normal text-red-500">Repay Result :{item?.repay_result || ''}</div>
<div className="font-normal text-blue-500">Verify Repay Result :{item?.verify_result || ''}</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>
)
}
@@ -1,29 +1,32 @@
import React from 'react' import React, { useState } from 'react'
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import {Link} from 'react-router-dom'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom' import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TableWrapper from '../tableWrapper/TableWrapper' import TablePaginatedWrapper from '../tableWrapper/TablePaginatedWrapper'
import Icons from '../Icons' import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg' import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys' import queryKeys from '../../services/queryKeys'
import { selectLoan } from '../../services/siteServices' import { getRepayments } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString'; import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
export default function RequestCom() { export default function RepaymentsCom() {
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({ const {data, isFetching, isError, error} = useQuery({
queryKey: queryKeys.select_loan, queryKey: [...queryKeys.transactions, page],
queryFn: () => selectLoan() queryFn: () => getRepayments({page}),
staleTime: 0,
// placeholderData: keepPreviousData,
}) })
const selectUsers = data?.data?.result_data?.data // APPLY LOAN LIST const repayments = data?.data?.repayments // REPAYMENTS LIST
const pagination = data?.data?.pagination
return ( return (
<div className='w-full flex flex-col gap-8'> <div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Request' paths={['Dashboard', 'Request']} /> <BreadcrumbCom title='Repayments' paths={['Dashboard', 'Repayments']} />
<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'>
{isFetching ? {isFetching ?
@@ -33,7 +36,7 @@ export default function RequestCom() {
: isError ? : isError ?
<p className='text-red-500'>{error.message}</p> <p className='text-red-500'>{error.message}</p>
: :
<TableWrapper data={selectUsers} itemsPerPage={15}> <TablePaginatedWrapper data={repayments} isFetching={isFetching} setPage={setPage} itemsPerPage={pagination?.limit} pagination={pagination}>
{({ data }) => ( {({ data }) => (
<> <>
<table className="py-2 w-full text-sm"> <table className="py-2 w-full text-sm">
@@ -42,9 +45,9 @@ export default function RequestCom() {
<th scope="col" className="px-2 py-2"> <th scope="col" className="px-2 py-2">
Name Name
</th> </th>
<th scope="col" className="px-2"> {/* <th scope="col" className="px-2">
Loan Loan
</th> </th> */}
<th scope="col" className="px-2"> <th scope="col" className="px-2">
Added Added
</th> </th>
@@ -55,45 +58,39 @@ export default function RequestCom() {
</thead> </thead>
<tbody> <tbody>
{(data && data.length > 0) ? data?.map((item, index) => ( {(data && data.length > 0) ? data?.map((item, index) => (
<tr 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 image" /> <img className="w-10 h-10 rounded-md" src={Avatar} alt="Jese image" />
<div className="text-left"> <div className="text-left">
<div className="text-base font-semibold">{item?.name || ''}</div> <div className="text-base font-semibold">{item?.customer_id || ''}</div>
<div className="font-normal text-gray-500">{item?.bvn}</div> <div className="font-normal text-gray-500">{item?.loan_id} : {item?.transaction_id}</div>
</div> </div>
</div> </div>
</td> </td>
<td className="px-2"> {/* <td className="px-2">
<div className="text-left"> <div className="text-left">
<div className="text-base font-semibold">{item?.loan}</div> <div className="text-base font-semibold">{item?.loan}</div>
<div className="font-normal text-gray-500">{item?.description}</div> <div className="font-normal text-gray-500">{item?.description}</div>
</div> </div>
</td> </td> */}
<td className="px-2"> <td className="px-2">
<div className="text-left"> <div className="text-left">
<div className="font-normal text-gray-500">{getDateFromDateString(item?.added)} {getTimeFromDateString(item?.added)}</div> <div className="font-normal text-gray-500">{getDateFromDateString(item?.created_at)}</div>
</div> </div>
</td> </td>
<td className="px-2 text-right"> <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='edit' /> <Icons name='eye' />
</div> </div>
<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' />
</div>
<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='trash' />
</div>
</div> </div>
</td> </td>
</tr> </tr>
)) ))
: :
<tr className="py-2 border-t border-dashed border-slate-300"> <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"> <div className="flex justify-center items-center">
No Record Found No Record Found
</div> </div>
@@ -104,7 +101,7 @@ export default function RequestCom() {
</table> </table>
</> </>
)} )}
</TableWrapper> </TablePaginatedWrapper>
} }
</div> </div>
</div> </div>
@@ -0,0 +1,64 @@
import { useState } from "react";
import MainBtn from "../MainBtn";
import Icons from "../Icons";
export default function TablePaginatedWrapper({
data = [],
isFetching,
pagination,
setPage,
children,
}) {
const handlePrev = () => {
setPage(prev => prev - 1)
};
const handleNext = () => {
setPage(prev => prev + 1)
};
return (
<div className="relative w-full">
<div className="flex flex-col">
<div className="w-full overflow-x-auto">
{children({ data })}
</div>
<div className='w-full flex flex-col lg:flex-row justify-center items-center gap-3 md:gap-6'>
<div className="text-sm text-center lg:text-left font-normal text-gray-500 dark:text-gray-400 block w-full">Showing <span className="font-semibold text-gray-900 dark:text-white">
{isFetching ? '----' : `page ${pagination?.current_page}`}</span> of <span className="font-semibold text-gray-900 dark:text-white">{pagination?.total_pages}</span>
</div>
<div className='flex items-center gap-3 md:gap-6'>
<MainBtn
onClick={handlePrev}
// text='Prev'
className={`${!pagination?.has_prev ? 'bg-primary/50 pointer-events-none' : 'bg-primary'} text-white-light text-center flex justify-center gap-2 items-center`}
disabled={isFetching || !pagination?.has_prev}
>
<Icons name='prev' />
</MainBtn>
<MainBtn
onClick={handleNext}
// text='Next'
className={`${!pagination?.has_next ? 'bg-primary/50 pointer-events-none' : 'bg-primary'} text-white-light text-center flex justify-center gap-2 items-center`}
disabled={isFetching || !pagination?.has_next}
>
<Icons name='next' />
</MainBtn>
</div>
</div>
</div>
{isFetching && <TableIsLoading />}
</div>
);
}
export const TableIsLoading = () => {
return (
<div className="w-full fixed z-[991] inset-0 flex justify-center items-center bg-black/10">
<p className="rounded-md shadow-md p-4 bg-white/90 dark:bg-gray-900 text-brown dark:text-white">Loading...</p>
</div>
)
}
+4 -4
View File
@@ -1,4 +1,4 @@
import { ReactNode, useEffect, useState } from "react"; import { useEffect, useState } from "react";
import MainBtn from "../MainBtn"; import MainBtn from "../MainBtn";
import Icons from "../Icons"; import Icons from "../Icons";
@@ -19,7 +19,7 @@ export default function TableWrapper({
const numberOfSelection = itemsPerPage; const numberOfSelection = itemsPerPage;
const handlePrev = () => { const handlePrev = () => {
if (currentPage != 0) { if (currentPage !== 0) {
setCurrentPage((prev) => prev - numberOfSelection); setCurrentPage((prev) => prev - numberOfSelection);
} }
}; };
@@ -46,7 +46,7 @@ export default function TableWrapper({
); );
setIsLoading(false) setIsLoading(false)
},1000) },1000)
}, [currentPage, filteredData]); }, [currentPage, filteredData, numberOfSelection]);
useEffect(()=>{ useEffect(()=>{
setCurrentPage(0) setCurrentPage(0)
@@ -92,7 +92,7 @@ export default function TableWrapper({
<MainBtn <MainBtn
onClick={handlePrev} onClick={handlePrev}
// text='Prev' // text='Prev'
className={`${currentPage == 0 ? 'bg-primary/50 pointer-events-none' : 'bg-primary'} text-white-light text-center flex justify-center gap-2 items-center`} className={`${currentPage === 0 ? 'bg-primary/50 pointer-events-none' : 'bg-primary'} text-white-light text-center flex justify-center gap-2 items-center`}
disabled={isLoading} disabled={isLoading}
> >
<Icons name='prev' /> <Icons name='prev' />
@@ -0,0 +1,103 @@
import React, { useState } from 'react'
import { useQuery } from "@tanstack/react-query";
import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import { getLoanCharges } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber';
export default function LoanChargeDetails({transactionID}) {
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.loan_charges, page, transactionID],
queryFn: () => getLoanCharges({transaction_id: transactionID, page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const loanCharges = data?.data?.loan_charges // LOAN CHARGES LIST
// const pagination = data?.data?.pagination
return (
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body' style={{backgroundColor: 'aliceblue'}}>
<p className='pb-4 font-bold text-base'>Loan Charges</p>
{isFetching ?
<>
<p className='text-slate-800'>Loading...</p>
</>
: isError ?
<p className='text-red-500'>{error.message}</p>
:
<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">
Name
</th>
{/* <th scope="col" className="px-2">
Loan
</th> */}
<th scope="col" className="px-2 text-right">
Amount
</th>
<th scope="col" className="px-2 text-right">
Added
</th>
{/* <th scope="col" className="px-2 text-right">
Action
</th> */}
</tr>
</thead>
<tbody>
{(loanCharges && loanCharges.length > 0) ? loanCharges?.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 image" />*/}
<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>
</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?.amount)}</div>
</div>
</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>
</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'>
<Icons name='eye' />
</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>
}
</div>
)
}
@@ -0,0 +1,251 @@
import React, { useState } from 'react'
import {useQuery} from "@tanstack/react-query";
import Icons from '../Icons'
import Avatar from '../../assets/loans.png'
import queryKeys from '../../services/queryKeys'
import {getLoans} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber'
import getTimeFromDateString from "../../helpers/GetTimeFromDateString";
import {initiateDisburseRetrials, initiateDisburseVerify} from "../../services/siteEventService"
import ModalWrapper from '../modals/ModalWrapper';
import MainBtn from '../MainBtn';
export default function LoanDetails({transactionID}) {
const [retryDisbursementModal, setRetryDisbursementModal] = useState({})
const [retryVerifyModal, setRetryVerifyModal] = useState({})
const handleSetRetryDisbursementModal = (transactioID) => {
setRetryDisbursementModal({status:true, transactioID})
}
const closeRetryDisbursementModal = () => {setRetryDisbursementModal({})}
const handleSetRetryVerifyModal = (transactioID) => {
setRetryVerifyModal({status:true, transactioID})
}
const closeRetryVerifyModal = () => {setRetryVerifyModal({})}
const {data: allLoans, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.loans, transactionID],
queryFn: () => getLoans({transaction_id: transactionID})
})
const loans = allLoans?.data?.loans // LOANS LIST
// const loansCount = allLoans?.data?.count // LOANS LIST COUNT
const handleClick = (transactioID) => {
// alert(transactioID)
const fields = {
"transactionId": transactioID
}
closeRetryDisbursementModal() // CLOSES THE DISBURSEMENT MODAL
return initiateDisburseRetrials(fields)
// console.log('Button clicked!');
};
const handleRetryClick = (transactioID) => {
alert(transactioID)
const fields = {
"transactionId": transactioID
}
closeRetryVerifyModal() // CLOSES THE VERIFY MODAL
return initiateDisburseVerify(fields)
// console.log('Button clicked!');
};
return (
<>
{isFetching ?
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<p className='pb-4 font-bold text-base'>Loans</p>
<p className='text-slate-800'>Loading...</p>
</div>
: isError ?
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<p className='pb-4 font-bold text-base'>Loans</p>
<p className='text-red-500'>{error.message}</p>
</div>
: (loans && loans.length > 0) ?
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'
style={{backgroundColor: '#f7d9e3'}}>
<p className='pb-4 font-bold text-base'>Loan</p>
<table className="table-auto 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">
Name
</th>
<th scope="col" className="px-2 text-right">
Loan/Eligible Amount
</th>
<th scope="col" className="px-2 text-right">
Product/Tenor
</th>
<th scope="col" className="px-2 text-right">
Repay/Install Amount.
</th>
<th scope="col" className="px-2 text-right">
Added/Due
</th>
<th scope="col" className="px-2 text-right">
Status
</th>
</tr>
</thead>
<tbody>
{loans?.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 image"/>
<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="font-semibold text-red-500">ORIGIN
: {item?.original_transaction}</div>
<div className="font-bold text-blue-500">OFFER
: {item?.offer_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-semibold text-green-500">#{formatNumber(item?.initial_loan_amount)}</div>
<div
className="font-semibold text-red-500">#{formatNumber(item?.eligible_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-semibold text-gray-500">#{formatNumber(item?.repayment_amount)}</div>
<div
className="font-semibold text-red-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-semibold text-red-500">{getDateFromDateString(item?.due_date)}</div>
</div>
</td>
<td className="px-2 text-right">
<div className="font-semibold text-red-500">{item?.status}</div>
</td>
</tr>
<tr>
<td colSpan="8">
<div>
<div style={{display: 'flex'}}>
<div style={{width: '50%'}}>
<p className='pb-4 font-bold text-base'>Loans Disbursement
Details</p>
</div>
<div style={{width: '50%', textAlign: 'right'}}>
<button
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 roundede"
// onClick={() => handleClick(item?.transaction_id)}>
onClick={() => handleSetRetryDisbursementModal(item?.transaction_id)}>
Retry Disbursement
</button>
</div>
</div>
<div className="font-bold text-blue-500">Disburse Date
: {getDateFromDateString(item?.disburseDate)} {getTimeFromDateString(item?.disburseDate)} </div>
<div className="font-bold text-gray-500">Disburse Description
: {item?.disburseDescription}</div>
<div className="font-bold text-red-500">Disburse Result
: {item?.disburseResult}</div>
<div><br/></div>
<div style={{display: 'flex'}}>
<div style={{width: '70%'}}>
<div className="font-bold text-blue-500">Disburse Verify
Date: {getDateFromDateString(item?.disburseVerify)} {getTimeFromDateString(item?.disburseVerify)} </div>
<div className="font-bold text-gray-500">Verify Description
: {item?.verifyDescription}</div>
<div className="font-bold text-red-500">Verify Result
: {item?.verifyResult}</div>
</div>
<div style={{width: '30%', textAlign: 'right'}}>
<button
className="bg-blue-500 hover:bg-red-700 text-white font-bold py-2 px-4 roundede"
onClick={() => handleSetRetryVerifyModal(item?.transaction_id)}>
Retry Verification
</button>
</div>
</div>
{/*<div className="font-bold text-blue-500">Disburse Verify*/}
{/* Date: {getDateFromDateString(item?.disburseVerify)} {getTimeFromDateString(item?.disburseVerify)} </div>*/}
{/*<div className="font-bold text-gray-500">Verify Description*/}
{/* : {item?.verifyDescription}</div>*/}
{/*<div className="font-bold text-red-500">Verify Result*/}
{/* : {item?.verifyResult}</div>*/}
</div>
</td>
</tr>
</>
))
}
</tbody>
</table>
</div>
:
null
}
{retryDisbursementModal.status &&
<ModalWrapper maxWidth='max-w-lg'>
<div className="p-4 md:p-5 text-center bg-white rounded-md">
<svg className="mx-auto mb-4 text-gray-400 w-12 h-12 dark:text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
</svg>
<h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{'Confirm Retry Disbursement?'}</h3>
<div className="flex justify-center items-center gap-6 sm:gap-20">
<MainBtn onClick={closeRetryDisbursementModal} text='Cancel' className="border text-black dark:text-white" />
<MainBtn onClick={()=>handleClick(retryDisbursementModal.transactioID)} text='Yes' className="text-white bg-primary hover:bg-primary/90 focus:ring-0 focus:outline-none ring-0 font-medium rounded-lg text-sm px-5 py-2.5 text-center" />
</div>
</div>
</ModalWrapper>
}
{retryVerifyModal.status &&
<ModalWrapper maxWidth='max-w-lg'>
<div className="p-4 md:p-5 text-center bg-white rounded-md">
<svg className="mx-auto mb-4 text-gray-400 w-12 h-12 dark:text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
</svg>
<h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{'Continue Verify Disburesement?'}</h3>
<div className="flex justify-center items-center gap-6 sm:gap-20">
<MainBtn onClick={closeRetryVerifyModal} text='Cancel' className="border text-black dark:text-white" />
<MainBtn onClick={()=>handleRetryClick(retryVerifyModal.transactioID)} text='Yes' className="text-white bg-primary hover:bg-primary/90 focus:ring-0 focus:outline-none ring-0 font-medium rounded-lg text-sm px-5 py-2.5 text-center" />
</div>
</div>
</ModalWrapper>
}
</>
)
}
@@ -0,0 +1,168 @@
import React, {useEffect, useState} from 'react'
import {useQuery} from "@tanstack/react-query";
import Icons from '../Icons'
import Avatar from '../../assets/user_avatar.jpg'
import queryKeys from '../../services/queryKeys'
import {getRepaymentSchedule} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import formatNumber from '../../helpers/formatNumber';
import localSiteIcons from "../../helpers/localSiteIcons";
import {initiateLoanPayment } from "../../services/siteEventService"
import ModalWrapper from '../modals/ModalWrapper';
import MainBtn from '../MainBtn';
export default function RepaymentScheduleDetails({transactionID}) {
const [retryPaymentModal, setRetryPaymentModal] = useState({})
const handleSetRetryPaymentModal = (transactioID) => {
setRetryPaymentModal({status:true, transactioID})
}
const closeRetryPaymentModal = () => {setRetryPaymentModal({})}
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.repayment_schedule, page, transactionID],
queryFn: () => getRepaymentSchedule({transaction_id: transactionID, page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const repaymentSchedule = data?.data?.repayment_schedules // LOAN CHARGES LIST
// const pagination = data?.data?.pagination
const handleClick = (transactioID) => {
alert(transactioID)
const fields = {
"transactionId": transactioID
}
closeRetryPaymentModal() // CLOSES PAYMENT INITIATE MODAL
return initiateLoanPayment(fields)
// console.log('Button clicked!');
};
useEffect(() => {
}, [])
return (
<>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<p className='pb-4 font-bold text-base'>Repayment Schedule</p>
{isFetching ?
<>
<p className='text-slate-800'>Loading...</p>
</>
: isError ?
<p className='text-red-500'>{error.message}</p>
:
<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">
ID/TrxID
</th>
{/* <th scope="col" className="px-2">
Loan
</th> */}
<th scope="col" className="px-2 text-right">
Repay Amount
</th>
<th scope="col" className="px-2 text-right">
Install Amount
</th>
<th scope="col" className="px-2 text-right">
Due Date
</th>
<th scope="col" className="px-2 text-right">
Paid Date
</th>
<th scope="col" className="px-2 text-right">
Paid ?
</th>
<th scope="col" className="px-2 text-right">
</th>
</tr>
</thead>
<tbody>
{(repaymentSchedule && repaymentSchedule.length > 0) ? repaymentSchedule?.map((item, index) => (
<tr key={index} className="py-2 border-t border-dashed border-slate-300">
<td className="px-2 py-2">
<div className="text-left">
<div className="text-base font-semibold">{item?.loan_id || ''}</div>
<div className="text-base font-semibold">{item?.transaction_id || ''}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div
className="font-normal text-gray-500">{formatNumber(item?.total_repayment_amount)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<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?.due_date)}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div
className="font-normal text-gray-500">{item?.paid_at ? getDateFromDateString(item?.paid_at) : 'Not available'}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<div className="text-base font-semibold">{item?.paid || 'false'}</div>
</div>
</td>
<td className="px-2">
<div className="text-right">
<button
className="bg-blue-500 hover:bg-red-700 text-white font-bold py-2 px-4 roundede"
onClick={() => handleSetRetryPaymentModal(item?.transaction_id)}>
Process Payment
</button>
</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>
}
</div>
{retryPaymentModal.status &&
<ModalWrapper maxWidth='max-w-lg'>
<div className="p-4 md:p-5 text-center bg-white rounded-md">
<svg className="mx-auto mb-4 text-gray-400 w-12 h-12 dark:text-gray-200" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 11V6m0 8h.01M19 10a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"/>
</svg>
<h3 className="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{'Continue Initiate Payment?'}</h3>
<div className="flex justify-center items-center gap-6 sm:gap-20">
<MainBtn onClick={closeRetryPaymentModal} text='Cancel' className="border text-black dark:text-white" />
<MainBtn onClick={()=>handleClick(retryDisbursementModal.transactioID)} text='Yes' className="text-white bg-primary hover:bg-primary/90 focus:ring-0 focus:outline-none ring-0 font-medium rounded-lg text-sm px-5 py-2.5 text-center" />
</div>
</div>
</ModalWrapper>
}
</>
)
}
@@ -0,0 +1,96 @@
import React, { useState } from 'react'
import { useQuery } from "@tanstack/react-query";
import Icons from '../Icons'
import queryKeys from '../../services/queryKeys'
import { getTransactions } from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
import localSiteIcons from '../../helpers/localSiteIcons';
export default function TransactionDetails({transactionID}) {
const [page, setPage] = useState(1)
const {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.transactions, page, transactionID],
queryFn: () => getTransactions({transaction_id: transactionID, page}),
staleTime: 0,
// placeholderData: keepPreviousData,
})
const transactions = data?.data?.transactions // TRANSACTIONS LIST
// const pagination = data?.data?.pagination
return (
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
<p className='pb-4 font-bold text-base'>Transactions</p>
{isFetching ?
<>
<p className='text-slate-800'>Loading...</p>
</>
: isError ?
<p className='text-red-500'>{error.message}</p>
:
<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">
Customer
</th>
<th scope="col" className="px-2 text-right">
Channel
</th>
</tr>
</thead>
<tbody>
{(transactions && transactions.length > 0) ? transactions?.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={localSiteIcons(`loan_icons/${item?.type}`)} 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="text-base font-semibold">{item?.customer_id}</div>
</div>
</td>
<td className="px-2 text-right">
<div className="text-base font-semibold">{item?.channel}</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>
}
</div>
)
}
@@ -0,0 +1,18 @@
import React from 'react'
import BreadcrumbCom from '../breadcrumb/BreadcrumbCom'
import TransactionDetails from './TransactionDetails'
import LoanDetails from './LoanDetails'
import LoanChargeDetails from './LoanChargeDetails'
import RepaymentScheduleDetails from './RepaymentScheduleDetails'
export default function TransactionDetailsCom({id}) {
return (
<div className='w-full flex flex-col gap-8'>
<BreadcrumbCom title='Transaction Details' span={`[${id}]`} paths={['Dashboard', 'Transactions Details']} />
<TransactionDetails transactionID={id} />
<LoanDetails transactionID={id} />
<RepaymentScheduleDetails transactionID={id} />
<LoanChargeDetails transactionID={id} />
</div>
)
}
@@ -0,0 +1,168 @@
import {useEffect, useState} from 'react'
import { useQuery } 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 {getTransactions} from '../../services/siteServices'
import getDateFromDateString from '../../helpers/GetDateFromDateString';
import getTimeFromDateString from '../../helpers/GetTimeFromDateString';
import localImgLoader from '../../helpers/localImageLoader';
import RouteLinks from '../../RouteLinks';
import localSiteIcons from '../../helpers/localSiteIcons';
import queryKeys from '../../services/queryKeys'
export default function TransactionsCom() {
const [page, setPage] = useState(1)
const [filter, setFilter] = useState({type: '', id: ''})
const [willFilter, setWillFilter] = useState(false)
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 {data, isFetching, isError, error} = useQuery({
queryKey: [...queryKeys.transactions, page, willFilter],
queryFn: () => {
const filterData = filter?.type ? {[filter?.type]: filter.id} : {}
const reqData = {
page,
...filterData
}
return getTransactions(reqData)
},
staleTime: 0 //0 mins
})
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', 'Transactions']}/>
<div className='box bg-white dark:bg-black-box text-black-body dark:text-white-body'>
{isError ?
<p className='text-red-500'>{error?.message}</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='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}/>
</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={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">
Customer/ID
</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={localSiteIcons(`loan_icons/${item?.type}`)}
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="text-base font-semibold">{item?.customer_id}</div>
<div className="font-normal text-red-500"><b>ID:</b>{item?.id}</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>
)
}
@@ -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 { getTransactions } 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 TransactionsCom() {
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.transactions] })
}
const {data, isFetching, isError, error, isPlaceholderData, isPending} = useQuery({
queryKey: [...queryKeys.transactions, page],
queryFn: () => getTransactions({...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', 'Transactions']} />
<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>
)
}
+61 -61
View File
@@ -1,4 +1,4 @@
import { createContext, useContext, useEffect, useState } from 'react' import {createContext, useContext, useEffect, useState} from 'react'
const GeneralContextProvider = createContext({}) const GeneralContextProvider = createContext({})
@@ -10,7 +10,7 @@ export default function GeneralLayoutContext({children}) {
const [booking, setBooking] = useState('') const [booking, setBooking] = useState('')
const [alertBox, setAlertBox] = useState({status:false, msg:''}) // USE TO SHOW SUcCESS OR FAILED ALERT MESSAGE const [alertBox, setAlertBox] = useState({status: false, msg: ''}) // USE TO SHOW SUcCESS OR FAILED ALERT MESSAGE
const [logoutModal, setLogoutModal] = useState(false) // USE TO SHOW LOGOUT MODAL BOX const [logoutModal, setLogoutModal] = useState(false) // USE TO SHOW LOGOUT MODAL BOX
@@ -21,93 +21,93 @@ export default function GeneralLayoutContext({children}) {
const [showAsideDrawer, setShowAsideDrawer] = useState('') const [showAsideDrawer, setShowAsideDrawer] = useState('')
const handleActiveMenu = (name) => { const handleActiveMenu = (name) => {
if(activeMenu == name){ if (activeMenu == name) {
setActiveMenu('') setActiveMenu('')
}else{ } else {
setActiveMenu(name) setActiveMenu(name)
} }
} }
const handleDrawer = (drawerToOpen) => { // FUNCTION TO DETERMINE WHICH ASIDE DRAWER TO SHOW const handleDrawer = (drawerToOpen) => { // FUNCTION TO DETERMINE WHICH ASIDE DRAWER TO SHOW
setDrawer((prev)=>{ setDrawer((prev) => {
if(!prev){ if (!prev) {
return drawerToOpen return drawerToOpen
}else if(drawerToOpen == prev){ } else if (drawerToOpen == prev) {
return '' return ''
}else{ } else {
return drawerToOpen return drawerToOpen
} }
}) })
} }
const handleBooking = (bookingToOpen) => { // FUNCTION TO DETERMINE WHICH ASIDE DRAWER TO SHOW const handleBooking = (bookingToOpen) => { // FUNCTION TO DETERMINE WHICH ASIDE DRAWER TO SHOW
setBooking((prev)=>{ setBooking((prev) => {
if(!prev){ if (!prev) {
return bookingToOpen return bookingToOpen
}else if(bookingToOpen == prev){ } else if (bookingToOpen == prev) {
return '' return ''
}else{ } else {
return bookingToOpen return bookingToOpen
} }
}) })
} }
const handleAlertBox = (valObj) => { const handleAlertBox = (valObj) => {
setAlertBox(valObj) setAlertBox(valObj)
} }
const handleTheme = () => { const handleTheme = () => {
setTheme(theme === "dark" ? "light" : "dark"); setTheme(theme === "dark" ? "light" : "dark");
} }
useEffect(() => { useEffect(() => {
if (window.matchMedia("(prefers-color-scheme: dark)").matches) { if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
setTheme("dark"); setTheme("dark");
} else { } else {
setTheme("light"); setTheme("light");
} }
}, []); }, []);
useEffect(() => {
if (theme === "dark") {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
}, [theme]);
useEffect(()=>{ useEffect(() => {
window.addEventListener('resize', ()=>{ if (theme === "dark") {
setShrinkAside(false) document.documentElement.classList.add("dark");
setShowAsideDrawer('') } else {
setActiveMenu('') document.documentElement.classList.remove("dark");
}) }
return () => window.removeEventListener('resize', window.addEventListener('resize', ()=>{ }, [theme]);
setShrinkAside(false)
setShowAsideDrawer('') useEffect(() => {
setActiveMenu('') window.addEventListener('resize', () => {
})) setShrinkAside(false)
},[]) setShowAsideDrawer('')
setActiveMenu('')
})
return () => window.removeEventListener('resize', window.addEventListener('resize', () => {
setShrinkAside(false)
setShowAsideDrawer('')
setActiveMenu('')
}))
}, [])
let value = { let value = {
theme, handleTheme, theme, handleTheme,
activeMenu, handleActiveMenu, activeMenu, handleActiveMenu,
drawer, handleDrawer, drawer, handleDrawer,
booking, handleBooking, booking, handleBooking,
alertBox, handleAlertBox, alertBox, handleAlertBox,
logoutModal, setLogoutModal, logoutModal, setLogoutModal,
shrinkAside, setShrinkAside, shrinkAside, setShrinkAside,
showAsideDrawer, setShowAsideDrawer showAsideDrawer, setShowAsideDrawer
} }
return ( return (
<GeneralContextProvider.Provider value={value}> <GeneralContextProvider.Provider value={value}>
{children} {children}
</GeneralContextProvider.Provider> </GeneralContextProvider.Provider>
) )
} }
export const generalLayoutContext = () => { export const generalLayoutContext = () => {
return useContext(GeneralContextProvider) return useContext(GeneralContextProvider)
} }
+3 -1
View File
@@ -1,6 +1,8 @@
function getDateFromDateString(dateString) { function getDateFromDateString(dateString) {
const date = new Date(dateString); const date = new Date(dateString);
if (dateString == null || dateString.trim() === '' ) return '';
// Ensure the date is valid // Ensure the date is valid
if (isNaN(date)) { if (isNaN(date)) {
return "Invalid date string"; return "Invalid date string";
+3 -1
View File
@@ -1,6 +1,8 @@
function getTimeFromDateString(dateString) { function getTimeFromDateString(dateString) {
const date = new Date(dateString); const date = new Date(dateString);
if (dateString == null || dateString.trim() === '' ) return '';
// Ensure the date is valid // Ensure the date is valid
if (isNaN(date)) { if (isNaN(date)) {
return "Invalid date string"; return "Invalid date string";
+15
View File
@@ -0,0 +1,15 @@
function debounceFunction(func, delay) {
let timer;
return function(...args) {
// Clear the previous timer if the function is called before the delay
clearTimeout(timer);
// Set a new timer to execute the function after the specified delay
timer = setTimeout(() => {
func(...args);
}, delay);
};
}
export default debounceFunction
+5 -1
View File
@@ -1,6 +1,10 @@
const formatNumber = (number = 0) => { const formatNumber = (number = 0) => {
// return new Intl.NumberFormat().format(number); // return new Intl.NumberFormat().format(number);
return number.toFixed(2); // return number.toFixed(2);
return number.toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
});
}; };
export default formatNumber export default formatNumber
+2
View File
@@ -0,0 +1,2 @@
const localImgLoader = (location) => require(`../assets/${location}`);
export default localImgLoader
+7
View File
@@ -0,0 +1,7 @@
const localSiteIcons = (location) => {
let localParts;
localParts = location.split(".")
return require(`../assets/${localParts[0]}.png`);
}
export default localSiteIcons
+1 -1
View File
@@ -29,7 +29,7 @@ code {
@apply [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500 [&::-webkit-scrollbar-track]:rounded-full [&::-webkit-scrollbar-thumb]:rounded-full @apply [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500 [&::-webkit-scrollbar-track]:rounded-full [&::-webkit-scrollbar-thumb]:rounded-full
} }
.box { .box {
@apply flex flex-col w-full p-8 cursor-pointer rounded-lg h-full border-[1px] border-[#F1F1F4] dark:border-[#1E2027] shadow-[0px_3px_4px_0px_rgba(0,_0,_0,_0.03)] @apply flex flex-col w-full p-8 rounded-lg h-full border-[1px] border-[#F1F1F4] dark:border-[#1E2027] shadow-[0px_3px_4px_0px_rgba(0,_0,_0,_0.03)]
} }
} }
-8
View File
@@ -1,8 +0,0 @@
import React from 'react'
import ApplicationsLoanCom from '../components/applicationsloancom/ApplicationsLoanCom'
export default function ApplicationsLoanPage() {
return (
<ApplicationsLoanCom />
)
}
-8
View File
@@ -1,8 +0,0 @@
import React from 'react'
import ApprovedLoanCom from '../components/approvedloancom/ApprovedLoanCom'
export default function ApprovedLoansPage() {
return (
<ApprovedLoanCom />
)
}
-8
View File
@@ -1,8 +0,0 @@
import React from 'react'
import DisbursementsLoanCom from '../components/disbursementsloancom/DisbursementsLoanCom'
export default function DisbursementsLoanPage() {
return (
<DisbursementsLoanCom />
)
}
+9
View File
@@ -0,0 +1,9 @@
import React from 'react'
import EligibilityCom from '../components/eligibility/EligibilityCom';
export default function EligibilityPage() {
return (
<EligibilityCom />
)
}
+8
View File
@@ -0,0 +1,8 @@
import React from 'react'
import ErrorCom from '../components/error/ErrorCom'
export default function ErrorPage() {
return (
<ErrorCom />
)
}
+8
View File
@@ -0,0 +1,8 @@
import React from 'react'
import LoanChargesCom from '../components/loan_charges/LoanChargesCom'
export default function LoanChargesPage() {
return (
<LoanChargesCom />
)
}
-8
View File
@@ -1,8 +0,0 @@
import React from 'react'
import LoanOffersCom from '../components/loanofferscom/LoanOffersCom'
export default function LoanOffersPage() {
return (
<LoanOffersCom />
)
}
+8
View File
@@ -0,0 +1,8 @@
import React from 'react'
import OffersCom from '../components/offers/OffersCom'
export default function OffersPage() {
return (
<OffersCom />
)
}
+8
View File
@@ -0,0 +1,8 @@
import React from 'react'
import RepaymentsCom from '../components/repayments/RepaymentsCom'
export default function RepaymentsPage() {
return (
<RepaymentsCom />
)
}
-8
View File
@@ -1,8 +0,0 @@
import React from 'react'
import RequestCom from '../components/request/RequestCom'
export default function RequestPage() {
return (
<RequestCom/>
)
}
-8
View File
@@ -1,8 +0,0 @@
import React from 'react'
import SelectedLoanCom from '../components/selectedloancom/SelectedLoanCom'
export default function SelectedLoanPage() {
return (
<SelectedLoanCom />
)
}
+18
View File
@@ -0,0 +1,18 @@
import React, { useEffect } from 'react'
import {useLocation, useNavigate} from 'react-router-dom'
import TransactionDetailsCom from '../components/transactionDetails/TransactionDetailsCom'
export default function TransactionDetailsPage() {
const {state} = useLocation()
const navigate = useNavigate()
useEffect(()=>{
if(!state?.transactionID){
navigate('/', {replace: true})
}
},[])
return (
<TransactionDetailsCom id={state?.transactionID} />
)
}
+8
View File
@@ -0,0 +1,8 @@
import React from 'react'
import TransactionsCom from '../components/transactions/TransactionsCom'
export default function TransactionsPage() {
return (
<TransactionsCom />
)
}
-13
View File
@@ -1,13 +0,0 @@
import React from 'react'
import BreadcrumbCom from '../components/breadcrumb/BreadcrumbCom'
export default function UsersPage() {
return (
<div className='w-full'>
<BreadcrumbCom title='Users' paths={['Dashboard', 'Users']} />
<p className=''>
coming soon ...
</p>
</div>
)
}
+8
View File
@@ -1,9 +1,17 @@
const queryKeys = { const queryKeys = {
dashboard: ['dashboard'], dashboard: ['dashboard'],
loans: ['loans'],
repayment_schedule: ['repayment-schedule'],
loan_charges: ['loan-charges'],
offers: ['offers'],
apply_loan: ['apply'], apply_loan: ['apply'],
select_loan: ['select-loan'], select_loan: ['select-loan'],
approved_loan: ['approved-loan'], approved_loan: ['approved-loan'],
loan_offers: ['loan-offers'], loan_offers: ['loan-offers'],
//new
transactions: ['transactions'],
recent_loans: ['recent_loans'],
} }
export default queryKeys export default queryKeys
+60
View File
@@ -0,0 +1,60 @@
import axios from "axios"
// import dotenv from 'dotenv';
//dotenv.config();
axios.interceptors.request.use(
config => {
config.headers = {
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
};
return config;
},
error => {
return Promise.reject(error);
}
);
const postAuxEnd = (path, postData, media = false) => {
const basePath = media ? process.env.REACT_APP_EVENT_API : process.env.REACT_APP_EVENT_API
return axios.post(`${basePath}${path}`, postData).then(res => {
return res
}).catch(err => {
// throw new Error(err.response.data.message);
throw new Error(err);
})
}
const getAuxEnd = (path, reqData = null) => {
const basePath = media ? process.env.REACT_APP_EVENT_API : process.env.REACT_APP_EVENT_API
return axios.get(`${basePath}${path}`, {params: reqData}).then(res => {
return res
// localStorage.clear();
// window.location.href = `/login?sessionExpired=true`;
}).catch(err => {
throw new Error(err);
// throw new Error(err.response.data.message);
// return err
})
}
// FUNCTION TO GET SALARY RECEIVED
export const initiateDisburseRetrials = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/autocall/retry-disbursement', postData, false)
}
export const initiateDisburseVerify = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/autocall/verify-disbursement', postData, false)
}
export const initiateLoanPayment = (reqData) => {
let postData = {
...reqData
}
return postAuxEnd('/autocall/start-repayment', postData, false)
}
+31 -13
View File
@@ -8,7 +8,7 @@ axios.interceptors.request.use(
"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Origin": "*",
// "Access-Control-Expose-Headers": "Access-Control-Allow-Origin", // "Access-Control-Expose-Headers": "Access-Control-Allow-Origin",
// "Access-Control-Allow-Headers": "Origin, X-API-KEY, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Allow-Headers, Authorization, observe, enctype, Content-Length, X-Csrf-Token", // "Access-Control-Allow-Headers": "Origin, X-API-KEY, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Allow-Headers, Authorization, observe, enctype, Content-Length, X-Csrf-Token",
"Content-Type": "application/json;charset=UTF-8", // "Content-Type": "application/json;charset=UTF-8",
'Authorization': (localStorage && localStorage.getItem('token')) ? `Bearer ${localStorage.getItem('token')}` : '' 'Authorization': (localStorage && localStorage.getItem('token')) ? `Bearer ${localStorage.getItem('token')}` : ''
}; };
// config.headers['Authorization'] = `Bearer ${localStorage.getItem('token')}`; // config.headers['Authorization'] = `Bearer ${localStorage.getItem('token')}`;
@@ -56,26 +56,44 @@ export const getDashData = (reqData) => {
return getAuxEnd(`/dashboard`, postData) return getAuxEnd(`/dashboard`, postData)
} }
// FUNCTION TO GET APPLIED LOANS TABLE // FUNCTION TO GET LOANS TABLE
export const applyLoan = (reqData) => { export const getLoans = (reqData) => {
const postData = { ...reqData } const postData = { ...reqData }
return getAuxEnd(`/office/loan/apply`, postData) return getAuxEnd(`/loans`, postData)
} }
// FUNCTION TO GET APPLIED LOANS TABLE // FUNCTION TO GET TRANSACTIONS TABLE
export const loanOffers = (reqData) => { export const getTransactions = (reqData) => {
const postData = { ...reqData } const postData = { ...reqData }
return getAuxEnd(`/office/offers`, postData) return getAuxEnd(`/transactions`, postData)
} }
// FUNCTION TO GET APPLIED LOANS TABLE // FUNCTION TO GET REPAYMENTS TABLE
export const selectLoan = (reqData) => { export const getRepayments = (reqData) => {
const postData = { ...reqData } const postData = { ...reqData }
return getAuxEnd(`/office/loan/select`, postData) return getAuxEnd(`/repayments`, postData)
} }
// FUNCTION TO GET APPLIED LOANS TABLE // FUNCTION TO GET LOAN CHARGES TABLE
export const approvedLoan = (reqData) => { export const getLoanCharges = (reqData) => {
const postData = { ...reqData } const postData = { ...reqData }
return getAuxEnd(`/office/loan/approved`, postData) return getAuxEnd(`/loan-charges`, postData)
}
// FUNCTION TO GET OFFERS LIST TABLE
export const getOffers = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/offers`, postData)
}
// FUNCTION TO GET REPAYMENT SCHEDULE TABLE
export const getRepaymentSchedule = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/repayment-schedules`, postData)
}
// FUNCTION TO GET RECENT LOANS
export const getRecentLoans = (reqData) => {
const postData = { ...reqData }
return getAuxEnd(`/recent-loans`, postData)
} }