diff --git a/src/components/Dashboard/DashboardFormInit.tsx b/src/components/Dashboard/DashboardFormInit.tsx index 7595be4..220fc8b 100644 --- a/src/components/Dashboard/DashboardFormInit.tsx +++ b/src/components/Dashboard/DashboardFormInit.tsx @@ -1,73 +1,118 @@ import { Button, InputCompOne, Stepper } from ".."; -// import { useNavigate } from "react-router-dom"; -// import { RouteHandler } from "../../router/routes"; +import {Formik, Form} from 'formik' +import * as Yup from "yup"; type Props = { handleNextStep:()=>any } +const initialValues = { + amount: "", + duration: "", + id: "", +}; + +// To get the validation schema +const validationSchema = Yup.object().shape({ + duration: Yup.string() + .required("Required"), + amount: Yup.string() + .required("Required") + .test("no-e", "Invalid", (value:any) => { + if (value && /^[0-9]*$/.test(value) == false) { + return false; + } + return true; + }), + id: Yup.string() + .required("Required") +}); + export default function DashboardFormInit({handleNextStep}:Props) { - // let navigate = useNavigate(); - // const navigateToProfile = () => navigate(RouteHandler.dashboardProfile); + //FUNCTION TO HANDLE SUBMIT + const handleSubmit = (values:any) => { + console.log(values) + handleNextStep() + }; return (
-
- - {}} - /> - -
+ + {(props)=>( +
+
+ + + +
+
+ )} +
); } -interface Option { - value: string; - label: string; +interface SelectOption { + loading: boolean; + data: {value: string; + label: string}[] } -const duration: Option[] = [ - { value: "", label: "Please Select" }, - { value: "6", label: "6 Months" }, - { value: "12", label: "12 Months" }, - { value: "18", label: "18 Months" }, - { value: "24", label: "24 Months" }, -]; +const duration: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "6", label: "6 Months" }, + { value: "12", label: "12 Months" }, + { value: "18", label: "18 Months" }, + { value: "24", label: "24 Months" }, + ] +} diff --git a/src/components/Dashboard/home/DashboardHomeAttestation.tsx b/src/components/Dashboard/home/DashboardHomeAttestation.tsx index 8217680..f3ea735 100644 --- a/src/components/Dashboard/home/DashboardHomeAttestation.tsx +++ b/src/components/Dashboard/home/DashboardHomeAttestation.tsx @@ -1,4 +1,7 @@ import { Button, InputCompOne, Stepper } from '../../shared/index'; + +import {Formik, Form} from 'formik' +import * as Yup from "yup"; // import { useNavigate } from "react-router-dom"; // import { RouteHandler } from '../../../router/routes'; @@ -6,9 +9,29 @@ type Props = { handleNextStep:()=>any } +const initialValues = { + account_number: "", + checked: false +}; + +// To get the validation schema +const validationSchema = Yup.object().shape({ + account_number: Yup.string() + .required("Required"), + checked: Yup.bool() // use bool instead of boolean + .oneOf([true], "You must accept the terms and conditions") +}); + export default function DashboardHomeAttestation({handleNextStep}:Props) { // let navigate = useNavigate(); // const navigateToProfile = () => navigate(RouteHandler.dashboardProfile); + + //FUNCTION TO HANDLE SUBMIT + const handleSubmit = (values:any) => { + console.log(values) + handleNextStep() + }; + return (
@@ -16,31 +39,51 @@ export default function DashboardHomeAttestation({handleNextStep}:Props) {

Applicant's Attestation and Debit Instruction

NB: Must be your FCMB account number

-
-
- -
-
- -

By pressing, you agree that you have read, understood and accept the applicatant's attestation and terms and conditions for FCMB - premium salary loan. You also give us permission to collect financial information and run credit checks on the account provided through our partners -

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

By pressing, you agree that you have read, understood and accept the applicatant's attestation and terms and conditions for FCMB + premium salary loan. You also give us permission to collect financial information and run credit checks on the account provided through our partners +

+
+ {props.errors.checked && props.touched.checked && {props.errors.checked}} +
+
+
+ )} +
); } diff --git a/src/components/Dashboard/home/DashboardHomeDetail.tsx b/src/components/Dashboard/home/DashboardHomeDetail.tsx index 1b75ba4..991820e 100644 --- a/src/components/Dashboard/home/DashboardHomeDetail.tsx +++ b/src/components/Dashboard/home/DashboardHomeDetail.tsx @@ -1,105 +1,166 @@ import { Button, InputCompOne, Stepper } from '../../shared/index'; +import {Formik, Form} from 'formik' +import * as Yup from "yup"; + type Props = { handleNextStep:()=>any } +const initialValues = { + gender: "", + address: "", + marital_status: "", + state: "", + email:"" +}; + +// To get the validation schema +const validationSchema = Yup.object().shape({ + gender: Yup.string() + .required("Required"), + address: Yup.string() + .required("Required"), + marital_status: Yup.string() + .required("Required"), + state: Yup.string() + .required("Required"), + email: Yup.string() + .email("Invalid") + .required("Required"), +}); + export default function DashboardHomeDetail({handleNextStep}:Props) { + + //FUNCTION TO HANDLE SUBMIT + const handleSubmit = (values:any) => { + console.log(values) + handleNextStep() + }; + return (
-
-
- {}} - /> - -
-
- {}} - /> - {}} - /> -
- -
+ + {(props)=>( +
+
+
+ + +
+
+ + +
+ +
+
+ )} +
); } -interface Option { - value: string; - label: string; +interface SelectOption { + loading: boolean; + data: {value: string; + label: string}[] } -const gender: Option[] = [ - { value: "", label: "Please Select" }, - { value: "male", label: "Male" }, - { value: "female", label: "Female" }, - { value: "others", label: "Prefer not to say" }, -]; +const gender: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "male", label: "Male" }, + { value: "female", label: "Female" }, + { value: "others", label: "Prefer not to say" }, + ] +} -const maritalStatus: Option[] = [ - { value: "", label: "Please Select" }, - { value: "single", label: "Single" }, - { value: "married", label: "Married" }, - { value: "divorced", label: "Divorced" }, -]; +const maritalStatus: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "single", label: "Single" }, + { value: "married", label: "Married" }, + { value: "divorced", label: "Divorced" }, + ] +} -const state: Option[] = [ - { value: "", label: "Please Select" }, - { value: "abia", label: "Abia" }, - { value: "imo", label: "Imo" }, - { value: "lagos", label: "Lagos" }, -]; \ No newline at end of file +const state: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "abia", label: "Abia" }, + { value: "imo", label: "Imo" }, + { value: "lagos", label: "Lagos" }, + ] +} \ No newline at end of file diff --git a/src/components/Dashboard/home/DashboardHomeEmploymentInfo.tsx b/src/components/Dashboard/home/DashboardHomeEmploymentInfo.tsx index c84d97b..a5767e0 100644 --- a/src/components/Dashboard/home/DashboardHomeEmploymentInfo.tsx +++ b/src/components/Dashboard/home/DashboardHomeEmploymentInfo.tsx @@ -1,162 +1,275 @@ import { Button, InputCompOne, Stepper } from '../../shared/index'; +import {Formik, Form} from 'formik' +import * as Yup from "yup"; + type Props = { handleNextStep:()=>any } +const initialValues = { + job_title: "", + employer_name: "", + job_sector: "", + industry: "", + date_of_resumption: "", + employer_email:"", + annual_income: "", + monthly_salary: "", + salary_payment_date: "", + employee_id: "", + qualification: "" +}; + +// To get the validation schema +const validationSchema = Yup.object().shape({ + job_title: Yup.string() + .required("Required"), + employer_name: Yup.string() + .required("Required"), + job_sector: Yup.string() + .required("Required"), + industry: Yup.string() + .required("Required"), + date_of_resumption: Yup.string() + .required("Required"), + employer_email: Yup.string() + .email("Invalid") + .required("Required"), + annual_income: Yup.string() + .required("Required") + .test("no-e", "Invalid", (value:any) => { + if (value && /^[0-9]*$/.test(value) == false) { + return false; + } + return true; + }), + monthly_salary: Yup.string() + .required("Required") + .test("no-e", "Invalid", (value:any) => { + if (value && /^[0-9]*$/.test(value) == false) { + return false; + } + return true; + }), + salary_payment_date: Yup.string() + .required("Required"), + employee_id: Yup.string() + .required("Required"), + qualification: Yup.string() + .required("Required"), +}); + export default function DashboardHomeEmploymentInfo({handleNextStep}:Props) { + + + //FUNCTION TO HANDLE SUBMIT + const handleSubmit = (values:any) => { + console.log(values) + handleNextStep() + }; + + return (
-
-

