feat: OTP verify status and status messages added

This commit is contained in:
مهرزاد قدرتی
2025-07-27 15:05:46 +03:30
parent ea5a679312
commit fc5d441712
7 changed files with 142 additions and 17 deletions

View File

@@ -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}