fix: can redirect to password form from otp form
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Box, Button, Stack, Typography } from '@mui/material';
|
||||
import { Edit2 } from 'iconsax-react';
|
||||
import { ArrowLeft, ArrowRight, Edit2 } from 'iconsax-react';
|
||||
import DigitInput from '@/components/DigitsInput';
|
||||
import type { AuthFactory, AuthMode, AuthType } from '../../types/authTypes';
|
||||
import { useEffect, useState } from 'react';
|
||||
@@ -31,6 +31,8 @@ interface OtpVerifyFormProps {
|
||||
tokenResponse: GenerateTokenResponse,
|
||||
) => void;
|
||||
authFactory: AuthFactory;
|
||||
hasPassword: boolean;
|
||||
onLoginWithPassword: () => void;
|
||||
}
|
||||
|
||||
export function OtpVerifyForm({
|
||||
@@ -41,11 +43,13 @@ export function OtpVerifyForm({
|
||||
onEditValue,
|
||||
onOTPVerified,
|
||||
authFactory,
|
||||
hasPassword,
|
||||
onLoginWithPassword,
|
||||
}: OtpVerifyFormProps) {
|
||||
const [otpCode, setOtpCode] = useState<string>('');
|
||||
const [otpDigitInvalid, setOtpDigitInvalid] = useState<boolean>(false);
|
||||
const [isStatusSuccess, setIsStatusSuccess] = useState<boolean>();
|
||||
const { t } = useTranslation('authentication');
|
||||
const { t, i18n } = useTranslation('authentication');
|
||||
const [resendTimer, setResendTimer] = useState<number>(120);
|
||||
const [canResend, setCanResend] = useState(false);
|
||||
const toast = useToast();
|
||||
@@ -219,6 +223,21 @@ export function OtpVerifyForm({
|
||||
onChange={(value) => setOtpCode(value)}
|
||||
/>
|
||||
|
||||
{hasPassword && (
|
||||
<Button
|
||||
onClick={onLoginWithPassword}
|
||||
sx={{ width: 'auto', mb: 2 }}
|
||||
variant="text"
|
||||
endIcon={
|
||||
<Icon
|
||||
Component={i18n.dir() === 'rtl' ? ArrowLeft : ArrowRight}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{t('verify.loginWithPassword')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Button type="submit" loading={loginSignUpLoading}>
|
||||
{authMode === 'register'
|
||||
? t('verify.confirmAndContinue')
|
||||
|
||||
Reference in New Issue
Block a user