From 1bd523c4932c89b249ce912488a380567f8cfd34 Mon Sep 17 00:00:00 2001 From: Ebube Date: Wed, 20 Mar 2024 13:37:49 +0100 Subject: [PATCH] added valid types --- src/components/GetStarted/BasicInfo.tsx | 58 ++++++++++++++++--------- src/components/shared/InputCompOne.tsx | 4 +- src/utils/data.tsx | 6 +-- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/components/GetStarted/BasicInfo.tsx b/src/components/GetStarted/BasicInfo.tsx index 42e4a9e..c05b2cb 100644 --- a/src/components/GetStarted/BasicInfo.tsx +++ b/src/components/GetStarted/BasicInfo.tsx @@ -1,4 +1,4 @@ -import React, { useRef } from "react"; +import React, { useRef, useState } from "react"; import InputCompOne from "../shared/InputCompOne"; interface Option { @@ -7,7 +7,19 @@ interface Option { } const BasicInfo: React.FC = () => { - const [hideOTPComponent, setHideOTPComponent] = React.useState(true); + const [hideOTPComponent, setHideOTPComponent] = useState(true); + const [inputValues, setInputValues] = useState({ + title: "", + marital: "", + agentId: "", + bvn: "", + firstName: "", + phone: "", + email: "", + surname: "", + dob: "", + secondName: "", + }); const inputRef = useRef(null); // Array for marital status options @@ -29,16 +41,19 @@ const BasicInfo: React.FC = () => { ]; const handleChange = (e: React.ChangeEvent) => { - // Handle input value changes - console.log(e.target.value); + const { name, value } = e.target; + + setInputValues((prev) => ({ ...prev, [name]: value })); }; const handleInput = (e: React.FormEvent) => { + const { name, value } = e.currentTarget; + if (name === "bvn") { const regex = /^[0-9]+$/; if (regex.test(value)) { - if (value?.length == 10) { + if (value?.length === 10) { setHideOTPComponent(false); // secondInputRef.current?.focus(); } else setHideOTPComponent(true); @@ -60,7 +75,7 @@ const BasicInfo: React.FC = () => { select selectClass="w-full h-[36px] rounded-[12px]" selectOptions={titleOptions} - value="" + value={inputValues.title} onChange={handleChange} ref={inputRef} /> @@ -72,7 +87,7 @@ const BasicInfo: React.FC = () => { select selectClass="w-full h-[36px] rounded-[12px]" selectOptions={maritalStatusOptions} - value="" + value={inputValues.marital} onChange={handleChange} onInput={handleInput} ref={inputRef} @@ -85,7 +100,7 @@ const BasicInfo: React.FC = () => { select selectClass="w-full h-[36px] rounded-[12px]" selectOptions={[{ value: "", label: "Select" }]} - value="" + value={inputValues.agentId} onChange={handleChange} onInput={handleInput} ref={inputRef} @@ -100,10 +115,11 @@ const BasicInfo: React.FC = () => { labelClass="font-bold text-[18px] leading-[21.78px] tracking-[2%] text-[#5C2684] mb-[2px] gap-[2px]" input inputClass="w-full h-[36px] bg-[#EFEFEF] px-[2px] rounded-[12px]" - value="" + value={inputValues.bvn} onChange={handleChange} onInput={handleInput} ref={inputRef} + maxLength={10} /> @@ -113,36 +129,36 @@ const BasicInfo: React.FC = () => {
{
) => void; - onInput: (e: React.FormEvent) => void; + onChange?: (e: React.ChangeEvent) => void; + onInput?: (e: React.FormEvent) => void; name: string; tabIndex?: number; ref?: React.RefObject; diff --git a/src/utils/data.tsx b/src/utils/data.tsx index 5876770..eebfefd 100644 --- a/src/utils/data.tsx +++ b/src/utils/data.tsx @@ -400,9 +400,9 @@ export const _lowerMenuItems = [ ]; export const socialsIcons = [ - { name: "facebook", image: FBook, link: import.meta.env.VITE_FACEBOOK_URL }, - { name: "twitter", image: Twitter, link: import.meta.env.VITE_TWITTER_URL }, - { name: "instagram", image: Instagram, link: import.meta.env.VITE_INSTAGRAM_URL }, + { name: "facebook", image: FBook, link: process.VITE_FACEBOOK_URL }, + { name: "twitter", image: Twitter, link: process.VITE_TWITTER_URL }, + { name: "instagram", image: Instagram, link: process.VITE_INSTAGRAM_URL }, ]; export const footerItems = [