removing unused imports, creating a file for global decelaration

This commit is contained in:
مهرزاد قدرتی
2025-08-13 16:32:29 +03:30
parent 0a65e5f25c
commit 20da3f980e
21 changed files with 66 additions and 91 deletions

8
package-lock.json generated
View File

@@ -31,6 +31,7 @@
"@types/node": "^24.0.10", "@types/node": "^24.0.10",
"@types/react": "^19.1.8", "@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6", "@types/react-dom": "^19.1.6",
"@types/stylis": "^4.2.7",
"@typescript-eslint/eslint-plugin": "^8.35.1", "@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^8.35.1", "@typescript-eslint/parser": "^8.35.1",
"@vitejs/plugin-react": "^4.5.2", "@vitejs/plugin-react": "^4.5.2",
@@ -1882,6 +1883,13 @@
"@types/react": "*" "@types/react": "*"
} }
}, },
"node_modules/@types/stylis": {
"version": "4.2.7",
"resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.7.tgz",
"integrity": "sha512-VgDNokpBoKF+wrdvhAAfS55OMQpL6QRglwTwNC3kIgBrzZxA4WsFj+2eLfEA/uMUDzBcEhYmjSbwQakn/i3ajA==",
"dev": true,
"license": "MIT"
},
"node_modules/@typescript-eslint/eslint-plugin": { "node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.35.1", "version": "8.35.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.35.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.35.1.tgz",

View File

@@ -34,6 +34,7 @@
"@types/node": "^24.0.10", "@types/node": "^24.0.10",
"@types/react": "^19.1.8", "@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6", "@types/react-dom": "^19.1.6",
"@types/stylis": "^4.2.7",
"@typescript-eslint/eslint-plugin": "^8.35.1", "@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^8.35.1", "@typescript-eslint/parser": "^8.35.1",
"@vitejs/plugin-react": "^4.5.2", "@vitejs/plugin-react": "^4.5.2",

View File

@@ -1,5 +1,5 @@
import { Alert, Snackbar, type AlertColor } from '@mui/material'; import { Alert, Snackbar, type AlertColor } from '@mui/material';
import React, { type PropsWithChildren } from 'react'; import { type PropsWithChildren } from 'react';
export interface ToastProps extends PropsWithChildren { export interface ToastProps extends PropsWithChildren {
color: AlertColor | undefined; color: AlertColor | undefined;

View File

@@ -1,5 +1,5 @@
import { Box, Paper } from '@mui/material'; import { Paper } from '@mui/material';
import React, { type PropsWithChildren } from 'react'; import { type PropsWithChildren } from 'react';
// Beacuse in the otp verify there is a element outside of the authentication card // Beacuse in the otp verify there is a element outside of the authentication card
export const AuthenticationCard = ({ children }: PropsWithChildren) => { export const AuthenticationCard = ({ children }: PropsWithChildren) => {

View File

@@ -1,15 +1,10 @@
import React, { useState, type JSX } from 'react'; import { useState, type JSX } from 'react';
import { LoginRegisterForm } from './LoginRegiserForm'; import { LoginRegisterForm } from './LoginRegiserForm';
import type { AuthMode, AuthType } from '../../types/authTypes'; import type { AuthMode, AuthType } from '../../types/authTypes';
import { OtpVerifyForm } from './OtpVerifyForm'; import { OtpVerifyForm } from './OtpVerifyForm';
import { isNumeric } from '@/utils/regexes/isNumeric'; import { isNumeric } from '@/utils/regexes/isNumeric';
import { CompleteSignUp } from './CompleteSignUp'; import { CompleteSignUp } from './CompleteSignUp';
import { EnterPasswordForm } from './EnterPasswordForm'; import { EnterPasswordForm } from './EnterPasswordForm';
import {
getUserStatusByPhoneNumberOrEmail,
sendEmailOtp,
sendSmsOtp,
} from '../../api/authorizationAPI';
import { UserStatus } from '../../types/userTypes'; import { UserStatus } from '../../types/userTypes';
import type { CountryCode, GUID } from '@/types/commonTypes'; import type { CountryCode, GUID } from '@/types/commonTypes';
import { VerifyPhoneNumber } from './VerifyPhoneNumber'; import { VerifyPhoneNumber } from './VerifyPhoneNumber';
@@ -134,11 +129,9 @@ export const AuthenticationSteps = (): JSX.Element => {
{currentStep === 'addedPhoneNumberVerify' && ( {currentStep === 'addedPhoneNumberVerify' && (
<VerifyPhoneNumber <VerifyPhoneNumber
authReturnUrl={authReturnUrl}
countryCode={countryCode} countryCode={countryCode}
onEditValue={() => setCurrentStep('addPhoneNumber')} onEditValue={() => setCurrentStep('addPhoneNumber')}
value={addedPhoneNumberValue} value={addedPhoneNumberValue}
email={loginRegisterValue}
onPhoneNumberVerified={handlePhoneNumberVerified} onPhoneNumberVerified={handlePhoneNumberVerified}
/> />
)} )}

View File

@@ -1,6 +1,6 @@
import { Box, Button, Paper, TextField, Typography } from '@mui/material'; import { Button, TextField, Typography } from '@mui/material';
import parsePhoneNumberFromString from 'libphonenumber-js'; import parsePhoneNumberFromString from 'libphonenumber-js';
import React, { useRef, useState, type Dispatch } from 'react'; import { useRef, useState, type Dispatch } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
import { CountryCodeSelector } from '../CountryCodeSelector'; import { CountryCodeSelector } from '../CountryCodeSelector';

View File

@@ -1,6 +1,6 @@
import React, { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
import { ArrowLeft, Edit2, Eye, EyeSlash, MaskLeft } from 'iconsax-reactjs'; import { ArrowLeft, Edit2, Eye, EyeSlash } from 'iconsax-reactjs';
import { import {
Box, Box,
Button, Button,
@@ -11,7 +11,7 @@ import {
} from '@mui/material'; } from '@mui/material';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Toast } from '@/components/Toast'; import { Toast } from '@/components/Toast';
import { Link, Navigate, useSearchParams } from 'react-router'; import { Link } from 'react-router';
import type { AuthType } from '../../types/authTypes'; import type { AuthType } from '../../types/authTypes';
import type { CountryCode, GUID } from '@/types/commonTypes'; import type { CountryCode, GUID } from '@/types/commonTypes';
import { import {
@@ -19,7 +19,7 @@ import {
sendEmailOtp, sendEmailOtp,
sendSmsOtp, sendSmsOtp,
} from '../../api/authorizationAPI'; } from '../../api/authorizationAPI';
import type { LoginRequest, PasswordLoginRequest } from '../../types/userTypes'; import type { PasswordLoginRequest } from '../../types/userTypes';
export interface EnterPasswordFormProps { export interface EnterPasswordFormProps {
onEditValue: () => void; onEditValue: () => void;

View File

@@ -1,18 +1,11 @@
import { Button } from '@mui/material'; import { Button } from '@mui/material';
import { Google } from 'iconsax-reactjs'; import { Google } from 'iconsax-reactjs';
import React, { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import type { GoogleCodeClientResponse } from '../../types/userTypes'; import type { GoogleCodeClientResponse } from '../../types/userTypes';
import { loginOrSignUpWithGoogle } from '../../api/authorizationAPI'; import { loginOrSignUpWithGoogle } from '../../api/authorizationAPI';
import type { GUID } from '@/types/commonTypes'; import type { GUID } from '@/types/commonTypes';
declare global {
interface Window {
google: typeof google;
}
const google: any;
}
export interface GoogleAuthenticationProps { export interface GoogleAuthenticationProps {
disabled: boolean; disabled: boolean;
authReturnUrl: string; authReturnUrl: string;

View File

@@ -1,16 +1,8 @@
import { import { Button, Stack, TextField, Typography } from '@mui/material';
Box,
Button,
Paper,
Stack,
TextField,
Typography,
} from '@mui/material';
import { useRef, useState, type Dispatch } from 'react'; import { useRef, useState, type Dispatch } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Google } from 'iconsax-reactjs';
import { isNumeric } from '@/utils/regexes/isNumeric'; import { isNumeric } from '@/utils/regexes/isNumeric';
import type { AuthMode, AuthType } from '../../types/authTypes'; import type { AuthType } from '../../types/authTypes';
import { isEmail } from '@/utils/regexes/isEmail'; import { isEmail } from '@/utils/regexes/isEmail';
import parsePhoneNumberFromString from 'libphonenumber-js'; import parsePhoneNumberFromString from 'libphonenumber-js';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
@@ -45,10 +37,9 @@ export function LoginRegisterForm({
onGoogleAuthenticated, onGoogleAuthenticated,
}: LoginRegisterFormProps) { }: LoginRegisterFormProps) {
const [checkStatusLoading, setCheckStatusLoading] = useState<boolean>(false); const [checkStatusLoading, setCheckStatusLoading] = useState<boolean>(false);
const { t, i18n } = useTranslation('authentication'); const { t } = useTranslation('authentication');
const textFieldRef = useRef<HTMLDivElement>(null); const textFieldRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const dir = i18n.dir();
const [error, setError] = useState<string>(); const [error, setError] = useState<string>();
const [touched, setTouched] = useState<boolean>(false); const [touched, setTouched] = useState<boolean>(false);
const [errorMessage, setErrorMessage] = useState<string>(); const [errorMessage, setErrorMessage] = useState<string>();

View File

@@ -1,18 +1,13 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Alert, Box, Button, Snackbar, Stack, Typography } from '@mui/material'; import { Box, Button, Stack, Typography } from '@mui/material';
import { Edit2 } from 'iconsax-reactjs'; import { Edit2 } from 'iconsax-reactjs';
import DigitInput from '@/components/components/DigitsInput'; import DigitInput from '@/components/components/DigitsInput';
import type { AuthMode, AuthType } from '../../types/authTypes'; import type { AuthMode, AuthType } from '../../types/authTypes';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Toast } from '@/components/Toast'; import { Toast } from '@/components/Toast';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
import type { import type { LoginRequest } from '../../types/userTypes';
ConfirmEmailOtpRequest,
LoginRequest,
} from '../../types/userTypes';
import { useSearchParams } from 'react-router';
import { import {
confirmEmailOtp,
loginOrSignUpWithOtp, loginOrSignUpWithOtp,
sendEmailOtp, sendEmailOtp,
sendSmsOtp, sendSmsOtp,

View File

@@ -1,33 +1,22 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Alert, Box, Button, Snackbar, Stack, Typography } from '@mui/material'; import { Box, Button, Stack, Typography } from '@mui/material';
import { Edit2 } from 'iconsax-reactjs'; import { Edit2 } from 'iconsax-reactjs';
import DigitInput from '@/components/components/DigitsInput'; import DigitInput from '@/components/components/DigitsInput';
import type { AuthMode, AuthType } from '../../types/authTypes';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Toast } from '@/components/Toast'; import { Toast } from '@/components/Toast';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
import type { ConfirmSmsOtpRequest, LoginRequest } from '../../types/userTypes'; import type { ConfirmSmsOtpRequest } from '../../types/userTypes';
import { useSearchParams } from 'react-router'; import { confirmSmsOtp, sendSmsOtp } from '../../api/authorizationAPI';
import { import type { CountryCode } from '@/types/commonTypes';
confirmSmsOtp,
loginOrSignUpWithOtp,
sendEmailOtp,
sendSmsOtp,
} from '../../api/authorizationAPI';
import type { CountryCode, GUID } from '@/types/commonTypes';
interface VerifyPhoneNumberProps { interface VerifyPhoneNumberProps {
authReturnUrl: string;
value: string; value: string;
email: string;
countryCode: CountryCode; countryCode: CountryCode;
onEditValue: () => void; onEditValue: () => void;
onPhoneNumberVerified: () => void; onPhoneNumberVerified: () => void;
} }
export function VerifyPhoneNumber({ export function VerifyPhoneNumber({
authReturnUrl,
email,
value, value,
countryCode, countryCode,
onEditValue, onEditValue,

View File

@@ -13,7 +13,6 @@ import { useMemo, useRef, useState, type RefObject } from 'react';
import { ArrowDown2 } from 'iconsax-reactjs'; import { ArrowDown2 } from 'iconsax-reactjs';
import ReactCountryFlag from 'react-country-flag'; import ReactCountryFlag from 'react-country-flag';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Virtuoso } from 'react-virtuoso';
import { countries, type Country } from '../data/countries'; import { countries, type Country } from '../data/countries';
import type { CountryCode } from '@/types/commonTypes'; import type { CountryCode } from '@/types/commonTypes';
interface CountryCodeSelectorProps { interface CountryCodeSelectorProps {

View File

@@ -1,13 +1,6 @@
import React, { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
import { import { Edit2, Eye, EyeSlash, TickCircle } from 'iconsax-reactjs';
ArrowLeft,
Edit2,
Eye,
EyeSlash,
MaskLeft,
TickCircle,
} from 'iconsax-reactjs';
import { import {
Box, Box,
Button, Button,

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react'; import { useState } from 'react';
import type { AuthType } from '../../types/authTypes'; import type { AuthType } from '../../types/authTypes';
import { ForgettedPasswordInfo } from './ForgettedPasswordInfo'; import { ForgettedPasswordInfo } from './ForgettedPasswordInfo';
import { ForgetPasswordOtp } from './ForgetPasswordOtp'; import { ForgetPasswordOtp } from './ForgetPasswordOtp';
@@ -14,7 +14,7 @@ export const ForgetPasswordContainer = () => {
const [infoCountryCode, setInfoCountryCode] = useState<CountryCode>('+98'); const [infoCountryCode, setInfoCountryCode] = useState<CountryCode>('+98');
const [infoType, setInfoType] = useState<AuthType>('email'); const [infoType, setInfoType] = useState<AuthType>('email');
const handleVerifyOtp = (value: string) => { const handleVerifyOtp = () => {
setForgetPassCurrentStep('verifyOtp'); setForgetPassCurrentStep('verifyOtp');
}; };

View File

@@ -1,8 +1,8 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Alert, Box, Button, Snackbar, Stack, Typography } from '@mui/material'; import { Box, Button, Stack, Typography } from '@mui/material';
import { Edit2 } from 'iconsax-reactjs'; import { Edit2 } from 'iconsax-reactjs';
import DigitInput from '@/components/components/DigitsInput'; import DigitInput from '@/components/components/DigitsInput';
import type { AuthMode, AuthType } from '../../types/authTypes'; import type { AuthType } from '../../types/authTypes';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Toast } from '@/components/Toast'; import { Toast } from '@/components/Toast';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
@@ -96,8 +96,10 @@ export function ForgetPasswordOtp({
const jsonRes = await result.json(); const jsonRes = await result.json();
if (jsonRes.success) { if (jsonRes.success) {
setVerifyStatus('success');
onOTPVerified(otpCode); onOTPVerified(otpCode);
} else { } else {
setVerifyStatus('failed');
setVerifyAlertMessage(jsonRes.message); setVerifyAlertMessage(jsonRes.message);
} }

View File

@@ -1,16 +1,8 @@
import { import { Button, Stack, TextField, Typography } from '@mui/material';
Box,
Button,
Paper,
Stack,
TextField,
Typography,
} from '@mui/material';
import { useRef, useState, type Dispatch } from 'react'; import { useRef, useState, type Dispatch } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Google } from 'iconsax-reactjs';
import { isNumeric } from '@/utils/regexes/isNumeric'; import { isNumeric } from '@/utils/regexes/isNumeric';
import type { AuthMode, AuthType } from '../../types/authTypes'; import type { AuthType } from '../../types/authTypes';
import { isEmail } from '@/utils/regexes/isEmail'; import { isEmail } from '@/utils/regexes/isEmail';
import parsePhoneNumberFromString from 'libphonenumber-js'; import parsePhoneNumberFromString from 'libphonenumber-js';
import { AuthenticationCard } from '../AuthenticationCard'; import { AuthenticationCard } from '../AuthenticationCard';
@@ -39,10 +31,9 @@ export function ForgettedPasswordInfo({
countryCode, countryCode,
setCountryCode, setCountryCode,
}: ForgettedPasswordInfoProps) { }: ForgettedPasswordInfoProps) {
const { t, i18n } = useTranslation('authentication'); const { t } = useTranslation('authentication');
const textFieldRef = useRef<HTMLDivElement>(null); const textFieldRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null); const inputRef = useRef<HTMLInputElement>(null);
const dir = i18n.dir();
const [error, setError] = useState<string>(); const [error, setError] = useState<string>();
const [touched, setTouched] = useState<boolean>(false); const [touched, setTouched] = useState<boolean>(false);
const [errorMessage, setErrorMessage] = useState<string>(); const [errorMessage, setErrorMessage] = useState<string>();

View File

@@ -1,9 +1,6 @@
import { FlexBox } from '@/components/components/common/FlexBox'; import { FlexBox } from '@/components/components/common/FlexBox';
import Logo from '@/components/Logo'; import Logo from '@/components/Logo';
import { Paper } from '@mui/material';
import { useState } from 'react';
import { AuthenticationSteps } from '../components/AuthenticationSteps/AuthenticationSteps'; import { AuthenticationSteps } from '../components/AuthenticationSteps/AuthenticationSteps';
import { ForgetPasswordContainer } from '../components/ForgetPassword/ForgetPasswordContainer';
export function AuthenticationPage() { export function AuthenticationPage() {
return ( return (

View File

@@ -1,8 +1,5 @@
import { FlexBox } from '@/components/components/common/FlexBox'; import { FlexBox } from '@/components/components/common/FlexBox';
import Logo from '@/components/Logo'; import Logo from '@/components/Logo';
import { Paper } from '@mui/material';
import { useState } from 'react';
import { AuthenticationSteps } from '../components/AuthenticationSteps/AuthenticationSteps';
import { ForgetPasswordContainer } from '../components/ForgetPassword/ForgetPasswordContainer'; import { ForgetPasswordContainer } from '../components/ForgetPassword/ForgetPasswordContainer';
export function ForgetPasswordPage() { export function ForgetPasswordPage() {

12
src/global.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import React from 'react';
declare global {
namespace JSX {
interface Element extends React.ReactElement<any, any> {}
}
interface Window {
google: typeof google;
}
const google: any;
}

2
vite.config.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
declare const _default: import("vite").UserConfig;
export default _default;

12
vite.config.js Normal file
View File

@@ -0,0 +1,12 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
});