LFFE-30 implemention of auto submit component in core
This commit is contained in:
@@ -12,6 +12,7 @@ import ResendToken from "@/core/components/ResendToken";
|
||||
import useUser from "@/lib/app/hooks/useUser";
|
||||
import SvgRegister from "@/core/components/svgs/SvgRegister";
|
||||
import useRequest from "@/lib/app/hooks/useRequest";
|
||||
import AutoSubmit from "@/core/components/AutoSubmit";
|
||||
|
||||
const UserRegisterComponent = ({
|
||||
PhoneNumber,
|
||||
@@ -109,7 +110,7 @@ const UserRegisterComponent = ({
|
||||
placeholder={t(
|
||||
"LoginPage.text_field_enter_your_verification_code"
|
||||
)}
|
||||
type={"text"}
|
||||
type={"number"}
|
||||
error={
|
||||
!!(props.touched.verification_code && props.errors.verification_code)
|
||||
}
|
||||
@@ -119,7 +120,9 @@ const UserRegisterComponent = ({
|
||||
? props.errors.verification_code
|
||||
: null
|
||||
}
|
||||
onChange={(e) => e.target.value.length <= 6 ? props.setFieldValue("verification_code", e.target.value) : ""}
|
||||
/>
|
||||
<AutoSubmit/>
|
||||
<ResendToken
|
||||
initialTimerValue={initialTimerValue}
|
||||
timer={timer}
|
||||
|
||||
@@ -11,7 +11,7 @@ const NavyComponent = () => {
|
||||
const [timer, setTimer] = useState(initialTimerValue);
|
||||
// End For Resend Token
|
||||
|
||||
if (!otpToken) {
|
||||
if (otpToken) {
|
||||
return (
|
||||
<RequestOtpComponent
|
||||
setOtpToken={setOtpToken}
|
||||
|
||||
13
src/core/components/AutoSubmit.jsx
Normal file
13
src/core/components/AutoSubmit.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import {useFormikContext} from "formik";
|
||||
import {useEffect} from "react";
|
||||
|
||||
const AutoSubmit = () => {
|
||||
const {values, submitForm} = useFormikContext()
|
||||
useEffect(() => {
|
||||
if (values.verification_code.toString().length === 6) {
|
||||
submitForm();
|
||||
}
|
||||
}, [values, submitForm]);
|
||||
};
|
||||
|
||||
export default AutoSubmit;
|
||||
Reference in New Issue
Block a user