import React,{useState} from "react"; import {useNavigate} from "react-router-dom" import titleShape from "../../../assets/images/shape/text-shape-three.svg"; import AuthLayout from "../AuthLayout"; import Otp from "./Otp"; import usersService from "../../../services/UsersService"; export default function VerifyYou() { const [loading, setLoading] = useState(false); const [validation, setValidation] = useState(""); const verifyOTP = new usersService() const navigate = useNavigate() const [verificationCode, setVerificationCode] = useState({ value_one: '', value_two: '' }) const handleVerificationInput = ({target:{name, value}}) => { setVerificationCode(prev => { return {...prev, [name]:value} }) } const handleSubmit = async() => { setValidation("") setLoading(true) let otpCode = ''; for(let values in verificationCode){ otpCode+=verificationCode[values] } // Validating otp code if(!otpCode) { setLoading(false) setValidation("Please enter your otp code") return } if(otpCode.length < 6) { setLoading(false) setValidation("OTP code incomplete") return } const {username} = JSON.parse(localStorage.getItem('reset_raw')) const verifyEmail = { username: username, stage: 200, reset_uuid: localStorage.getItem('reset_uuid'), random_text: otpCode } localStorage.setItem('otp', otpCode) try { const verify = await verifyOTP.resetPassword(verifyEmail); console.log(verify) localStorage.setItem('member_uid', verify.data.member_uid); if (verify.status != 200){ setValidation("Sorry, could not verify code") setLoading(false) return } if (verify.status == 200){ if(verify?.data.error_msg == "Unable to continue"){ setLoading(false) setValidation("Incorrect otp code") return } setValidation("verified successfully") setTimeout(() => { setLoading(false) navigate("/update-password", {replace : true}); }, 2000); return } } catch (error) { setLoading(false) setValidation('An error occurred') } } return ( <>

Verification Code

shape
{validation &&

{validation}

}

Dont’t have an aceount ? Sign Up

); }