fix: remove duplicate component instance

This commit is contained in:
Sajad Mirjalili
2025-09-25 17:13:44 +03:30
parent fff86c5ff1
commit d5531b2508
11 changed files with 60 additions and 335 deletions

View File

@@ -1,5 +1,5 @@
import { Button, Stack, TextField, Typography, Box } from '@mui/material';
import { useRef, useState, type Dispatch } from 'react';
import { useEffect, useRef, useState, type Dispatch } from 'react';
import { useTranslation } from 'react-i18next';
import { isNumeric } from '@/utils/regexes/isNumeric';
import type { AuthFactory, AuthType } from '../../types/authTypes';
@@ -14,6 +14,7 @@ import { useToast } from '@rkheftan/harmony-ui';
import { useApi } from '@/hooks/useApi';
import type { GenerateTokenResponse } from '../../api/identityAPI';
import { GoogleAuthenticationV2 } from './GoogleAuthenticationV2';
import { replacePersianWithRealNumbers } from '@/utils/replacePersianWithRealNumbers';
export interface LoginRegisterFormProps {
loginRegisterValue: string;
@@ -47,11 +48,22 @@ export function LoginRegisterForm({
const [error, setError] = useState<string>();
const [touched, setTouched] = useState<boolean>(false);
const inputError: boolean = touched && !!error;
const [menuAnchorEl, setMenuAnchorEl] = useState<HTMLElement | null>(null);
const toast = useToast();
const { loading: userStatusLoading, execute: execUserStatus } = useApi(
getUserStatusByPhoneNumberOrEmail,
);
useEffect(() => {
if (textFieldRef.current) {
const inputBaseElement =
textFieldRef.current.querySelector('.MuiInputBase-root');
if (inputBaseElement) {
setMenuAnchorEl(inputBaseElement as HTMLElement);
}
}
}, []);
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
let newValue = event.target.value;
newValue = replacePersianWithRealNumbers(newValue);
@@ -160,7 +172,7 @@ export function LoginRegisterForm({
value={countryCode}
onChange={setCountryCode}
show={showAdornment}
menuAnchor={textFieldRef.current}
menuAnchor={menuAnchorEl}
onCloseFocusRef={inputRef}
/>
),