diff --git a/src/RouteLinks.js b/src/RouteLinks.js index 4709a12..ae3ba44 100644 --- a/src/RouteLinks.js +++ b/src/RouteLinks.js @@ -7,6 +7,7 @@ const RouteLinks = { applicationsLoanPage: '/loans/apply', disbursementsLoanPage: '/loans/disbursements', selectedLoanPage: '/loans/select', + loanOffersPage: '/loans/offers', } export default RouteLinks \ No newline at end of file diff --git a/src/SiteRoutes.jsx b/src/SiteRoutes.jsx index 261ba46..479c7e8 100644 --- a/src/SiteRoutes.jsx +++ b/src/SiteRoutes.jsx @@ -12,6 +12,7 @@ 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 // const Home = lazy(() => import('./pages/Home')); @@ -28,6 +29,7 @@ export default function SiteRoutes() { } /> {`*/DISBURSEMENTS LOANS PAGE*/`} } /> {`*/APPLICATIONS LOANS PAGE*/`} } /> {`*/SELECTED LOANS PAGE*/`} + } /> {`*/LOANS OFFERS PAGE*/`} {/* ERROR PAGE */} diff --git a/src/components/applicationsloancom/ApplicationsLoanCom.jsx b/src/components/applicationsloancom/ApplicationsLoanCom.jsx index 536efd1..fbe847e 100644 --- a/src/components/applicationsloancom/ApplicationsLoanCom.jsx +++ b/src/components/applicationsloancom/ApplicationsLoanCom.jsx @@ -13,7 +13,7 @@ import { applyLoan } from '../../services/siteServices' import getTimeFromDateString from '../../helpers/GetTimeFromDateString'; import getDateFromDateString from '../../helpers/GetDateFromDateString'; -export default function ApplicationsLoanCom() { +export default function LoanOffersCom() { const {data, isFetching, isError, error} = useQuery({ queryKey: queryKeys.apply_loan, diff --git a/src/components/layouts/DashboardHeader.jsx b/src/components/layouts/DashboardHeader.jsx index 3fbbc6a..59ce224 100644 --- a/src/components/layouts/DashboardHeader.jsx +++ b/src/components/layouts/DashboardHeader.jsx @@ -68,7 +68,7 @@ export default function DashboardHeader({showAsideDrawer, setShowAsideDrawer}) { user image */} - + diff --git a/src/components/layouts/aside/AsideLinkWithSubLinks.jsx b/src/components/layouts/aside/AsideLinkWithSubLinks.jsx index 5416ee2..cfae3e9 100644 --- a/src/components/layouts/aside/AsideLinkWithSubLinks.jsx +++ b/src/components/layouts/aside/AsideLinkWithSubLinks.jsx @@ -1,27 +1,29 @@ +import { useState } from "react"; import { useLocation } from "react-router-dom" import { FaCaretDown } from "react-icons/fa"; import Icons from "../../Icons"; -export default function AsideLinkWithSubLinks({shrinkAside, name, icon, hideSubMenu, setHideSubMenu, to, children}) { +export default function AsideLinkWithSubLinks({shrinkAside, name, icon, to, children, isOpen}) { // const btnName = name const {pathname} = useLocation() -// const [hideSubMenu, setHideSubMenu] = useState(true) + const isMatchedPath = pathname.split('/').includes('') + // isMatchedPath.splice(0,1) - const subLinkIsOpen = children.props.children.map(item => item.props).map(link => link.children).map(to => to.props.to).includes(pathname) + const [hideSubMenu, setHideSubMenu] = useState(isOpen) return (
- -
+
{children}
diff --git a/src/components/layouts/aside/DashboardAside.jsx b/src/components/layouts/aside/DashboardAside.jsx index cc7f593..a5f270e 100644 --- a/src/components/layouts/aside/DashboardAside.jsx +++ b/src/components/layouts/aside/DashboardAside.jsx @@ -19,18 +19,18 @@ export default function DashboardAside({shrinkAside=false}) { const {userDetails} = useSelector((state) => state.userDetails) // GETS LOGGED IN USER ROLE DETAILS const {role}= userDetails - const [hideSubMenu, setHideSubMenu] = useState('') + // const [hideSubMenu, setHideSubMenu] = useState('') - const handleHideSubMenu = (name) => { - // e.stopPropagation() - setHideSubMenu((prev) => { - if(prev == name){ - return '' - }else{ - return name - } - }) - } + // const handleHideSubMenu = (name) => { + // // e.stopPropagation() + // setHideSubMenu((prev) => { + // if(prev == name){ + // return '' + // }else{ + // return name + // } + // }) + // } return (
@@ -46,36 +46,77 @@ export default function DashboardAside({shrinkAside=false}) { if(active && !hasSubLinks){ return (
- +
) - }else if(active && hasSubLinks){ + } + if(active && hasSubLinks){ + // let subLinkList = link.subLinks.filter(value => value.to).map(item => { //any of all open + // if(item.to){ + // return item.to + // } + // }) + let subLinkList = [] + link.subLinks.forEach(item =>{ + if(item.to){ + subLinkList.push(item.to) + }else if(item.subLinks?.length > 0){ + item.subLinks.forEach(item => { + subLinkList.push(item.to) + }) + } + }) + // console.log('subLinkList', subLinkList) return (
{link.title &&

{link.title}

} - + <> {link.subLinks.map((subItem, index)=>{ let active = subItem.status == 1 ? true : false - if(active){ + let hasSubLinks = (subItem.subLinks && subItem.subLinks.length > 0) ? true : false + if(active && !hasSubLinks){ return (
) + }else if(active && hasSubLinks){ + let subLinkList = subItem.subLinks.filter(value => value.to).map(item => { // specific open + if(item.to){ + return item.to + } + }) + return( + + <> + {subItem.subLinks.map((item, index)=>{ + let active = item.status == 1 ? true : false + if(active){ + return ( +
+ +
+ ) + } + })} + +
+ ) + }else{ + return null } })}
) - }else{ - return null } })}
+
state.userDetails) // GETS LOGGED IN USER ROLE DETAILS + const {role}= userDetails + + const [hideSubMenu, setHideSubMenu] = useState('') + + const handleHideSubMenu = (name) => { + // e.stopPropagation() + setHideSubMenu((prev) => { + if(prev == name){ + return '' + }else{ + return name + } + }) + } + + return ( +
+
+ +
+
+ +
+ {asideNavLinks.map((link, index) => { + let active = link.status == 1 ? true : false + let hasSubLinks = (link.subLinks && link.subLinks.length > 0) ? true : false + if(active && !hasSubLinks){ + return ( +
+ +
+ ) + }else if(active && hasSubLinks){ + return ( +
+ {link.title && +

{link.title}

+ } + + <> + {link.subLinks.map((subItem, index)=>{ + let active = subItem.status == 1 ? true : false + if(active){ + return ( +
+ +
+ ) + } + })} + +
+
+ ) + }else{ + return null + } + })} +
+
+
+ setLogoutModal(true)} + > + + +
+
+
+ ) +} + +const asideNavLinks = [ + {name:'Dashboard', status:1, icon: 'dashboard', to: RouteLinks.homePage}, + {name:'Salary Loan', title:'Loan', status:1, icon: 'money', subLinks: [ + {name: 'Selected Loans', status:1, icon: 'dot', to: RouteLinks.selectedLoanPage}, + {name: 'Applications', status:1, icon: 'dot', to: RouteLinks.applicationsLoanPage}, + {name: 'Approved Loans', status:1, icon: 'dot', to: RouteLinks.approvedLoansPage}, + {name: 'Disbursements', status:1, icon: 'dot', to: RouteLinks.disbursementsLoanPage}, + {name: 'Payments', status:1, icon: 'dot', to: '#'}, + {name: 'Configurations', status:1, icon: 'dot', to: '#'}, + ], + }, + {name:'Product 2', title:'Product 2', status:1, icon: 'product', subLinks: [ + {name: 'Applications', status:1, icon: 'dot', to: '#'}, + {name: 'Configuration', status:1, icon: 'dot', to: '#'}, + ] + }, + {name:'Product 3', title:'Product 3', status:1, icon: 'product', subLinks: [ + {name: 'Applications', status:1, icon: 'dot', to: '#'}, + {name: 'Configuration', status:1, icon: 'dot', to: '#'}, + ] + }, + {name:'Administration', title:'Admin', status:1, icon: 'people', subLinks: [ + {name: 'Users', status:1, icon: 'dot', to: RouteLinks.usersPage}, + ] + }, +] diff --git a/src/components/loanofferscom/LoanOffersCom.jsx b/src/components/loanofferscom/LoanOffersCom.jsx new file mode 100644 index 0000000..f64cfed --- /dev/null +++ b/src/components/loanofferscom/LoanOffersCom.jsx @@ -0,0 +1,129 @@ +import React 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 Icons from '../Icons' + +import Avatar from '../../assets/user_avatar.jpg' +import queryKeys from '../../services/queryKeys' +import { loanOffers } from '../../services/siteServices' + +import getTimeFromDateString from '../../helpers/GetTimeFromDateString'; +import getDateFromDateString from '../../helpers/GetDateFromDateString'; + +export default function ApplicationsLoanCom() { + + const {data, isFetching, isError, error} = useQuery({ + queryKey: queryKeys.apply_loan, + queryFn: () => loanOffers() + }) + + const loanOffersUsersList = data?.data // LOAN OFFERS LIST + + return ( +
+ + + {isFetching ? + <> +
+

Loading...

+
+ + : isError ? +
+

{error.message}

+
+ : + + {({ data }) => ( + <> + + + + + + + + + + + + {/* */} + + + + {(data && data.length > 0) ? data?.map((item, index) => ( + + + + + + + + + + {/* */} + + )) + : + + + + } + +
+ CID + + Loan + + Amount + + Description + + Days Duration + + Ative + + Score + + Lorder + + Action +
+ Jese image +
+
{item?.cid}
+
+
+ {item?.loan} + + {item?.amount || ''} + + {item?.description} + + {item?.days_duration} + + {item?.active} + + {item?.score} + + {item?.lorder} + + + + +
+
+ No Record Found +
+
+ + )} +
+ } +
+ ) +} \ No newline at end of file diff --git a/src/components/tableWrapper/TableWrapper.jsx b/src/components/tableWrapper/TableWrapper.jsx index ffb9a5d..d666394 100644 --- a/src/components/tableWrapper/TableWrapper.jsx +++ b/src/components/tableWrapper/TableWrapper.jsx @@ -87,24 +87,26 @@ export default function TableWrapper({
Showing {isLoading ? '----' : `${currentPage + 1}-${currentPage + numberOfSelection >= data.length ? data.length : (currentPage + numberOfSelection)}`} of {data.length}
-
- - - - = data.length ? 'bg-primary/50 pointer-events-none' : 'bg-primary'} text-white-light text-center flex justify-center gap-2 items-center`} - disabled={isLoading} - > - - -
+ {(newData.length >= itemsPerPage) && +
+ + + + = data.length ? 'bg-primary/50 pointer-events-none' : 'bg-primary'} text-white-light text-center flex justify-center gap-2 items-center`} + disabled={isLoading} + > + + +
+ }
}
diff --git a/src/pages/LoanOffersPage.jsx b/src/pages/LoanOffersPage.jsx new file mode 100644 index 0000000..3aacaf4 --- /dev/null +++ b/src/pages/LoanOffersPage.jsx @@ -0,0 +1,8 @@ +import React from 'react' +import LoanOffersCom from '../components/loanofferscom/LoanOffersCom' + +export default function LoanOffersPage() { + return ( + + ) +} diff --git a/src/services/queryKeys.js b/src/services/queryKeys.js index 00a0ab9..a8a232c 100644 --- a/src/services/queryKeys.js +++ b/src/services/queryKeys.js @@ -2,6 +2,7 @@ const queryKeys = { apply_loan: ['apply'], select_loan: ['select-loan'], approved_loan: ['approved-loan'], + loan_offers: ['loan-offers'], } export default queryKeys \ No newline at end of file diff --git a/src/services/siteServices.js b/src/services/siteServices.js index d064855..55595c5 100644 --- a/src/services/siteServices.js +++ b/src/services/siteServices.js @@ -56,6 +56,12 @@ export const applyLoan = (reqData) => { return getAuxEnd(`/office/loan/apply`, postData) } +// FUNCTION TO GET APPLIED LOANS TABLE +export const loanOffers = (reqData) => { + const postData = { ...reqData } + return getAuxEnd(`/office/offers`, postData) +} + // FUNCTION TO GET APPLIED LOANS TABLE export const selectLoan = (reqData) => { const postData = { ...reqData }