pending loan list added to dashboard #51
@@ -1,8 +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, Icons } from "../";
|
import { Button, Icons } from "../";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import PendingList from "../paginated-list/PendingList";
|
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;
|
||||||
@@ -76,6 +79,29 @@ 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'>
|
<div className='w-full'>
|
||||||
{step == 1 ?
|
{step == 1 ?
|
||||||
@@ -115,31 +141,34 @@ const DashboardHomeIntro: FC<DashboardHomeIntroProps> = ({ handleNextStep, step
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
{userLoanList.loading ?
|
||||||
|
null
|
||||||
|
:
|
||||||
<div className='mt-5 w-full'>
|
<div className='mt-5 w-full'>
|
||||||
<PendingList
|
<PendingList
|
||||||
data={dummyData}
|
data={userLoanList.data}
|
||||||
itemsPerPage={5}
|
itemsPerPage={5}
|
||||||
tableTitle='Current Applications'
|
tableTitle='Current Applications'
|
||||||
>
|
>
|
||||||
{({data}:any)=>(
|
{(data:any)=>(
|
||||||
<div className="w-full p-4 rounded-lg shadow-lg bg-white overflow-x-auto min-h-[250px] max-h-[450px]">
|
<div className="w-full p-4 rounded-lg shadow-lg bg-white overflow-x-auto min-h-[250px] max-h-[450px]">
|
||||||
<table className="w-full table-auto">
|
<table className="w-full table-auto">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className='text-left border-b-2'>
|
<tr className='text-left border-b-2'>
|
||||||
<th className='px-1 py-4'>Date</th>
|
<th className='px-1 py-4'>Date</th>
|
||||||
<th className='px-1 py-4'>Amount</th>
|
<th className='px-1 py-4 text-right'>Amount</th>
|
||||||
<th className='px-1 py-4'>Payment Term</th>
|
<th className='px-1 py-4 text-center'>Payment Term</th>
|
||||||
<th className='px-1 py-4'>Status</th>
|
<th className='px-1 py-4 text-center'>Status</th>
|
||||||
<th className='px-1 py-4'>Action</th>
|
<th className='px-1 py-4'>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.map((item:any, index:any) =>(
|
{data.map((item:any, index:any) =>(
|
||||||
<tr key={index || item} className='even:bg-slate-100'>
|
<tr key={index || item} className='even:bg-slate-100'>
|
||||||
<td className='px-1 py-2'>{'item.date'}</td>
|
<td className='px-1 py-2'>{NewDateTimeFormatter(item?.added)}</td>
|
||||||
<td className='px-1 py-2'>The Sliding Mr. Bones (Next Stop, Pottersville)</td>
|
<td className='px-1 py-2 text-right'>{item?.loan_amount}</td>
|
||||||
<td className='px-1 py-2'>12</td>
|
<td className='px-1 py-2 text-center'>{item?.payment_month}</td>
|
||||||
<td className='px-1 py-2'>Malcolm Lockyer</td>
|
<td className='px-1 py-2 text-center'>{item?.status}</td>
|
||||||
<td className='px-1 py-2'>
|
<td className='px-1 py-2'>
|
||||||
<button className='px-2 py-1 border-2 border-black flex gap-2 items-center'>
|
<button className='px-2 py-1 border-2 border-black flex gap-2 items-center'>
|
||||||
View
|
View
|
||||||
@@ -154,21 +183,13 @@ const DashboardHomeIntro: FC<DashboardHomeIntroProps> = ({ handleNextStep, step
|
|||||||
)}
|
)}
|
||||||
</PendingList>
|
</PendingList>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DashboardHomeIntro;
|
export default DashboardHomeIntro;
|
||||||
|
|
||||||
const dummyData = [
|
|
||||||
{id: 1, name: 'obi John', last_login: '12/12/2024', image: 'string'},
|
|
||||||
{id: 1, name: 'obi John', last_login: '12/12/2024', image: 'string'},
|
|
||||||
{id: 1, name: 'obi John', last_login: '12/12/2024', image: 'string'},
|
|
||||||
{id: 1, name: 'obi John', last_login: '12/12/2024', image: 'string'},
|
|
||||||
{id: 1, name: 'obi John', last_login: '12/12/2024', image: 'string'},
|
|
||||||
{id: 1, name: 'obi John', last_login: '12/12/2024', image: 'string'}
|
|
||||||
]
|
|
||||||
|
|
||||||
// {/* <div className="group w-full lg:w-96 h-32">
|
// {/* <div className="group w-full lg:w-96 h-32">
|
||||||
// <DefaultCard
|
// <DefaultCard
|
||||||
// descText="You currently do not have any open application. Click on apply for a loan to get started."
|
// descText="You currently do not have any open application. Click on apply for a loan to get started."
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { ReactNode, useEffect, useState } from "react";
|
import { ReactNode, useEffect, useState } from "react";
|
||||||
|
import { PendingTableList } from "../../core/models";
|
||||||
|
|
||||||
type PaginatedListProps = {
|
type PaginatedListProps = {
|
||||||
data: { id: number, name: string, last_login: string, image: string }[],
|
data: PendingTableList,
|
||||||
itemsPerPage?: number,
|
itemsPerPage?: number,
|
||||||
filterItem?: string[],
|
filterItem?: string[],
|
||||||
tableTitle?: string,
|
tableTitle?: string,
|
||||||
titleClass?:string,
|
titleClass?:string,
|
||||||
children: (data:any) => ReactNode;
|
children: (data:PendingTableList) => ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PendingList({
|
export default function PendingList({
|
||||||
@@ -81,7 +82,7 @@ export default function PendingList({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{children({ data: newData })}
|
{children(newData)}
|
||||||
|
|
||||||
{/* show prev and next button if data exist */}
|
{/* show prev and next button if data exist */}
|
||||||
{(data.length > 0 && data.length > itemsPerPage) && (
|
{(data.length > 0 && data.length > itemsPerPage) && (
|
||||||
|
|||||||
@@ -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
|
||||||
|
}[];
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
export type TableListProps = {
|
|
||||||
id?: number;
|
|
||||||
name?: string;
|
|
||||||
date?: string;
|
|
||||||
amount?: string;
|
|
||||||
payment_term?: string;
|
|
||||||
status?: boolean;
|
|
||||||
}[];
|
|
||||||
Reference in New Issue
Block a user