import React from "react"; import * as Yup from "yup"; import { Form, Formik } from "formik"; import { InputCompOne } from ".."; import {useNavigate} from 'react-router-dom' import { RouteHandler } from "../../router/routes"; // To get the validation schema const validationSchema = Yup.object().shape({ bvn: Yup.string() .required("BVN is required") .test("no-e", "Invalid number", (value:any) => { if (value && /^[0-9]*$/.test(value) == false) { return false; } return true; }) .min(11, "must be 11 digits") .max(11, "must be 11 digits"), otp: Yup.string() .required("OTP is required") .test("no-e", "Invalid number", (value:any) => { if (value && /^[0-9]*$/.test(value) == false) { return false; } return true; }) .min(5, "must be 5 digits") .max(5, "must be 5 digits"), // .test("no-e", "must be 11 characters", (value:any) => { // if (value.length < 11) { // return false; // } // return true; // }) }); // initial values for formik let initialValues = { bvn: '', otp: '', }; const LetsGetStarted: React.FC = () => { const navigate = useNavigate() // const [pinValues, setPinValues] = React.useState({ // bvn: "", // otp: "", // }); const [hideOTPComponent, setHideOTPComponent] = React.useState(true); const firstInputRef = React.useRef(null); const secondInputRef = React.useRef(null); // const handleChange = (e: React.ChangeEvent) => { // let { name, value } = e.target as HTMLInputElement; // setPinValues((prev) => ({ ...prev, [name]: value })); // }; const handleInput = (e: React.FormEvent) => { let { name, value } = e.target as HTMLInputElement; if (name === "bvn") { const regex = /^[0-9]+$/; if (regex.test(value)) { if (value?.length == 11) { setHideOTPComponent(false); // secondInputRef.current?.focus(); } else setHideOTPComponent(true); } else { console.log("object not found"); } } }; const handleSubmit = (values:any) => { console.log('values', values) navigate(RouteHandler.dashboardHome, {replace:true}) }; return ( {(props:any) => (

Let’s Get You Started

{!hideOTPComponent && ( )} {hideOTPComponent ? (

***Every personal information attached to your BVN is safe and secure. It is only important for us to verify your information and also give you access to your application profile/account.

) : (

***Did not receive OTP? Click to resend

)}
)}
); }; export default LetsGetStarted;