diff --git a/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx b/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx index 882122c..f8acdca 100644 --- a/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx +++ b/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx @@ -11,10 +11,11 @@ import { Edit2, TickCircle } from 'iconsax-react'; import { CountDownTimer } from '@/components/CountDownTimer'; import { Icon } from '@rkheftan/harmony-ui'; import { type PhoneEditFormProps } from '@/features/profile/types/settingsType'; -import { useRef } from 'react'; +import { useRef, type ChangeEvent } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { CountryCodeSelector } from '@/components/CountryCodeSelector'; import { LTRTypography } from '@/components/common/LTRTypography'; +import { replacePersianWithRealNumbers } from '@/utils/replacePersianWithRealNumbers'; export default function PhoneEditForm({ phoneNumber, @@ -42,6 +43,21 @@ export default function PhoneEditForm({ const textFieldRef = useRef(null); const inputRef = useRef(null); + const handleChange = (event: ChangeEvent) => { + const value = replacePersianWithRealNumbers(event.target.value); + console.log(value); + + setPhoneNumber(value); + }; + + const onSendCode = () => { + if (countryCode === '+98' && phoneNumber.startsWith('09')) { + const newValue = phoneNumber.substring(1); + setPhoneNumber(newValue); + } + handleSendCode(); + }; + return ( @@ -70,6 +86,7 @@ export default function PhoneEditForm({ > handleBlur('phoneNumber')} error={!!phoneNumberError} helperText={phoneNumberError} - onChange={(e) => setPhoneNumber(e.target.value)} + onChange={handleChange} placeholder="09123456789" slotProps={{ input: { - endAdornment: isCodeSent ? ( - - { - setButtonState('default'); - setVerificationCode(''); - setIsCodeSent(false); - }} - edge="end" - > - - - - ) : ( - i18n.dir() === 'rtl' && ( + endAdornment: + i18n.dir() === 'rtl' ? ( - ) - ), - startAdornment: i18n.dir() === 'ltr' && ( - - ), + ) : ( + isCodeSent && ( + + { + setButtonState('default'); + setVerificationCode(''); + setIsCodeSent(false); + }} + edge="end" + > + + + + ) + ), + startAdornment: + i18n.dir() === 'ltr' ? ( + + ) : ( + isCodeSent && ( + + { + setButtonState('default'); + setVerificationCode(''); + setIsCodeSent(false); + }} + edge="end" + > + + + + ) + ), }, }} /> @@ -144,7 +183,8 @@ export default function PhoneEditForm({