diff --git a/src/components/GetStarted/EmployerValidation.tsx b/src/components/GetStarted/EmployerValidation.tsx index 530a213..8c9f14d 100644 --- a/src/components/GetStarted/EmployerValidation.tsx +++ b/src/components/GetStarted/EmployerValidation.tsx @@ -1,44 +1,49 @@ -import React from "react"; +import React, {useState} from "react"; +import { useSelector } from "react-redux"; +import { useLocation } from "react-router-dom"; -import { Button, InputCompOne } from ".."; +import { Button, CustomSpinner, InputCompOne } from ".."; import {Formik, Form} from 'formik' import * as Yup from "yup"; +import { RequestStatus, StoreState } from "../../core/models"; +import ErrorMsg from "../shared/ErrorMsg"; +import { verifyEmployee } from "../../core/apiRequest"; const initialValues = { - salary_acct: "", + // salary_acct: "", confirm_salary_acct: false, - qualification: "", - doe: "", - gl: "", - ippis: "", - employer_name: "", + education: "", + applicant_date: "", + grade: "", + ippis_number: "", + employers_name: "", designation: "", checked: false }; // To get the validation schema const validationSchema = Yup.object().shape({ - salary_acct: Yup.string() - .required("Required") - .test("no-e", "Invalid number", (value:any) => { - if (value && /^[0-9]*$/.test(value) == false) { - return false; - } - return true; - }) - .min(10, "must be 10 digits") - .max(10, "must be 10 digits"), + // salary_acct: Yup.string() + // .required("Required") + // .test("no-e", "Invalid number", (value:any) => { + // if (value && /^[0-9]*$/.test(value) == false) { + // return false; + // } + // return true; + // }) + // .min(10, "must be 10 digits") + // .max(10, "must be 10 digits"), confirm_salary_acct: Yup.bool() // use bool instead of boolean .oneOf([true], "You must check the box"), - qualification: Yup.string() + education: Yup.string() .required("Required"), - doe: Yup.string() + applicant_date: Yup.string() .required("BVN is required"), - gl: Yup.string() + grade: Yup.string() .required("Required"), - ippis: Yup.string(), - employer_name: Yup.string() + ippis_number: Yup.string(), + employers_name: Yup.string() .required("Required"), designation: Yup.string() .required("Required"), @@ -48,213 +53,233 @@ const validationSchema = Yup.object().shape({ const EmployerValidation: React.FC= () => { - // const inputRef = useRef(null); - // const handleInput = (e: React.FormEvent) => { - // const { name, value } = e.target as HTMLInputElement; + const { userDetails } = useSelector((state:StoreState) => state.userDetails); - // if (name === "bvn") { - // const isNumeric = /^[0-9]+$/.test(value); + const [requestStatus, setRequestStatus] = useState({loading:false, status:null, message:'', data:{}}) - // if (isNumeric) { - // if (value.length === 10) { - // setHideOTPComponent(false); - // } else { - // setHideOTPComponent(true); - // } - // } else { - // console.log("Invalid BVN"); - // } - // } - // }; + const { state:{application_uid, verify_uid} } = useLocation(); + const initialValuesNew = {...initialValues, application_uid, verify_uid} //FUNCTION TO HANDLE SUBMIT const handleSubmit = (values:any) => { - console.log(values) + delete values.checked + delete values.confirm_salary_acct + + setRequestStatus({loading:true, status:null, message:'', data:{}}) + verifyEmployee(values).then(res => { + console.log('RES', res) + // if(res.status != '200'){ + // setRequestStatus({loading:false, status:false, message:'verification failed', data:{}}) + // return setTimeout(()=>{ + // setRequestStatus({loading:false, status:false, message:'', data:{}}) + // },2000) + // } + setRequestStatus({loading:false, status:true, message:'verification sucessful', data:{}}) + }).catch(() => { + setRequestStatus({loading:false, status:false, message:'Something went wrong, try again!', data:{}}) + setTimeout(()=>{ + setRequestStatus({loading:false, status:false, message:'', data:{}}) + },2000) + }) }; return ( <> - {/* Header */} -
-

- EMPLOYER'S COMMITMENT AND VALIDATION -

-

(This is to be filled and validated by the employer of the applicant)

-
- - {(props)=>( -
-
-

We hereby confirm that Mr Victor Badmus (The Applicant) who applied for our loan facility is a permanent and confirmed (Non-contract) staff of Globalcom Nigeria limited and that he is actively on the company's payroll -

-

We hereby irrevocably and unconditionally undertake to domicile his/her salaries to First City Monument Bank Ltd (FCMB) Accounts number. -

-
-
-

Confirms Employee's salary account number - {(props.errors.salary_acct && props.touched.salary_acct) && {props.errors.salary_acct} } -

-
- - -
- {(props.errors.confirm_salary_acct && props.touched.confirm_salary_acct) && {props.errors.confirm_salary_acct} } -
- -
-

We further undertake that we shall not change the domiciliation of the applicant's account from FCMB throughout the tenor of the loan and any extension thereof unless with your written consent stating that the applicant is no longer indebted to the Bank. -

-

We agree to notigy you within 14 days in the event of transfer of the applicant from his/her present location, any change in the employment status or disengagement from the service of our organization or death of the applicant and shall pay his/her benefits, if applicable (excluding Pension Contribution) to the designated FCMB Account number above or issue a cheque or bank draft in favour of We further consent to any additional salary plus facility enhancement that may be obtained by the Beneficiary from your Bank subject to the Bank carrying out a due diligence as to the status of the Beneficiary's employment with our company prior to the approval of the facility Our commitment/consent and undertaking as stated above extends to cover additinal facilities of any kind that may be obtained from your Bank by any of the above mentioned Beneficiary(ies). -

-

This Undertaking is given in good faith and shall remain irrevocable except with the written consent of the Bank. -

-

Thank you.

-
- -
-

- Employers Validation -

-
- -
- - -
- - -
- - -
- -
-
- -

We hereby accept that all the information provided about the applicant (your employee) is true and correct to the best of our knowledge + {requestStatus.status ? +

+ Thank you for completing the process, we will continue further processing with the information provided +

+ : + <> + {/* Header */} +
+

+ EMPLOYER'S COMMITMENT AND VALIDATION +

+

(This is to be filled and validated by the employer of the applicant)

+
+ + {(props)=>( + +
+

We hereby confirm that Mr {userDetails.firstname} {userDetails.lastname} (The Applicant) who applied for our loan facility is a permanent and confirmed (Non-contract) staff of {userDetails.employer_name} and that he is actively on the company's payroll +

+

We hereby irrevocably and unconditionally undertake to domicile his/her salaries to First City Monument Bank Ltd (FCMB) Accounts number.

- {props.errors.checked && props.touched.checked && {props.errors.checked}} -
+
+
+ + +
+ {(props.errors.confirm_salary_acct && props.touched.confirm_salary_acct) && {props.errors.confirm_salary_acct} } +
-
- - -
+
+

We further undertake that we shall not change the domiciliation of the applicant's account from FCMB throughout the tenor of the loan and any extension thereof unless with your written consent stating that the applicant is no longer indebted to the Bank. +

+

We agree to notigy you within 14 days in the event of transfer of the applicant from his/her present location, any change in the employment status or disengagement from the service of our organization or death of the applicant and shall pay his/her benefits, if applicable (excluding Pension Contribution) to the designated FCMB Account number above or issue a cheque or bank draft in favour of We further consent to any additional salary plus facility enhancement that may be obtained by the Beneficiary from your Bank subject to the Bank carrying out a due diligence as to the status of the Beneficiary's employment with our company prior to the approval of the facility Our commitment/consent and undertaking as stated above extends to cover additinal facilities of any kind that may be obtained from your Bank by any of the above mentioned Beneficiary(ies). +

+

This Undertaking is given in good faith and shall remain irrevocable except with the written consent of the Bank. +

+

Thank you.

+
+ +
+

+ Employers Validation +

+
+ +
+ + +
+ + +
+ + +
+ +
+
+ +

We hereby accept that all the information provided about the applicant (your employee) is true and correct to the best of our knowledge +

+
+ {props.errors.checked && props.touched.checked && {props.errors.checked}} +
+ +
+ + +
- {/* submit button */} -
-
- - )} - + {/* submit button */} +
+
+
+ +
+ + )} + + + } ); }; diff --git a/src/components/auth/OTP.tsx b/src/components/auth/OTP.tsx index eee1cf5..53f6452 100644 --- a/src/components/auth/OTP.tsx +++ b/src/components/auth/OTP.tsx @@ -72,9 +72,9 @@ export default function Login() { } setRequestStatus({loading:false, status:true, message:'OTP Verified', data:res?.data}) localStorage.setItem('token', state?.verify_uid) - let data = {firstname:'firstname', lastname:'lastname', uid:'28273737646466464'} - dispatch(updateUserDetails(data)); - navigate(`/${state?.application_uid}`, {replace:true}) + // let data = {firstname:'firstname', lastname:'lastname', uid:'28273737646466464'} + dispatch(updateUserDetails(res?.data?.records)); + navigate(`/${state?.application_uid}`, {state:{'application_uid':state?.application_uid, 'verify_uid':state?.verify_uid}, replace:true}) }).catch(err =>{ setRequestStatus({loading:false, status:false, message:'something went wrong', data:{}}) console.log(err) diff --git a/src/core/apiRequest.ts b/src/core/apiRequest.ts index 66a8439..020125d 100644 --- a/src/core/apiRequest.ts +++ b/src/core/apiRequest.ts @@ -15,4 +15,12 @@ export const verifyOTP = (postData:any) => { ...postData } return postAuxEnd('/otp', reqData) +} + +// FUNCTION TO VERIFY OTP AND LOGIN +export const verifyEmployee = (postData:any) => { + let reqData = { + ...postData + } + return postAuxEnd('/verify', reqData) } \ No newline at end of file diff --git a/src/core/models.ts b/src/core/models.ts index 159dc69..48f8f36 100644 --- a/src/core/models.ts +++ b/src/core/models.ts @@ -14,4 +14,8 @@ export interface APIResponse { password: string username: string } +} + +export interface StoreState { + [index:string]: string } \ No newline at end of file diff --git a/src/layouts/DashboardLayout/DashboardAuth.tsx b/src/layouts/DashboardLayout/DashboardAuth.tsx index ef27c00..d513a61 100644 --- a/src/layouts/DashboardLayout/DashboardAuth.tsx +++ b/src/layouts/DashboardLayout/DashboardAuth.tsx @@ -8,6 +8,7 @@ import { updateUserDetails } from '../../store/UserDetails'; import { RouteHandler } from '../../router/routes'; import Logo from '../../assets/images/logo.png' +import { StoreState } from '../../core/models'; export default function DashboardAuth() { @@ -15,7 +16,7 @@ export default function DashboardAuth() { const dispatch = useDispatch() const {application_uid} = useParams() - const { userDetails } = useSelector((state:any) => state?.userDetails); // CHECKS IF USER Details are avaliable + const { userDetails } = useSelector((state:StoreState) => state?.userDetails); // CHECKS IF USER Details are avaliable const [loading, setLoading] = useState(true) @@ -45,7 +46,7 @@ export default function DashboardAuth() { navigate(RouteHandler.loginpage, {state:{application_uid}, replace:true}) return } - if(!application_uid){ // IF NO TOKEN || UID RETURN TO LOGIN PAGE + if(!application_uid){ // APPLICATION UID RETURN TO LOGIN PAGE navigate(RouteHandler.loginpage, {replace:true}) return }