Employment Informaton

-
- - -
-
- {}} - /> - {}} - /> -
-
- - -
-
- - -
-
- {" "} - -
- {}} - /> -
+ + {(props)=>( +
+
+

Employment Informaton

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ )} +
); } -interface Option { - value: string; - label: string; +interface SelectOption { + loading: boolean; + data: {value: string; + label: string}[] } -const jobSection: Option[] = [ - { value: "", label: "Please Select" }, - { value: "private (non academic)", label: "Private (non academic)" }, -]; +const jobSector: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "private (non academic)", label: "Private (non academic)" }, + ] +} -const industry: Option[] = [ - { value: "", label: "Please Select" }, - { value: "engineering", label: "Engineering" }, -]; +const industry: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "engineering", label: "Engineering" }, + ] +} -const qualification: Option[] = [ - { value: "", label: "Please Select" }, - { value: "b.sc + professional qualification", label: "B.Sc + Professional Qualification" }, -]; \ No newline at end of file +const qualification: SelectOption = { + loading: false, + data: [ + { value: "", label: "Please Select" }, + { value: "b.sc + professional qualification", label: "B.Sc + Professional Qualification" }, + ] +} \ No newline at end of file diff --git a/src/components/Dashboard/home/DashboardHomeRefereeInfo.tsx b/src/components/Dashboard/home/DashboardHomeRefereeInfo.tsx index e06df85..f66c5bd 100644 --- a/src/components/Dashboard/home/DashboardHomeRefereeInfo.tsx +++ b/src/components/Dashboard/home/DashboardHomeRefereeInfo.tsx @@ -1,126 +1,215 @@ import { Button, InputCompOne, Stepper } from '../../shared/index'; +import {Formik, Form} from 'formik' +import * as Yup from "yup"; + type Props = { handleNextStep:()=>any } +const initialValues = { + ref_name: "", + ref_email: "", + ref_number: "", + ref_relationship: "", + ref_bvn: "", + ref_two_name: "", + ref_two_email: "", + ref_two_number: "", + ref_two_relationship: "", + ref_two_bvn: "", +}; + +// To get the validation schema +const validationSchema = Yup.object().shape({ + ref_name: Yup.string() + .required("Required"), + ref_email: Yup.string() + .email("Invalid") + .required("Required"), + ref_number: Yup.string() + .required("Required"), + ref_relationship: Yup.string() + .required("Required"), + ref_bvn: Yup.string() + .required("Required"), + ref_two_name: Yup.string() + .required("Required"), + ref_two_email: Yup.string() + .email("Invalid") + .required("Required"), + ref_two_number: Yup.string() + .required("Required"), + ref_two_relationship: Yup.string() + .required("Required"), + ref_two_bvn: Yup.string() + .required("Required"), +}); + export default function DashboardHomeRefereeInfo({handleNextStep}:Props) { + + //FUNCTION TO HANDLE SUBMIT + const handleSubmit = (values:any) => { + console.log(values) + handleNextStep() + }; + + return (
-
-

