From 718bc3aaa0f5ebbaf52cea16bf1783a38890bd12 Mon Sep 17 00:00:00 2001 From: mehrzadghdev Date: Sun, 21 Sep 2025 21:47:45 +0330 Subject: [PATCH] =?UTF-8?q?fix:=20login=20info=20inputs=20paddings,=20pers?= =?UTF-8?q?ian=20number=20support,=20country=20code=20selector=20not=20fou?= =?UTF-8?q?nd=20message,=20codes=20ltr,=20auto=20submit=20after=20otp=20pa?= =?UTF-8?q?ste=20or=20enter,=20removing=20word=20"=D8=AF=D9=82=DB=8C=D9=82?= =?UTF-8?q?=D9=87"=20from=20otp=20timer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/AuthenticationSteps/CompleteSignUp.tsx | 2 +- .../AuthenticationSteps/LoginRegiserForm.tsx | 4 +++- .../components/AuthenticationSteps/OtpVerifyForm.tsx | 6 ++++++ .../AuthenticationSteps/VerifyPhoneNumber.tsx | 6 ++++++ .../authentication/components/CountryCodeSelector.tsx | 9 +++++++-- .../components/ForgetPassword/ForgetPasswordOtp.tsx | 6 ++++++ .../ForgetPassword/ForgettedPasswordInfo.tsx | 4 +++- src/utils/replacePersianWithRealNumbers.ts | 10 ++++++++++ 8 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/utils/replacePersianWithRealNumbers.ts diff --git a/src/features/authentication/components/AuthenticationSteps/CompleteSignUp.tsx b/src/features/authentication/components/AuthenticationSteps/CompleteSignUp.tsx index 6ec07f3..e85c694 100644 --- a/src/features/authentication/components/AuthenticationSteps/CompleteSignUp.tsx +++ b/src/features/authentication/components/AuthenticationSteps/CompleteSignUp.tsx @@ -99,7 +99,7 @@ export const CompleteSignUp = ({ helperText={inputError ? error : ''} autoFocus slotProps={{ - htmlInput: { dir: 'auto', sx: { lineHeight: 1.5, paddingX: 0 } }, + htmlInput: { dir: 'auto', sx: { lineHeight: 1.5 } }, input: { endAdornment: ( ) => { let newValue = event.target.value; + newValue = replacePersianWithRealNumbers(newValue); if (newValue.startsWith('09')) { newValue = newValue.substring(1); } @@ -152,7 +154,7 @@ export function LoginRegisterForm({ helperText={inputError ? error : ''} autoFocus slotProps={{ - htmlInput: { dir: 'auto', sx: { lineHeight: 1.5, paddingX: 0 } }, + htmlInput: { dir: 'auto', sx: { lineHeight: 1.5 } }, input: { endAdornment: ( { + if (otpCode.length === 4) { + handleVerifyOTP(); + } + }, [otpCode]); + useEffect(() => { let interval: NodeJS.Timeout; if (resendTimer > 0) { diff --git a/src/features/authentication/components/AuthenticationSteps/VerifyPhoneNumber.tsx b/src/features/authentication/components/AuthenticationSteps/VerifyPhoneNumber.tsx index 2b9b0fc..9943fe3 100644 --- a/src/features/authentication/components/AuthenticationSteps/VerifyPhoneNumber.tsx +++ b/src/features/authentication/components/AuthenticationSteps/VerifyPhoneNumber.tsx @@ -35,6 +35,12 @@ export function VerifyPhoneNumber({ const { loading: confirmSmsOtpLoading, execute: confirmSmsOtpCall } = useApi(confirmSmsOtp); + useEffect(() => { + if (otpCode.length === 4) { + handleVerifyOTP(); + } + }, [otpCode]); + useEffect(() => { let interval: NodeJS.Timeout; if (resendTimer > 0) { diff --git a/src/features/authentication/components/CountryCodeSelector.tsx b/src/features/authentication/components/CountryCodeSelector.tsx index 2aa9709..fd42dac 100644 --- a/src/features/authentication/components/CountryCodeSelector.tsx +++ b/src/features/authentication/components/CountryCodeSelector.tsx @@ -16,6 +16,7 @@ import { useTranslation } from 'react-i18next'; import { countries, type Country } from '../../../data/countries'; import type { CountryCode } from '@/types/commonTypes'; import { Icon } from '@rkheftan/harmony-ui'; +import { LTRBox } from '@/components/common/LTRBox'; interface CountryCodeSelectorProps { show: boolean; value: CountryCode; @@ -187,7 +188,9 @@ export function CountryCodeSelector({ {filteredCountries.length === 0 ? ( - {t('messages.noResualtFound')} + + {t('messages.noResualtFound', { ns: 'common' })} + ) : ( @@ -209,7 +212,9 @@ export function CountryCodeSelector({ - {country.phone} + + {country.phone} + )) diff --git a/src/features/authentication/components/ForgetPassword/ForgetPasswordOtp.tsx b/src/features/authentication/components/ForgetPassword/ForgetPasswordOtp.tsx index e9c8045..d914114 100644 --- a/src/features/authentication/components/ForgetPassword/ForgetPasswordOtp.tsx +++ b/src/features/authentication/components/ForgetPassword/ForgetPasswordOtp.tsx @@ -48,6 +48,12 @@ export function ForgetPasswordOtp({ execute: confirmForgetPassCodeCall, } = useApi(confirmForgetPassCode); + useEffect(() => { + if (otpCode.length === 4) { + handleVerifyOTP(); + } + }, [otpCode]); + useEffect(() => { let interval: NodeJS.Timeout; if (resendTimer > 0) { diff --git a/src/features/authentication/components/ForgetPassword/ForgettedPasswordInfo.tsx b/src/features/authentication/components/ForgetPassword/ForgettedPasswordInfo.tsx index 0ab10ab..5b2df84 100644 --- a/src/features/authentication/components/ForgetPassword/ForgettedPasswordInfo.tsx +++ b/src/features/authentication/components/ForgetPassword/ForgettedPasswordInfo.tsx @@ -12,6 +12,7 @@ import type { SendForgetPassCodeRequest } from '../../types/userTypes'; import { isPhoneNumber } from '@/utils/regexes/isValidPhoneNumber'; import { useToast } from '@rkheftan/harmony-ui'; import { useApi } from '@/hooks/useApi'; +import { replacePersianWithRealNumbers } from '@/utils/replacePersianWithRealNumbers'; export interface ForgettedPasswordInfoProps { forgettedPasswordInfo: string; @@ -46,6 +47,7 @@ export function ForgettedPasswordInfo({ const handleInputChange = (event: React.ChangeEvent) => { let newValue = event.target.value; + newValue = replacePersianWithRealNumbers(newValue); if (newValue.startsWith('09')) { newValue = newValue.substring(1); } @@ -138,7 +140,7 @@ export function ForgettedPasswordInfo({ helperText={inputError ? error : ''} autoFocus slotProps={{ - htmlInput: { dir: 'auto', sx: { lineHeight: 1.5, paddingX: 0 } }, + htmlInput: { dir: 'auto', sx: { lineHeight: 1.5 } }, input: { endAdornment: ( { + const persianDigits = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; + return text + .split('') + .map((char) => { + const index = persianDigits.indexOf(char); + return index === -1 ? char : index.toString(); + }) + .join(''); +};