From 8bef6bb9ee49a6a09ade4fe345def3d4fb1b1c5a Mon Sep 17 00:00:00 2001 From: Koosha Lahouti Date: Sun, 20 Jul 2025 17:19:22 +0330 Subject: [PATCH] fix: translation and styles --- public/locales/fa/profileSetting.json | 36 +++++++++ src/App.tsx | 4 +- src/components/CountryFlag.tsx | 46 ++++++++++++ .../components/PersonalInformation.tsx | 73 ++++++++++++------- .../profile/components/PhoneNumber.tsx | 65 ++++++++++------- .../profile/components/SocialMedia.tsx | 41 ++++++----- 6 files changed, 193 insertions(+), 72 deletions(-) create mode 100644 public/locales/fa/profileSetting.json create mode 100644 src/components/CountryFlag.tsx diff --git a/public/locales/fa/profileSetting.json b/public/locales/fa/profileSetting.json new file mode 100644 index 0000000..ab5053b --- /dev/null +++ b/public/locales/fa/profileSetting.json @@ -0,0 +1,36 @@ +{ + "settingForm": { + "titlePersonalInfo": "اطلاعات شخصی من", + "descriptionPersonalInfo": "این اطلاعات شما صرفا برای احراز هویت شما است و نزد هارمونی باقی می‌ماند", + "titlePhoneNumber": "شماره تماس من", + "descriptionPhoneNumber": "این اطلاعات شما صرفا برای احراز هویت شما است و نزد هارمونی باقی می‌ماند", + "titleSocial": "ایمیل و شبکه های اجتماعی من", + "descriptionSocial": "این اطلاعات شما صرفاً برای احراز هویت شما است و نزد هارمونی باقی می‌ماند", + "rejectButton": "لغو", + "saveButton": "ذخیره", + "editButton": "ویرایش", + "editPhoneNumber": "تغییر شماره تماس", + "addEmailOrSocialButton": "افزودن ایمیل / سوشال", + "addEmailButton": "افزودن ایمیل", + "name": "نام", + "familyName": "نام خانوادگی", + "country": "کشور", + "gender": "جنسیت", + "nationalCode": "کد ملی", + "man": "مرد", + "woman": "زن", + "genderPlaceholder": "مرد", + "newPhoneNumber": "شماره تماس جدید", + "verificationCodeButton": "ارسال کد تایید", + "verificationCode": "کد تایید", + "checkCode": "بررسی کد", + "successButton": "تایید شد", + "email": "ایمیل", + "apple": "اپل", + "google": "گوگل", + "newEmail": "ایمیل جدید", + "dialogHeader": "با فعال‌سازی ایمیل می‌توانید در دفعات بعدی ورود برای ورود از این ایمیل استفاده کنید", + "or": "یا", + "emailError": "لطفا یک ایمیل معتبر وارد کنید" + } +} diff --git a/src/App.tsx b/src/App.tsx index 76660a8..0172e04 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -13,6 +13,7 @@ import { LanguageManager } from './components/LanguageManager'; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> f1620b6 (fix: issue in user profile) @@ -27,6 +28,8 @@ import { UserProfileForm } from './features/profile/components/UserProfileForm'; ======= import { UserForm } from './features/profile/components/UserForm'; >>>>>>> 60c6dc1 (fix: styles) +======= +>>>>>>> afc7ff8 (fix: translation and styles) function App() { const { t } = useTranslation(); @@ -34,7 +37,6 @@ function App() { <> -
{t('helloWorld')} + {country} + {country} + + ); +} diff --git a/src/features/profile/components/PersonalInformation.tsx b/src/features/profile/components/PersonalInformation.tsx index 9975735..8905e48 100644 --- a/src/features/profile/components/PersonalInformation.tsx +++ b/src/features/profile/components/PersonalInformation.tsx @@ -10,21 +10,27 @@ import { } from '@mui/material'; import { useState, type ChangeEvent } from 'react'; import { CardContainer } from '@/components/CardContainer'; +import { CountryFlag } from '@/components/CountryFlag'; +import { useTranslation } from 'react-i18next'; +import { Profile } from 'iconsax-react'; export function PersonalInformation() { + const { t } = useTranslation('profileSetting'); const [isEditing, setIsEditing] = useState(false); const [gender, setGender] = useState(''); - const [data, setData] = useState({ + const initialData = { firstName: 'محمد حسین', lastName: 'برزه‌گر', + country: 'قطر', gender: 'مرد', nationalCode: '', - }); - + }; + const [data, setData] = useState(initialData); const handleChange = (e: ChangeEvent) => { + const { name, value } = e.target; setData((prev) => ({ ...prev, - [e.target.name]: e.target.value, + [name]: value, })); }; @@ -62,8 +68,8 @@ export function PersonalInformation() { }} > @@ -77,7 +83,7 @@ export function PersonalInformation() { width: '43px', }} > - لغو + {t('settingForm.rejectButton')} )} } @@ -115,24 +122,30 @@ export function PersonalInformation() { name="firstName" value={data.firstName} onChange={handleChange} - label="نام" + label={t('settingForm.name')} /> ) : ( - نام - - - {displayValue(data.firstName)} + {`${t('settingForm.name')} و ${t('settingForm.familyName')}`} + + + + + {displayValue(data.firstName + ' ' + data.lastName)} + + )} @@ -144,7 +157,7 @@ export function PersonalInformation() { name="lastName" value={data.lastName} onChange={handleChange} - label="نام خانوادگی" + label={t('settingForm.familyName')} /> ) : ( - نام خانوادگی - - - {displayValue(data.lastName)} + {t('settingForm.country')} + )} @@ -172,9 +183,21 @@ export function PersonalInformation() { value={gender} onChange={handleChangeGender} displayEmpty + renderValue={(selected) => { + if (!selected) { + return ( + + {t('settingForm.genderPlaceholder')} + + ); + } + return selected === 'male' + ? t('settingForm.man') + : t('settingForm.woman'); + }} > - زن - مرد + {t('settingForm.man')} + {t('settingForm.woman')} ) : ( @@ -188,7 +211,7 @@ export function PersonalInformation() { }} > - جنسیت + {t('settingForm.gender')} {displayValue(data.gender)} @@ -204,7 +227,7 @@ export function PersonalInformation() { name="nationalCode" value={data.nationalCode} onChange={handleChange} - label="کد ملی" + label={t('settingForm.nationalCode')} /> ) : ( - کد ملی + {t('settingForm.nationalCode')}{' '} {displayValue(data.nationalCode)} diff --git a/src/features/profile/components/PhoneNumber.tsx b/src/features/profile/components/PhoneNumber.tsx index 8e08d09..3e40c18 100644 --- a/src/features/profile/components/PhoneNumber.tsx +++ b/src/features/profile/components/PhoneNumber.tsx @@ -7,11 +7,13 @@ import { GlobalStyles, } from '@mui/material'; import { Edit, Refresh, TickCircle } from 'iconsax-react'; -import { useState, useEffect, type ChangeEvent } from 'react'; +import { useState, type ChangeEvent } from 'react'; import { CardContainer } from '@/components/CardContainer'; import { CountDownTimer } from '@/components/CountDownTimer'; +import { useTranslation } from 'react-i18next'; export function PhoneNumber() { + const { t } = useTranslation('profileSetting'); const [isEditing, setIsEditing] = useState(false); const [phoneNumber, setPhoneNumber] = useState(''); const [verificationCode, setVerificationCode] = useState(''); @@ -21,6 +23,8 @@ export function PhoneNumber() { const [isVerifying, setIsVerifying] = useState(false); const [isVerified, setIsVerified] = useState(false); + const phones = [{ phone: '09123456789', time: '۱ ماه پیش' }]; + const handleSendCode = () => { setButtonState('counting'); setIsVerified(false); @@ -71,8 +75,8 @@ export function PhoneNumber() { }} > @@ -83,7 +87,7 @@ export function PhoneNumber() { size="large" sx={{ color: '#2979FF', width: '43px' }} > - لغو + {t('settingForm.rejectButton')} )} } @@ -108,7 +114,7 @@ export function PhoneNumber() { - تغییر شماره تماس + {t('settingForm.editPhoneNumber')} شماره تماس جدید شما جایگزین شماره تماس قبلی(+989123456789) @@ -127,7 +133,7 @@ export function PhoneNumber() { - تایید شد + {t('profileSetting.successButton')} ) : ( )} @@ -192,8 +198,8 @@ export function PhoneNumber() { > ) : ( - 'بررسی کد' + t('settingForm.checkCode') )} )} ) : ( - - - 09909366045 - - - ۱ ماه پیش - + + {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 cd543b5..4db2ee7 100644 --- a/src/features/profile/components/SocialMedia.tsx +++ b/src/features/profile/components/SocialMedia.tsx @@ -23,8 +23,10 @@ import { } from '@mui/material'; import React, { useState } from 'react'; import { CardContainer } from '@/components/CardContainer'; +import { useTranslation } from 'react-i18next'; export function SocialMedia() { + const { t } = useTranslation('profileSetting'); const [openDialog, setOpenDialog] = useState(false); const [emailInput, setEmailInput] = useState(''); const [emailError, setEmailError] = useState(false); @@ -45,8 +47,8 @@ export function SocialMedia() { }; const emailList = [ - { email: 'emailtemp@email.com', provider: 'email' }, - { email: 'emailtemp@gmail.com', provider: 'google' }, + { email: 'emailtemp@email.com', provider: 'email', time: '1 ماه پیش' }, + { email: 'emailtemp@gmail.com', provider: 'google', time: '1 ماه پیش' }, ]; return ( @@ -59,8 +61,8 @@ export function SocialMedia() { }} > - ایمیل + {t('settingForm.email')} { @@ -113,7 +115,7 @@ export function SocialMedia() { - گوگل + {t('settingForm.google')} { @@ -124,7 +126,7 @@ export function SocialMedia() { - اپل + {t('settingForm.apple')} @@ -180,7 +182,7 @@ export function SocialMedia() { {item.email} - ۱ ماه پیش + {item.time} @@ -211,7 +213,7 @@ export function SocialMedia() { - افزودن ایمیل + {t('settingForm.addEmailButton')} - ایمیل جدید + + {t('settingForm.newEmail')} + - با فعال‌سازی ایمیل می‌توانید در دفعات بعدی ورود برای ورود از - این ایمیل استفاده کنید + {t('settingForm.dialogHeader')} - ارسال کد تایید + {t('settingForm.verificationCodeButton')} - یا + {t('settingForm.or')} @@ -278,7 +281,7 @@ export function SocialMedia() { }} > - گوگل + {t('settingForm.google')}