From 9c9e14842686db914e9ca62104f5c4696d5e97b9 Mon Sep 17 00:00:00 2001 From: Koosha Lahouti Date: Wed, 23 Jul 2025 17:28:25 +0330 Subject: [PATCH] fix: styles and add a country textfield in personal field --- public/locales/fa/profileSetting.json | 7 +- src/App.tsx | 5 + src/components/CardContainer.tsx | 6 +- src/components/CountryFlag.tsx | 2 +- .../components/PersonalInformation.tsx | 322 +++++++++------- .../profile/components/PhoneNumber.tsx | 362 +++++++++--------- .../profile/components/SocialMedia.tsx | 4 +- 7 files changed, 381 insertions(+), 327 deletions(-) diff --git a/public/locales/fa/profileSetting.json b/public/locales/fa/profileSetting.json index ab5053b..b97e10f 100644 --- a/public/locales/fa/profileSetting.json +++ b/public/locales/fa/profileSetting.json @@ -31,6 +31,11 @@ "newEmail": "ایمیل جدید", "dialogHeader": "با فعال‌سازی ایمیل می‌توانید در دفعات بعدی ورود برای ورود از این ایمیل استفاده کنید", "or": "یا", - "emailError": "لطفا یک ایمیل معتبر وارد کنید" + "emailError": "لطفا یک ایمیل معتبر وارد کنید", + "profilePicture": "تصویر حساب کاربری", + "allowedFormat": "فرمت‌های مجاز: PNG، JPEG، GIF (حداکثر ۱۰ مگابایت)", + "uploadPicture": "بارگذاری تصویر", + "phoneNumberText": "شماره تماس جدید شما جایگزین شماره تماس قبلی", + "verb": "خواهد شد" } } diff --git a/src/App.tsx b/src/App.tsx index 0172e04..47481fa 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -14,6 +14,7 @@ import { LanguageManager } from './components/LanguageManager'; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> f1620b6 (fix: issue in user profile) @@ -30,6 +31,9 @@ import { UserForm } from './features/profile/components/UserForm'; >>>>>>> 60c6dc1 (fix: styles) ======= >>>>>>> afc7ff8 (fix: translation and styles) +======= +import { UserForm } from './features/profile/components/UserForm'; +>>>>>>> b327e7a (fix: styles and add a country textfield in personal field) function App() { const { t } = useTranslation(); @@ -37,6 +41,7 @@ function App() { <> +
{t('helloWorld')} (null); + const handleChange = (e: ChangeEvent) => { const { name, value } = e.target; setData((prev) => ({ @@ -56,16 +61,22 @@ export function PersonalInformation() { return value && value.trim() !== '' ? value : 'تعیین نشده'; }; + const handleImageChange = (e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (file) { + const reader = new FileReader(); + reader.onload = () => { + setUploadedImageUrl(reader.result as string); + }; + reader.readAsDataURL(file); + } + }; + + const initials = `${data.firstName?.trim()[0] || ''}‌${data.lastName?.trim()[0] || ''}`; + return ( setIsEditing(false)} size="large" - sx={{ - color: '#2979FF', - width: '43px', - }} + sx={{ color: '#2979FF', width: '43px' }} > {t('settingForm.rejectButton')} @@ -109,142 +117,178 @@ export function PersonalInformation() { > - - {isEditing ? ( - - ) : ( - + - - {`${t('settingForm.name')} و ${t('settingForm.familyName')}`} + {initials} + + + + {t('settingForm.profilePicture')} - - - - - {displayValue(data.firstName + ' ' + data.lastName)} - + + {t('settingForm.allowedFormat')} + + + - )} - + + )} - - {isEditing ? ( - + + {isEditing ? ( + + ) : ( + + + {`${t('settingForm.name')} و ${t('settingForm.familyName')}`} + + + {initials} + + {displayValue(data.firstName + ' ' + data.lastName)} + + + + )} + + + + {isEditing ? ( + + ) : ( + + + {t('settingForm.country')} + + + + )} + + + + {isEditing ? ( + + + + ) : ( + + + {t('settingForm.gender')} + + + {displayValue(data.gender)} + + + )} + + + + {isEditing ? ( + + ) : ( + + + {t('settingForm.nationalCode')} + + + {displayValue(data.nationalCode)} + + + )} + + {isEditing && ( + + setData((prev) => ({ + ...prev, + country: newValue || '', + })) + } + renderOption={(props, option) => ( + + + + )} + renderInput={(params) => ( + + )} /> - ) : ( - - - {t('settingForm.country')} - - - - )} - - - - {isEditing ? ( - - - - ) : ( - - - {t('settingForm.gender')} - - - {displayValue(data.gender)} - - - )} - - - - {isEditing ? ( - - ) : ( - - - {t('settingForm.nationalCode')}{' '} - - - {displayValue(data.nationalCode)} - - )} diff --git a/src/features/profile/components/PhoneNumber.tsx b/src/features/profile/components/PhoneNumber.tsx index 3e40c18..b185a00 100644 --- a/src/features/profile/components/PhoneNumber.tsx +++ b/src/features/profile/components/PhoneNumber.tsx @@ -23,7 +23,9 @@ export function PhoneNumber() { const [isVerifying, setIsVerifying] = useState(false); const [isVerified, setIsVerified] = useState(false); - const phones = [{ phone: '09123456789', time: '۱ ماه پیش' }]; + const phones = [ + { phone: '09123456789', time: '۱ ماه پیش', withCode: '+989123456789' }, + ]; const handleSendCode = () => { setButtonState('counting'); @@ -56,210 +58,206 @@ export function PhoneNumber() { }; return ( - <> - - - - {isEditing && ( - - )} + + + {isEditing && ( + )} + + + } + > + {isEditing ? ( + + + + {t('settingForm.editPhoneNumber')} + + + {t('settingForm.phoneNumberText')}( + {phones.map((p) => p.withCode)}){t('settingForm.verb')} + - } - > - {isEditing ? ( - - - - {t('settingForm.editPhoneNumber')} - - - شماره تماس جدید شما جایگزین شماره تماس قبلی(+989123456789) - خواهد شد. - - + + setButtonState('default')} + sx={{ mr: 1 }} + > + + + ) : null, + }} + /> + + {isVerified ? ( + + + {t('settingForm.successButton')} + + ) : ( + + )} + + + {buttonState === 'counting' && !isVerified && ( setButtonState('default')} - > - - - ) : null, - }} /> - - {isVerified ? ( - - - {t('profileSetting.successButton')} - - ) : ( - - )} - - - {buttonState === 'counting' && !isVerified && ( - - - - - )} - - ) : ( - - {phones.map((item, index) => ( - - - {item.phone} - - - {item.time} - - - ))} - - )} - - - + {isVerifying ? ( + + + + ) : ( + t('settingForm.checkCode') + )} + + + )} + + ) : ( + + {phones.map((item, index) => ( + + + {item.phone} + + + {item.time} + + + ))} + + )} + + ); } diff --git a/src/features/profile/components/SocialMedia.tsx b/src/features/profile/components/SocialMedia.tsx index 57cc939..5631bda 100644 --- a/src/features/profile/components/SocialMedia.tsx +++ b/src/features/profile/components/SocialMedia.tsx @@ -54,10 +54,10 @@ export function SocialMedia() { return (