Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e20b7e32f1 | |||
| 6bd533c7ca | |||
| 408777353d | |||
| a2e039eab4 | |||
| 8d6cc5861e | |||
| 18967d720c | |||
| 044b2ef917 | |||
| 4f7fdfb2ba | |||
| 29538e3b6e |
@@ -25,7 +25,6 @@ const validationSchema = Yup.object().shape({
|
|||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
sales_agent: Yup.string()
|
sales_agent: Yup.string()
|
||||||
.required("Required")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function DashboardFormInit({handleNextStep}:Props) {
|
export default function DashboardFormInit({handleNextStep}:Props) {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import React, { FC } from "react";
|
import React, { FC, useState, useEffect } from "react";
|
||||||
import NairaBag from "../../assets/images/dashboard/naira-bag.png";
|
import NairaBag from "../../assets/images/dashboard/naira-bag.png";
|
||||||
import { Button } from "../";
|
import { Button, Icons } from "../";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
import PendingList from "../paginated-list/PendingList";
|
||||||
|
import { PendingTableList } from "../../core/models";
|
||||||
|
import { NewDateTimeFormatter } from "../../lib/NewDateTimeFormatter";
|
||||||
|
import { getUserPendingLoanList } from "../../core/apiRequest";
|
||||||
|
|
||||||
export interface DashBoardCardProps {
|
export interface DashBoardCardProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
@@ -75,8 +79,31 @@ interface DashboardHomeIntroProps {
|
|||||||
|
|
||||||
const DashboardHomeIntro: FC<DashboardHomeIntroProps> = ({ handleNextStep, step }) => {
|
const DashboardHomeIntro: FC<DashboardHomeIntroProps> = ({ handleNextStep, step }) => {
|
||||||
const { userDetails } = useSelector((state:any) => state?.userDetails); // CHECKS IF USER Details are avaliable
|
const { userDetails } = useSelector((state:any) => state?.userDetails); // CHECKS IF USER Details are avaliable
|
||||||
|
|
||||||
|
const [userLoanList, setUserLoanList] = useState<{loading:boolean, data:PendingTableList}>({loading: true, data:[]})
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
let token = localStorage.getItem('token')
|
||||||
|
let uid = localStorage.getItem('uid')
|
||||||
|
if(!token || !uid){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
getUserPendingLoanList(uid).then(res => {
|
||||||
|
console.log('RES', res)
|
||||||
|
console.log('RES', userLoanList)
|
||||||
|
if(!res || !res.data.loans){
|
||||||
|
setUserLoanList({loading:false, data:[]})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setUserLoanList({loading:false, data:res?.data?.loans})
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
setUserLoanList({loading:false, data:[]})
|
||||||
|
})
|
||||||
|
},[])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className='w-full'>
|
||||||
{step == 1 ?
|
{step == 1 ?
|
||||||
<>
|
<>
|
||||||
<h1 className="font-bold my-5 text-2xl">Hello, {userDetails.firstname}</h1>
|
<h1 className="font-bold my-5 text-2xl">Hello, {userDetails.firstname}</h1>
|
||||||
@@ -114,7 +141,50 @@ const DashboardHomeIntro: FC<DashboardHomeIntroProps> = ({ handleNextStep, step
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
</>
|
{userLoanList.loading ?
|
||||||
|
null
|
||||||
|
:
|
||||||
|
<div className='mt-5 w-full'>
|
||||||
|
<PendingList
|
||||||
|
data={userLoanList.data}
|
||||||
|
itemsPerPage={5}
|
||||||
|
tableTitle='Current Applications'
|
||||||
|
>
|
||||||
|
{(data:any)=>(
|
||||||
|
<div className="w-full p-4 rounded-lg shadow-lg bg-white overflow-x-auto min-h-[250px] max-h-[450px]">
|
||||||
|
<table className="text-[12px] sm:text-base w-full table-auto">
|
||||||
|
<thead>
|
||||||
|
<tr className='text-left border-b-2'>
|
||||||
|
<th className='px-1 py-4'>Date</th>
|
||||||
|
<th className='px-1 py-4 text-right'>Amount</th>
|
||||||
|
<th className='px-1 py-4 text-center min-w-[110px]'>Payment Term</th>
|
||||||
|
<th className='px-1 py-4 text-center'>Status</th>
|
||||||
|
<th className='px-1 py-4'>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{data.map((item:any, index:any) =>(
|
||||||
|
<tr key={index || item} className='even:bg-slate-100'>
|
||||||
|
<td className='px-1 py-2'>{NewDateTimeFormatter(item?.added)}</td>
|
||||||
|
<td className='px-1 py-2 text-right'>{item?.loan_amount}</td>
|
||||||
|
<td className='px-1 py-2 text-center'>{item?.payment_month}</td>
|
||||||
|
<td className='px-1 py-2 text-center'>{item?.status}</td>
|
||||||
|
<td className='px-1 py-2'>
|
||||||
|
<button className='px-2 py-1 border-2 border-black flex gap-2 items-center'>
|
||||||
|
View
|
||||||
|
<Icons name='arrow-right' />
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</PendingList>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const Header: React.FC<HiddenMenuItems> = ({
|
|||||||
<div className="flex flex-col-reverse lg:flex-col grow lg:grow-0 justify-between items-end">
|
<div className="flex flex-col-reverse lg:flex-col grow lg:grow-0 justify-between items-end">
|
||||||
<ul className="flex gap-0 lg:gap-[10px] items-center justify-end w-full flex-wrap">
|
<ul className="flex gap-0 lg:gap-[10px] items-center justify-end w-full flex-wrap">
|
||||||
{[
|
{[
|
||||||
{ text: "Open An Account", href: RouteHandler.getStarted },
|
{ text: "Open An Account", href: RouteHandler.letsGetStarted },
|
||||||
{
|
{
|
||||||
text: "Internet Banking",
|
text: "Internet Banking",
|
||||||
href: RouteHandler.businessBanking,
|
href: RouteHandler.businessBanking,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FaCaretDown } from "react-icons/fa";
|
import { FaCaretDown, FaCaretRight } from "react-icons/fa";
|
||||||
|
|
||||||
import dashIcon from "../../assets/images/dashboard/dashDefault.svg";
|
import dashIcon from "../../assets/images/dashboard/dashDefault.svg";
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -111,6 +111,8 @@ export default function Icons({ name, fillColor, className }: Props) {
|
|||||||
</svg>
|
</svg>
|
||||||
) :name == 'arrow-down'?
|
) :name == 'arrow-down'?
|
||||||
<FaCaretDown className={`text-xl ${className && className}`} />
|
<FaCaretDown className={`text-xl ${className && className}`} />
|
||||||
|
:name == 'arrow-right'?
|
||||||
|
<FaCaretRight className={`text-xl ${className && className}`} />
|
||||||
:name == "dash-icon" ? (
|
:name == "dash-icon" ? (
|
||||||
<img src={dashIcon} alt="dash-icon" />
|
<img src={dashIcon} alt="dash-icon" />
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import { ReactNode, useEffect, useState } from "react";
|
||||||
|
import { PendingTableList } from "../../core/models";
|
||||||
|
|
||||||
|
type PaginatedListProps = {
|
||||||
|
data: PendingTableList,
|
||||||
|
itemsPerPage?: number,
|
||||||
|
filterItem?: string[],
|
||||||
|
tableTitle?: string,
|
||||||
|
titleClass?:string,
|
||||||
|
children: (data:PendingTableList) => ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PendingList({
|
||||||
|
data,
|
||||||
|
itemsPerPage = 5,
|
||||||
|
filterItem,
|
||||||
|
tableTitle,
|
||||||
|
titleClass,
|
||||||
|
children,
|
||||||
|
}:PaginatedListProps) {
|
||||||
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
|
const [filteredData, setFilteredData] = useState(data);
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(0);
|
||||||
|
const [newData, setNewData] = useState<any>([]);
|
||||||
|
|
||||||
|
const numberOfSelection = itemsPerPage;
|
||||||
|
|
||||||
|
const handlePrev = () => {
|
||||||
|
if (currentPage != 0) {
|
||||||
|
setCurrentPage((prev) => prev - numberOfSelection);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleNext = () => {
|
||||||
|
if (currentPage < data.length) {
|
||||||
|
setCurrentPage((prev) => prev + numberOfSelection);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSearch = ({ target: { value } }:{target: {value:string}}, name:string) => {
|
||||||
|
setSearchTerm(value);
|
||||||
|
let newFilteredData:any = data.filter((item:any) =>
|
||||||
|
item[name].toLowerCase().startsWith(value.toLowerCase())
|
||||||
|
);
|
||||||
|
setFilteredData(newFilteredData);
|
||||||
|
setCurrentPage(0);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setNewData(
|
||||||
|
filteredData?.slice(currentPage, numberOfSelection + currentPage)
|
||||||
|
);
|
||||||
|
}, [currentPage, filteredData]);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
setCurrentPage(0)
|
||||||
|
},[itemsPerPage])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full">
|
||||||
|
<h1 className={`text-2xl mb-5 font-semibold ${titleClass && titleClass}`}>{tableTitle}</h1>
|
||||||
|
|
||||||
|
{data.length > 0 && filterItem && (
|
||||||
|
<div className="mb-10 flex justify-end items-center gap-2">
|
||||||
|
{filterItem.map((item, index) => (
|
||||||
|
<label
|
||||||
|
key={index}
|
||||||
|
className="flex flex-col sm:flex-row items-center gap-2 text-slate-600 dark:text-slate-100 transition-all duration-500"
|
||||||
|
>
|
||||||
|
Search by {item[0].toUpperCase() + item.slice(1)}
|
||||||
|
<input
|
||||||
|
name={item}
|
||||||
|
type="text"
|
||||||
|
className="py-1 px-2 text-sm min-w-[100px] text-black dark:text-white bg-white dark:bg-slate-800 rounded-full border-0 outline-none ring-1 ring-slate-300 dark:ring-white transition-all duration-500"
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleSearch(e, item);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{children(newData)}
|
||||||
|
|
||||||
|
{/* show prev and next button if data exist */}
|
||||||
|
{(data.length > 0 && data.length > itemsPerPage) && (
|
||||||
|
<div className="mt-5 md:mt-10 w-full flex gap-4 justify-center items-center">
|
||||||
|
<button
|
||||||
|
onClick={handlePrev}
|
||||||
|
className={`w-6 h-6 md:w-12 md:h-12 text-sm md:text-lg rounded-full flex justify-center items-center transition-all duration-300 ${
|
||||||
|
currentPage == 0
|
||||||
|
? "text-slate-400 border-slate-400 dark:text-slate-400 dark:border-slate-400 pointer-events-none"
|
||||||
|
: "text-slate-600 border-slate-600 dark:text-white dark:border-white"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{data.length && data.map((item, index)=>{
|
||||||
|
item = item
|
||||||
|
if(index%itemsPerPage == 0 && index >= currentPage && index <= currentPage+itemsPerPage){
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={index}
|
||||||
|
onClick={handleNext}
|
||||||
|
className={`w-6 h-6 md:w-12 md:h-12 text-sm md:text-lg rounded-full flex justify-center items-center border transition-all duration-300 ${
|
||||||
|
currentPage != index
|
||||||
|
? "text-slate-400 border-slate-400 dark:text-slate-400 dark:border-slate-400"
|
||||||
|
: "text-slate-600 border-slate-600 dark:text-white dark:border-white pointer-events-none"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{index/itemsPerPage +1}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
|
||||||
|
<button
|
||||||
|
onClick={handleNext}
|
||||||
|
className={`w-6 h-6 md:w-12 md:h-12 text-sm md:text-lg rounded-full flex justify-center items-center transition-all duration-300 ${
|
||||||
|
currentPage + numberOfSelection >= data.length
|
||||||
|
? "text-slate-400 border-slate-400 dark:text-slate-400 dark:border-slate-400 pointer-events-none"
|
||||||
|
: "text-slate-600 border-slate-600 dark:text-white dark:border-white"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -26,7 +26,6 @@ export const applyForLoan = (postData:any) => {
|
|||||||
return postAuxEnd('/loan/apply', reqData)
|
return postAuxEnd('/loan/apply', reqData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FUNCTION TO GET USER BY CUSTOMER UID
|
// FUNCTION TO GET USER BY CUSTOMER UID
|
||||||
export const getUserByID = (uid:string) => {
|
export const getUserByID = (uid:string) => {
|
||||||
let reqData = {
|
let reqData = {
|
||||||
@@ -34,3 +33,11 @@ export const getUserByID = (uid:string) => {
|
|||||||
}
|
}
|
||||||
return getAuxEnd(`/profile?uid=${uid}`, reqData)
|
return getAuxEnd(`/profile?uid=${uid}`, reqData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTION TO GET USER BY CUSTOMER UID
|
||||||
|
export const getUserPendingLoanList = (uid:string) => {
|
||||||
|
let reqData = {
|
||||||
|
// customer_uid: localStorage.getItem('uid'),
|
||||||
|
}
|
||||||
|
return getAuxEnd(`/dash?uid=${uid}`, reqData)
|
||||||
|
}
|
||||||
@@ -16,3 +16,12 @@ export interface User {
|
|||||||
customer_uid?:string
|
customer_uid?:string
|
||||||
call_return?:string
|
call_return?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type PendingTableList = {
|
||||||
|
status?: string | boolean;
|
||||||
|
application_uid?: string
|
||||||
|
added?: string
|
||||||
|
loan_amount?: string
|
||||||
|
payment_month?: string
|
||||||
|
}[];
|
||||||
@@ -83,8 +83,8 @@ export default function DashboardLayout({ children }: { children: ReactNode }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className="flex p-5 relative">
|
<div className="flex p-2 md:p-5 relative">
|
||||||
<div className="w-full p-5">{children}</div>
|
<div className="w-full p-2 md:p-5">{children}</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
export function NewDateTimeFormatter(isoDateString:any, addHour = true) {
|
||||||
|
const date = new Date(isoDateString);
|
||||||
|
if (addHour) {
|
||||||
|
date.setTime(date.getTime() + 1 * 60 * 60 * 1000);
|
||||||
|
}
|
||||||
|
const formattedDate = date.toLocaleDateString("en-US", {
|
||||||
|
year: "numeric",
|
||||||
|
month: "numeric",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
// second: "2-digit",
|
||||||
|
hour12: true,
|
||||||
|
timeZone: "UTC",
|
||||||
|
});
|
||||||
|
return formattedDate;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user