feat: OTP verify status and status messages added
This commit is contained in:
@@ -2,21 +2,31 @@ import React, { useState, type JSX } from 'react';
|
||||
import { LoginRegisterForm } from './LoginRegiserForm';
|
||||
import type { AuthMode, AuthType } from '../types/auth-types';
|
||||
import { OtpVerifyForm } from './OtpVerifyForm';
|
||||
import { isNumeric } from '@/utils/regexes/isNumeric';
|
||||
|
||||
export const AuthenticationContainer = (): JSX.Element => {
|
||||
const [authMode, setAuthMode] = useState<AuthMode>('register');
|
||||
const [authMode, setAuthMode] = useState<AuthMode>('login');
|
||||
const [authType, setAuthType] = useState<AuthType>('phone');
|
||||
const [currentStep, setCurrentStep] = useState<
|
||||
'emailOrPassword' | 'verify' | 'enterPassword'
|
||||
>('verify');
|
||||
const [loginRegisterValue, setLoginRegisterValue] =
|
||||
useState<string>('9152814093');
|
||||
'emailOrPassword' | 'verify' | 'enterPassword' | 'addPhoneNumber'
|
||||
>('emailOrPassword');
|
||||
const [loginRegisterValue, setLoginRegisterValue] = useState<string>('');
|
||||
|
||||
const handleLoginRegister = (value: string) => {
|
||||
setLoginRegisterValue(value);
|
||||
setAuthType(isNumeric(value) ? 'phone' : 'email');
|
||||
setCurrentStep('verify');
|
||||
};
|
||||
|
||||
const handleOTPVerfied = (otpCode: string) => {
|
||||
console.log(otpCode);
|
||||
|
||||
if (authMode === 'register' && authType === 'email') {
|
||||
setAuthType('phone');
|
||||
setCurrentStep('addPhoneNumber');
|
||||
}
|
||||
};
|
||||
|
||||
const handleEditValue = () => {
|
||||
setCurrentStep('emailOrPassword');
|
||||
};
|
||||
@@ -35,6 +45,7 @@ export const AuthenticationContainer = (): JSX.Element => {
|
||||
|
||||
{currentStep === 'verify' && (
|
||||
<OtpVerifyForm
|
||||
onOTPVerified={handleOTPVerfied}
|
||||
onEditValue={handleEditValue}
|
||||
authMode={authMode}
|
||||
authType={authType}
|
||||
|
||||
Reference in New Issue
Block a user