From 814bfe041a8a416abb986f5a42cc3829e3939b7a Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Tue, 30 Apr 2024 19:03:22 +0100 Subject: [PATCH] added endpoint for loan application --- src/components/Dashboard/DashboardHome.tsx | 1 + .../home/DashboardHomeAttestation.tsx | 62 +++++++++++- .../Dashboard/home/DashboardHomeDetail.tsx | 51 +++++++--- .../LetsGetStated/LetsGetStarted.tsx | 6 +- src/components/shared/Stepper.tsx | 2 +- src/core/apiRequest.ts | 9 ++ src/core/axiosCall.ts | 97 ++++++++++--------- 7 files changed, 164 insertions(+), 64 deletions(-) diff --git a/src/components/Dashboard/DashboardHome.tsx b/src/components/Dashboard/DashboardHome.tsx index fc26030..79bc66e 100644 --- a/src/components/Dashboard/DashboardHome.tsx +++ b/src/components/Dashboard/DashboardHome.tsx @@ -28,6 +28,7 @@ const DashboardHome: FC = () => { {step === 5 && } {step === 6 && } {step === 7 && } + {/* */} ); }; diff --git a/src/components/Dashboard/home/DashboardHomeAttestation.tsx b/src/components/Dashboard/home/DashboardHomeAttestation.tsx index 67df9c6..c2cae7a 100644 --- a/src/components/Dashboard/home/DashboardHomeAttestation.tsx +++ b/src/components/Dashboard/home/DashboardHomeAttestation.tsx @@ -2,6 +2,8 @@ import { Button, InputCompOne, Stepper } from '../../shared/index'; import {Formik, Form} from 'formik' import * as Yup from "yup"; +import { applyForLoan } from '../../../core/apiRequest'; + // import { useNavigate } from "react-router-dom"; // import { RouteHandler } from '../../../router/routes'; @@ -27,11 +29,22 @@ export default function DashboardHomeAttestation({handleNextStep, applicationDet // let navigate = useNavigate(); // const navigateToProfile = () => navigate(RouteHandler.dashboardProfile); - //FUNCTION TO HANDLE SUBMIT + //FUNCTION TO HANDLE LOAN APPLICATION const handleSubmit = (values:any) => { delete values.checked - handleNextStep({disbursement: values}) - console.log('ApplicationDetails', applicationDetails) + applyForLoan({...applicationDetails, disbursement: values}).then(res=>{ + console.log('APPLY FOR LOAN', res) + handleNextStep({disbursement: values}) + console.log('ApplicationDetails', {...applicationDetails, disbursement: values}) + }).catch(err=>{ + console.log(err) + }) + // applyForLoan(payload).then(res=>{ + // console.log('APPLY FOR LOAN', res) + // // handleNextStep({disbursement: values}) + // }).catch(err=>{ + // console.log(err) + // }) }; return ( @@ -89,3 +102,46 @@ export default function DashboardHomeAttestation({handleNextStep, applicationDet ); } + + +// const payload = { +// "loan_amount": "100000", +// "payment_month": "18", +// "sales_agent": "Testing1234", +// "gender": "male", +// "address": "World bank housing Estate, Umuahia", +// "marital_status": "single", +// "state": "abia", +// "email": "test5070@gmail.com", +// "country": "NG", +// "employment": { +// "job_title": "Information Officer", +// "name": "Testing Testing", +// "sector": "private (non academic)", +// "industry": "engineering", +// "resumption_date": "2024-04-05", +// "email": "test50700@gmail.com", +// "annual_income": "600000", +// "monthly_salary": "50000", +// "salary_payment_date": "2024-04-19", +// "employment_id": "2555566", +// "highest_eductaion": "b.sc + professional qualification" +// }, +// "loan_reference": [ +// { +// "fullname": "John Mike", +// "relationship": "Brother", +// "phone_number": "07055566611", +// "email": "refone@gmail.com", +// "bvn": "11111111111" +// }, +// { +// "fullname": "Mary Paul", +// "relationship": "Brother", +// "phone_number": "07055577711", +// "email": "reftwo@gmail.com", +// "bvn": "22222222222" +// } +// ], +// disbursement:{account: '1122334456'} +// } \ No newline at end of file diff --git a/src/components/Dashboard/home/DashboardHomeDetail.tsx b/src/components/Dashboard/home/DashboardHomeDetail.tsx index 5205328..3097b18 100644 --- a/src/components/Dashboard/home/DashboardHomeDetail.tsx +++ b/src/components/Dashboard/home/DashboardHomeDetail.tsx @@ -12,7 +12,8 @@ const initialValues = { address: "", marital_status: "", state: "", - email:"" + email:"", + country:"" }; // To get the validation schema @@ -28,6 +29,8 @@ const validationSchema = Yup.object().shape({ email: Yup.string() .email("Invalid") .required("Required"), + country: Yup.string() + .required("Required"), }); export default function DashboardHomeDetail({handleNextStep}:Props) { @@ -102,18 +105,32 @@ export default function DashboardHomeDetail({handleNextStep}:Props) { error={(props.errors.state && props.touched.state) ? props.errors.state : ''} /> - +
+ + +