From 3a313133584df837198d26e9535a10ca6bb63071 Mon Sep 17 00:00:00 2001 From: Sajad Mirjalili Date: Fri, 26 Sep 2025 12:32:50 +0330 Subject: [PATCH] fix: phone number disable state in profile --- public/locales/en/setting.json | 2 +- .../components/CountryCodeSelector.tsx | 18 +++++- .../phoneNumber/PhoneEditForm.tsx | 58 ++++++++++++------- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/public/locales/en/setting.json b/public/locales/en/setting.json index 16fc6fe..2c3314c 100644 --- a/public/locales/en/setting.json +++ b/public/locales/en/setting.json @@ -23,7 +23,7 @@ "woman": "Female", "genderPlaceholder": "Male", "newPhoneNumber": "New phone number", - "verificationCodeButton": "Send verification code", + "verificationCodeButton": "Send code", "verificationCode": "Verification code", "checkCode": "Check code", "successButton": "Confirmed", diff --git a/src/features/authentication/components/CountryCodeSelector.tsx b/src/features/authentication/components/CountryCodeSelector.tsx index f0595d1..652775c 100644 --- a/src/features/authentication/components/CountryCodeSelector.tsx +++ b/src/features/authentication/components/CountryCodeSelector.tsx @@ -23,6 +23,7 @@ interface CountryCodeSelectorProps { onChange: (newValue: CountryCode) => void; menuAnchor: HTMLElement | null; onCloseFocusRef: RefObject; + disabled?: boolean; } /** @@ -35,6 +36,7 @@ export function CountryCodeSelector({ onChange, menuAnchor, onCloseFocusRef, + disabled = false, }: CountryCodeSelectorProps) { const [anchorEl, setAnchorEl] = useState(null); const [searchTerm, setSearchTerm] = useState(''); @@ -47,6 +49,7 @@ export function CountryCodeSelector({ countries.find((c) => c.phone === value) || countries[0]; const handleClick = () => { + if (disabled) return; setAnchorEl(menuAnchor); }; @@ -112,14 +115,22 @@ export function CountryCodeSelector({ pl: show ? 0.25 : 0, '&:hover': { - cursor: 'pointer', + cursor: disabled ? 'default' : 'pointer', }, }} > {/* This inner Box prevents the content from being squeezed during the transition */} - + - + {value} @@ -131,6 +142,7 @@ export function CountryCodeSelector({ width: '1.5rem', marginTop: '-2px', marginRight: '4px', + opacity: disabled ? 0.4 : 1, }} /> diff --git a/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx b/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx index 56252a8..bee1ae4 100644 --- a/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx +++ b/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx @@ -37,7 +37,7 @@ export default function PhoneEditForm({ phoneNumberError, verificationCodeError, }: PhoneEditFormProps) { - const { t } = useTranslation('setting'); + const { t, i18n } = useTranslation('setting'); const textFieldRef = useRef(null); const inputRef = useRef(null); @@ -72,6 +72,7 @@ export default function PhoneEditForm({ fullWidth name="phoneNumber" label={t('settingForm.newPhoneNumber')} + disabled={isCodeSent} type="tel" value={phoneNumber} ref={textFieldRef} @@ -81,35 +82,50 @@ export default function PhoneEditForm({ helperText={phoneNumberError} onChange={(e) => setPhoneNumber(e.target.value)} placeholder="09123456789" - InputProps={{ - endAdornment: - buttonState === 'counting' ? ( - - { - setButtonState('default'); - setVerificationCode(''); - setIsCodeSent(false); - }} - edge="end" - > - + { + setButtonState('default'); + setVerificationCode(''); + setIsCodeSent(false); + }} + edge="end" + > + + + + ) : ( + i18n.dir() === 'rtl' && ( + - - - ) : ( + ) + ), + startAdornment: i18n.dir() === 'ltr' && ( ), + }, }} />