From 0fc549f1b5c063812d63ecc894ee771597a5d8e2 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Mon, 15 Jul 2024 17:09:06 +0100 Subject: [PATCH] added loan details API --- .../approve-reject-page/ApproveRejectPage.tsx | 137 ++++++++++++------ src/app/modules/process/core/_models.ts | 49 +++++++ src/app/modules/process/core/_requests.ts | 10 +- .../components/loading/UsersListLoading.tsx | 19 ++- 4 files changed, 170 insertions(+), 45 deletions(-) diff --git a/src/app/modules/process/approve-reject-page/ApproveRejectPage.tsx b/src/app/modules/process/approve-reject-page/ApproveRejectPage.tsx index ac15773..c36b89a 100644 --- a/src/app/modules/process/approve-reject-page/ApproveRejectPage.tsx +++ b/src/app/modules/process/approve-reject-page/ApproveRejectPage.tsx @@ -2,7 +2,8 @@ import React, { useEffect, useState } from 'react' import {useLocation, useNavigate} from 'react-router-dom' import { Content } from '../../../../_digifi/layout/components/content' import { ToolbarWrapper } from '../../../../_digifi/layout/components/toolbar' -import { UsersListLoading } from '../user-started/components/loading/UsersListLoading' +import { CustomLoading, UsersListLoading } from '../user-started/components/loading/UsersListLoading' +import { getVerifiedLoanDetailsByUID } from '../core/_requests' export default function ApproveRejectPage() { const {state:{selectedUser}} = useLocation() @@ -10,6 +11,8 @@ export default function ApproveRejectPage() { const [requestStatus, setRequestStatus] = useState({loading:false, status:false, data:null}) + const [loanDetails, setLoanDetails] = useState({loading:true, data:null}) + const handleSubmit = ():any => { setRequestStatus({loading:true, status:false, data:null}) setTimeout(()=>{ @@ -19,59 +22,109 @@ export default function ApproveRejectPage() { useEffect(()=>{ if(!selectedUser){ - navigate('/', {replace:true}) + return navigate('/', {replace:true}) } + getVerifiedLoanDetailsByUID(selectedUser?.uid).then(res => { + setLoanDetails({loading:false, data:res?.data}) + }).catch(err => { + console.log(err) + setLoanDetails({loading:false, data:null}) + }) },[]) return ( <> {/* */} -
-

Processing: {selectedUser?.uid}

+ {loanDetails.loading ? +
+
- {/* begin::Row */} -
- {/* begin::Col */} -
-
-

Process Loan

-
- - - + : + <> +
+

Processing: {selectedUser?.uid}

+
+ {/* begin::Row */} +
+ {/* begin::Col */} +
+
+

Process Loan

+
+ + + +
+
+
+

Verification details

+
+ {loanDetails?.data?.verification.length > 0 ? + + + + + + {loanDetails?.data?.verification?.map((item:any) => ( + + + + + ))} +
UIDEMPLOYER NAME
{item.uid}{item.employers_name}
+ : + null + } +
-
-

Verification details

-
-
- {/* end::Col */} + {/* end::Col */} - {/* begin::Col */} -
-
-

Loan Details

+ {/* begin::Col */} +
+
+

Loan Details

+
+ {loanDetails?.data?.application.length > 0 ? + + + + + + {loanDetails?.data?.application?.map((item:any) => ( + + + + + ))} +
UIDAMOUNT
{item.uid}{item.loan_amount}
+ : + null + } +
+
-
- {/* end::Col */} -
- {/* end::Row */} + {/* end::Col */} +
+ {/* end::Row */} + + } {requestStatus.loading && } diff --git a/src/app/modules/process/core/_models.ts b/src/app/modules/process/core/_models.ts index 15033f6..1244c70 100644 --- a/src/app/modules/process/core/_models.ts +++ b/src/app/modules/process/core/_models.ts @@ -33,8 +33,57 @@ export type User = { employer_name?: string } +export type VerifiedLoanDetails = { + application_uid?: string + application?: Array<{[index: string]: string}> + // application?: [ + // { + // "id": "21", + // "uid": "006915e9-cb0d-42e9-b4af-c047da51e2ac", + // "customer_uid": "9cb678e0-0697-4cc9-9bf0-3f40a3c989fb", + // "loan_amount": "2220", + // "payment_month": "18", + // "sales_agent": "866969", + // "gender": null, + // "marital_status": "single", + // "email": "ameye+update@chiefsoft.com", + // "address": "4201 Defoors Farm Trail", + // "state": "abia", + // "country": "NG", + // "loan_detail": "{\"customer_uid\":\"9cb678e0-0697-4cc9-9bf0-3f40a3c989fb\",\"loan_amount\":\"2220\",\"payment_month\":\"18\",\"sales_agent\":\"866969\",\"gender\":\"female\",\"address\":\"4201 Defoors Farm Trail\",\"marital_status\":\"single\",\"state\":\"abia\",\"email\":\"ameye+update@chiefsoft.com\",\"country\":\"NG\",\"employer_uid\":\"3a9ec95a-090c-4c98-bc01-e96d76b93952\",\"employment\":\"[object Object]\",\"loan_reference\":\"[object Object],[object Object]\",\"disbursement\":\"[object Object]\"}", + // "status": "4", + // "added": "2024-07-10 21:28:13.404726", + // "updated": "2024-07-10 21:28:13.404726", + // "employer_uid": "3a9ec95a-090c-4c98-bc01-e96d76b93952" + // } + // ], + verification?: Array<{[index: string]: string}> + // "verification": [ + // { + // "id": "56", + // "uid": "e041279c-875d-4973-b042-48efec05fecf", + // "employer_uid": "3a9ec95a-090c-4c98-bc01-e96d76b93952", + // "status": "1", + // "added": "2024-07-11 16:03:25.343553", + // "updated": "2024-07-11 16:03:25.343553", + // "username": "ameye+update@chiefsoft.com", + // "password": "5769407ab4409037161a51692c6bb617", + // "signatory_uid": "db444b87-ec0f-483b-a8cf-eea9e8466f10", + // "application_uid": "006915e9-cb0d-42e9-b4af-c047da51e2ac", + // "education": "b.sc", + // "grade": "Test 001", + // "applicant_date": "2024-07-10 00:00:00", + // "ippis_number": "", + // "employers_name": "bshshsjss", + // "designation": "jdjdjddk" + // } + // ] +} + export type UsersQueryResponse = Response> +export type VerifiedLoanDetailsResponse = Response + export const initialUser: User = { avatar: 'avatars/300-6.jpg', position: 'Art Director', diff --git a/src/app/modules/process/core/_requests.ts b/src/app/modules/process/core/_requests.ts index 298d2e2..3c53e0d 100644 --- a/src/app/modules/process/core/_requests.ts +++ b/src/app/modules/process/core/_requests.ts @@ -1,7 +1,7 @@ import axios, { AxiosResponse } from "axios"; import { ID, Response } from "../../../../_digifi/helpers" -import { User, UsersQueryResponse } from "./_models"; -import { postAuxEnd } from "../../auth/core/AxiosCallHelper"; +import { User, UsersQueryResponse, VerifiedLoanDetailsResponse } from "./_models"; +import { postAuxEnd, getAuxEnd } from "../../auth/core/AxiosCallHelper"; const API_URL = import.meta.env.VITE_APP_THEME_API_URL; const USER_URL = `${API_URL}/user`; @@ -54,6 +54,10 @@ const employersVerify = (uid: ID): Promise => { // FUNCTION return postAuxEnd('/employers/verify', {application_uid:uid}) }; +const getVerifiedLoanDetailsByUID = (uid: string): Promise => { // FUNCTION TO GET VERIFIED LOAN DETAILS IN ORDER TO PROCESS + return getAuxEnd(`/loan/process/${uid}`) +}; + const getUserById = (id: ID): Promise => { return axios .get(`${USER_URL}/${id}`) @@ -92,6 +96,8 @@ export { getVerifiedUsers, getApprovedUsers, employersVerify, + getVerifiedLoanDetailsByUID, + deleteUser, deleteSelectedUsers, getUserById, diff --git a/src/app/modules/process/user-started/components/loading/UsersListLoading.tsx b/src/app/modules/process/user-started/components/loading/UsersListLoading.tsx index 2278f87..16015e2 100644 --- a/src/app/modules/process/user-started/components/loading/UsersListLoading.tsx +++ b/src/app/modules/process/user-started/components/loading/UsersListLoading.tsx @@ -15,4 +15,21 @@ const UsersListLoading = () => { return
Processing...
} -export {UsersListLoading} +const CustomLoading = () => { + const styles = { + borderRadius: '0.475rem', + boxShadow: '0 0 50px 0 rgb(82 63 105 / 15%)', + backgroundColor: '#fff', + color: '#7e8299', + fontWeight: '500', + margin: '0', + width: 'auto', + padding: '1rem 2rem', + top: 'calc(50% - 2rem)', + left: 'calc(50% - 4rem)', + } + + return
Loading...
+} + +export {UsersListLoading, CustomLoading}