Reference Details (Must be 18 years and above)

-
-
-

Reference one

-
- - - - - -
-
-
-

Reference two

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

Reference Details (Must be 18 years and above)

+
+
+

Reference one

+
+ + + + + +
+
+
+

Reference two

+
+ + + + + +
+
+
+
+
+ )} +
); } diff --git a/src/components/GetStarted/BVN.tsx b/src/components/GetStarted/BVN.tsx index f22576a..253c3f1 100644 --- a/src/components/GetStarted/BVN.tsx +++ b/src/components/GetStarted/BVN.tsx @@ -32,6 +32,7 @@ const BVN = ({handleNextStep}:Props) => { const handleSubmit = (values:any) => { console.log('values', values) + handleNextStep() }; return ( @@ -70,7 +71,6 @@ const BVN = ({handleNextStep}:Props) => { diff --git a/src/components/GetStarted/IntroDetails.tsx b/src/components/GetStarted/IntroDetails.tsx index a09f6a0..d238e0d 100644 --- a/src/components/GetStarted/IntroDetails.tsx +++ b/src/components/GetStarted/IntroDetails.tsx @@ -1,9 +1,10 @@ import React from "react"; import InputCompOne from "../shared/InputCompOne"; -interface Option { - value: string; - label: string; +interface SelectOption { + loading: boolean; + data: {value: string; + label: string}[] } interface InputSectionProps { @@ -56,7 +57,7 @@ const InputSection: React.FC = ({ "font-bold text-[18px] leading-[21.78px] tracking-[2%] text-[#5C2684] mb-[2px]", select: true, selectClass: "w-full h-[36px] rounded-[6px]", - selectOptions: [{ value: "", label: "Select" }], + selectOptions: {loading: false, data:[{ value: "", label: "Select" }]}, value: inputValues.agentId, onInput: handleInput, }, @@ -116,18 +117,24 @@ const InputSection: React.FC = ({ export default InputSection; -const maritalStatusOptions: Option[] = [ - { value: "", label: "Select" }, - { value: "single", label: "Single" }, - { value: "married", label: "Married" }, - { value: "divorced", label: "Divorced" }, - { value: "widowed", label: "Widowed" }, -]; +const maritalStatusOptions: SelectOption = { + loading: false, + data: [ + { value: "", label: "Select" }, + { value: "single", label: "Single" }, + { value: "married", label: "Married" }, + { value: "divorced", label: "Divorced" }, + { value: "widowed", label: "Widowed" }, + ] +} -const titleOptions: Option[] = [ - { value: "", label: "Select" }, - { value: "ms", label: "Ms" }, - { value: "mr", label: "Mr" }, - { value: "miss", label: "Miss" }, - { value: "mrs", label: "Mrs" }, -]; +const titleOptions: SelectOption = { + loading: false, + data: [ + { value: "", label: "Select" }, + { value: "ms", label: "Ms" }, + { value: "mr", label: "Mr" }, + { value: "miss", label: "Miss" }, + { value: "mrs", label: "Mrs" }, + ] +} diff --git a/src/components/shared/InputCompOne.tsx b/src/components/shared/InputCompOne.tsx index 09a1d10..ed8c7f4 100644 --- a/src/components/shared/InputCompOne.tsx +++ b/src/components/shared/InputCompOne.tsx @@ -8,16 +8,16 @@ export interface InputCompOneProps { labelSpanClass?: string; floatLabel?: string; placeholder?: string; - value?: string; - onChange?: (e: React.ChangeEvent) => void; - onInput?: (e: React.FormEvent) => void; + value?: string | any; + onChange?: (e:any) => any; + onInput?: (e:any) => any; name: string; tabIndex?: number; ref?: React.RefObject; selectValue?: string; input?: boolean; select?: boolean; - selectOptions?: { value: string; label: string }[]; + selectOptions?: {loading:boolean, data:{ value: string; label: string }[]}; inputType?: string; inputClass?: string; parentInputClass?: string; @@ -44,7 +44,7 @@ const InputCompOne = forwardRef( selectValue, input = false, select = false, - selectOptions = [], + selectOptions = {loading:false, data:[]}, inputType = "text", inputClass, parentInputClass, @@ -58,10 +58,10 @@ const InputCompOne = forwardRef( return (
{label && ( - }
)} @@ -94,19 +97,33 @@ const InputCompOne = forwardRef( id={label ? label : floatLabel} value={selectValue} className={`px-4 appearance-none ${floatLabel && 'peer pt-4'} ${selectClass}`} - // onChange={onChange} + onChange={onChange} > - {selectOptions.map(({ value, label }) => ( + {selectOptions.loading ? + + : selectOptions.data.length ? + selectOptions.data.map(({ value, label }) => ( + + )) + : + + } + {/* {selectOptions.map(({ value, label }) => ( - ))} + ))} */} {floatLabel && + className={`flex items-center gap-2 cursor-pointer text-sm text-black/70 dark:text-white absolute left-4 top-0 translate-y-0 peer-focus:top-0 peer-focus:translate-y-0 transition-all duration-500`} + > + {floatLabel} + {error && floatLabel && !label && {error}} + } {/* select custon arrow */}