From d42913bced7a5635cf453445df0d862e1ae53d6c Mon Sep 17 00:00:00 2001 From: Koosha Lahouti Date: Wed, 13 Aug 2025 11:18:12 +0330 Subject: [PATCH] fix: code styles --- public/locales/en/setting.json | 6 ++++-- public/locales/fa/setting.json | 6 ++++-- .../activeDevices/ActiveDevices.tsx | 21 ++++++++++++------- .../components/security/PasswordSecurity.tsx | 5 ++--- .../profile/components/setting/Setting.tsx | 2 +- .../userInformation/PhoneNumber.tsx | 16 ++++++++++++-- .../personalInformation/InfoRowEdit.tsx | 16 +++++++------- .../phoneNumber/PhoneActionButtons.tsx | 1 + .../phoneNumber/PhoneEditForm.tsx | 2 ++ .../socialMedia/SocialMediaMenu.tsx | 1 + 10 files changed, 51 insertions(+), 25 deletions(-) diff --git a/public/locales/en/setting.json b/public/locales/en/setting.json index d8eda93..458690b 100644 --- a/public/locales/en/setting.json +++ b/public/locales/en/setting.json @@ -61,7 +61,8 @@ "errorFetchEmail": "An error occurred while fetching your linked accounts.", "emailIsInvalid": "Email is invalid", "changeEmailFailed": "Change of email failed", - "anErrorOccurred": "An error occurred." + "anErrorOccurred": "An error occurred.", + "saving": "Saving..." }, "active": { @@ -74,7 +75,8 @@ "justNow": "Just now", "notLoggedIn": "You are not logged in", "failFetchActiveSessions": "Failed to fetch active sessions.", - "errorFetch": "An error occurred while fetching your active sessions." + "errorFetch": "An error occurred while fetching your active sessions.", + "deleting": "Deleting..." }, "settings": { diff --git a/public/locales/fa/setting.json b/public/locales/fa/setting.json index 13e6e46..eec7e03 100644 --- a/public/locales/fa/setting.json +++ b/public/locales/fa/setting.json @@ -61,7 +61,8 @@ "errorFetchEmail": "هنگام دریافت حساب‌های پیوند داده شده شما خطایی روی داد.", "emailIsInvalid": "ایمیل نامعتبر است", "changeEmailFailed": "تغییر ایمیل با خطا مواجه شد", - "anErrorOccurred": "خطایی رخ داد" + "anErrorOccurred": "خطایی رخ داد", + "saving": "در حال ذخیره‌سازی..." }, "active": { @@ -74,7 +75,8 @@ "justNow": "همین الان", "notLoggedIn": "شما وارد سیستم نشده‌اید", "failFetchActiveSessions": "دریافت نشست های فعال ناموفق بود.", - "errorFetch": "هنگام دریافت جلسات فعال شما خطایی روی داد." + "errorFetch": "هنگام دریافت جلسات فعال شما خطایی روی داد.", + "deleting": "در حال حذف..." }, "settings": { diff --git a/src/features/profile/components/activeDevices/ActiveDevices.tsx b/src/features/profile/components/activeDevices/ActiveDevices.tsx index 1b3f62b..7590ef7 100644 --- a/src/features/profile/components/activeDevices/ActiveDevices.tsx +++ b/src/features/profile/components/activeDevices/ActiveDevices.tsx @@ -14,6 +14,7 @@ import { CardContainer } from '@/components/CardContainer'; import { PageWrapper } from '../PageWrapper'; import { Icon } from '@rkheftan/harmony-ui'; import apiClient from '@/lib/apiClient'; +import { toLocaleDigits } from '@/utils/persianDigit'; function formatSessionDate( isoDate: string, @@ -30,7 +31,8 @@ function formatSessionDate( return t('active.justNow'); } if (diffInMinutes < 60) { - return t('active.minutesAgo', { count: diffInMinutes }); + const minuteString = t('active.minutesAgo', { count: diffInMinutes }); + return toLocaleDigits(minuteString, lang); } let displayLocale: string; @@ -62,7 +64,11 @@ function formatSessionDate( }; } - return new Intl.DateTimeFormat(displayLocale, options).format(date); + const formattedDate = new Intl.DateTimeFormat(displayLocale, options).format( + date, + ); + + return toLocaleDigits(formattedDate, lang); } interface Device { @@ -214,6 +220,7 @@ export function ActiveDevices() { borderRadius: 1, borderColor: 'error.main', color: 'error.main', + textTransform: 'none', }} disabled={isLoading} > @@ -263,7 +270,7 @@ export function ActiveDevices() { flexBasis: { xs: '100%', sm: 'auto' }, mb: { xs: 1, sm: 0 }, minWidth: { sm: '138px' }, - // order: { xs: 1, sm: 1 }, + order: { xs: 1, sm: 1 }, }} > {device.timeAndDate} @@ -274,9 +281,7 @@ export function ActiveDevices() { display: 'flex', alignItems: 'center', gap: 1, - flexBasis: { xs: '100%', sm: 'auto' }, - mb: { xs: 1, sm: 0 }, - minWidth: { sm: '138px' }, + width: '100%', order: { xs: 2, sm: 2 }, }} > @@ -322,6 +327,7 @@ export function ActiveDevices() { borderColor: 'success.main', whiteSpace: 'nowrap', color: 'success.main', + textTransform: 'none', '&.Mui-disabled': { color: 'success.main', borderColor: 'success.main', @@ -365,6 +371,7 @@ export function ActiveDevices() { alignItems: 'center', justifyContent: 'center', whiteSpace: 'nowrap', + textTransform: 'none', '& .MuiButton-startIcon': { marginRight: 0.5, marginLeft: 0, @@ -372,7 +379,7 @@ export function ActiveDevices() { }} > {loadingDeleteIds.includes(device.id) - ? t('active.deleting...') + ? t('active.deleting') : t('active.deleteDevice')} diff --git a/src/features/profile/components/security/PasswordSecurity.tsx b/src/features/profile/components/security/PasswordSecurity.tsx index 072e210..b628324 100644 --- a/src/features/profile/components/security/PasswordSecurity.tsx +++ b/src/features/profile/components/security/PasswordSecurity.tsx @@ -69,7 +69,7 @@ export function PasswordSecurity() { } : { password, - confirmPassword, + // confirmPassword, }; const res = await apiClient.post(url, payload, { @@ -88,11 +88,9 @@ export function PasswordSecurity() { setCurrentPassword(''); } else { console.error('Password update failed:', res.data?.message); - // optionally show error toast } } catch (err) { console.error('Error updating password:', err); - // optionally show error toast } finally { setLoading(false); } @@ -110,6 +108,7 @@ export function PasswordSecurity() { sx={{ backgroundColor: 'primary.main', color: 'background.paper', + textTransform: 'none', }} > {changePassword diff --git a/src/features/profile/components/setting/Setting.tsx b/src/features/profile/components/setting/Setting.tsx index 41144e9..2179c57 100644 --- a/src/features/profile/components/setting/Setting.tsx +++ b/src/features/profile/components/setting/Setting.tsx @@ -236,7 +236,7 @@ export function Setting() { disabled={loading || isFetching} > {loading - ? t('settings.saving...') + ? t('settings.saving') : isEditing ? t('settings.saveButton') : t('settings.editButton')} diff --git a/src/features/profile/components/userInformation/PhoneNumber.tsx b/src/features/profile/components/userInformation/PhoneNumber.tsx index 1e38410..993664e 100644 --- a/src/features/profile/components/userInformation/PhoneNumber.tsx +++ b/src/features/profile/components/userInformation/PhoneNumber.tsx @@ -8,6 +8,7 @@ import PhoneEditForm from './phoneNumber/PhoneEditForm'; import PhoneActionButtons from './phoneNumber/PhoneActionButtons'; import apiClient from '@/lib/apiClient'; import { CircularProgress, Box, Typography } from '@mui/material'; +import { toLocaleDigits } from '@/utils/persianDigit'; interface Phone { phone: string; @@ -31,7 +32,7 @@ interface ConfirmApiResponse extends ApiResponse { } export function PhoneNumber() { - const { t } = useTranslation('setting'); + const { t, i18n } = useTranslation('setting'); const [isEditing, setIsEditing] = useState(false); const [phoneNumber, setPhoneNumber] = useState(''); const [verificationCode, setVerificationCode] = useState(''); @@ -274,7 +275,18 @@ export function PhoneNumber() { t={t} /> ) : ( - + { + let localPhone = p.withCode; + if (localPhone.startsWith('+98')) { + localPhone = '0' + localPhone.slice(3); + } + return { + ...p, + phone: toLocaleDigits(localPhone, i18n.language), + }; + })} + /> )} diff --git a/src/features/profile/components/userInformation/personalInformation/InfoRowEdit.tsx b/src/features/profile/components/userInformation/personalInformation/InfoRowEdit.tsx index 7d36938..38d1622 100644 --- a/src/features/profile/components/userInformation/personalInformation/InfoRowEdit.tsx +++ b/src/features/profile/components/userInformation/personalInformation/InfoRowEdit.tsx @@ -31,17 +31,17 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) { const fields = [ { name: 'firstName' as const, - label: t('settingForm.name', { ns: 'profileSetting' }), + label: t('settingForm.name', { ns: 'setting' }), value: data.firstName, }, { name: 'lastName' as const, - label: t('settingForm.familyName', { ns: 'profileSetting' }), + label: t('settingForm.familyName', { ns: 'setting' }), value: data.lastName, }, { name: 'nationalCode' as const, - label: t('settingForm.nationalCode', { ns: 'profileSetting' }), + label: t('settingForm.nationalCode', { ns: 'setting' }), value: data.nationalCode, }, ]; @@ -71,11 +71,11 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) { - {t('settingForm.genderPlaceholder', { ns: 'profileSetting' })} + {t('settingForm.genderPlaceholder', { ns: 'setting' })} @@ -113,7 +113,7 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) { renderInput={(params) => ( )} clearOnEscape diff --git a/src/features/profile/components/userInformation/phoneNumber/PhoneActionButtons.tsx b/src/features/profile/components/userInformation/phoneNumber/PhoneActionButtons.tsx index a20e577..0477273 100644 --- a/src/features/profile/components/userInformation/phoneNumber/PhoneActionButtons.tsx +++ b/src/features/profile/components/userInformation/phoneNumber/PhoneActionButtons.tsx @@ -36,6 +36,7 @@ export default function PhoneActionButtons({ bgcolor: isEditing ? 'primary.main' : 'background.default', color: isEditing ? 'primary.contrastText' : 'primary.main', whiteSpace: 'nowrap', + textTransform: 'none', }} > {isEditing diff --git a/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx b/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx index 4875e71..b27d0b4 100644 --- a/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx +++ b/src/features/profile/components/userInformation/phoneNumber/PhoneEditForm.tsx @@ -161,6 +161,7 @@ export default function PhoneEditForm({ sx={{ minWidth: { xs: '100%', sm: 220 }, color: 'primary.main', + textTransform: 'none', }} > {buttonState === 'counting' ? ( @@ -205,6 +206,7 @@ export default function PhoneEditForm({ sx={{ minWidth: { xs: '100%', sm: 220 }, bgcolor: 'primary.main', + textTransform: 'none', }} > {isVerifying ? ( diff --git a/src/features/profile/components/userInformation/socialMedia/SocialMediaMenu.tsx b/src/features/profile/components/userInformation/socialMedia/SocialMediaMenu.tsx index ed0f652..c92f237 100644 --- a/src/features/profile/components/userInformation/socialMedia/SocialMediaMenu.tsx +++ b/src/features/profile/components/userInformation/socialMedia/SocialMediaMenu.tsx @@ -59,6 +59,7 @@ export default function SocialMediaMenu({ alignItems: 'center', whiteSpace: 'nowrap', backgroundColor: open ? 'primary.light' : 'primary.default', + textTransform: 'none', }} > {t('settingForm.addEmailOrSocialButton')}