fix: code styles

This commit is contained in:
Koosha Lahouti
2025-08-13 11:18:12 +03:30
parent cd4113b75a
commit d42913bced
10 changed files with 51 additions and 25 deletions

View File

@@ -61,7 +61,8 @@
"errorFetchEmail": "An error occurred while fetching your linked accounts.", "errorFetchEmail": "An error occurred while fetching your linked accounts.",
"emailIsInvalid": "Email is invalid", "emailIsInvalid": "Email is invalid",
"changeEmailFailed": "Change of email failed", "changeEmailFailed": "Change of email failed",
"anErrorOccurred": "An error occurred." "anErrorOccurred": "An error occurred.",
"saving": "Saving..."
}, },
"active": { "active": {
@@ -74,7 +75,8 @@
"justNow": "Just now", "justNow": "Just now",
"notLoggedIn": "You are not logged in", "notLoggedIn": "You are not logged in",
"failFetchActiveSessions": "Failed to fetch active sessions.", "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": { "settings": {

View File

@@ -61,7 +61,8 @@
"errorFetchEmail": "هنگام دریافت حساب‌های پیوند داده شده شما خطایی روی داد.", "errorFetchEmail": "هنگام دریافت حساب‌های پیوند داده شده شما خطایی روی داد.",
"emailIsInvalid": "ایمیل نامعتبر است", "emailIsInvalid": "ایمیل نامعتبر است",
"changeEmailFailed": "تغییر ایمیل با خطا مواجه شد", "changeEmailFailed": "تغییر ایمیل با خطا مواجه شد",
"anErrorOccurred": "خطایی رخ داد" "anErrorOccurred": "خطایی رخ داد",
"saving": "در حال ذخیره‌سازی..."
}, },
"active": { "active": {
@@ -74,7 +75,8 @@
"justNow": "همین الان", "justNow": "همین الان",
"notLoggedIn": "شما وارد سیستم نشده‌اید", "notLoggedIn": "شما وارد سیستم نشده‌اید",
"failFetchActiveSessions": "دریافت نشست های فعال ناموفق بود.", "failFetchActiveSessions": "دریافت نشست های فعال ناموفق بود.",
"errorFetch": "هنگام دریافت جلسات فعال شما خطایی روی داد." "errorFetch": "هنگام دریافت جلسات فعال شما خطایی روی داد.",
"deleting": "در حال حذف..."
}, },
"settings": { "settings": {

View File

@@ -14,6 +14,7 @@ import { CardContainer } from '@/components/CardContainer';
import { PageWrapper } from '../PageWrapper'; import { PageWrapper } from '../PageWrapper';
import { Icon } from '@rkheftan/harmony-ui'; import { Icon } from '@rkheftan/harmony-ui';
import apiClient from '@/lib/apiClient'; import apiClient from '@/lib/apiClient';
import { toLocaleDigits } from '@/utils/persianDigit';
function formatSessionDate( function formatSessionDate(
isoDate: string, isoDate: string,
@@ -30,7 +31,8 @@ function formatSessionDate(
return t('active.justNow'); return t('active.justNow');
} }
if (diffInMinutes < 60) { if (diffInMinutes < 60) {
return t('active.minutesAgo', { count: diffInMinutes }); const minuteString = t('active.minutesAgo', { count: diffInMinutes });
return toLocaleDigits(minuteString, lang);
} }
let displayLocale: string; 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 { interface Device {
@@ -214,6 +220,7 @@ export function ActiveDevices() {
borderRadius: 1, borderRadius: 1,
borderColor: 'error.main', borderColor: 'error.main',
color: 'error.main', color: 'error.main',
textTransform: 'none',
}} }}
disabled={isLoading} disabled={isLoading}
> >
@@ -263,7 +270,7 @@ export function ActiveDevices() {
flexBasis: { xs: '100%', sm: 'auto' }, flexBasis: { xs: '100%', sm: 'auto' },
mb: { xs: 1, sm: 0 }, mb: { xs: 1, sm: 0 },
minWidth: { sm: '138px' }, minWidth: { sm: '138px' },
// order: { xs: 1, sm: 1 }, order: { xs: 1, sm: 1 },
}} }}
> >
{device.timeAndDate} {device.timeAndDate}
@@ -274,9 +281,7 @@ export function ActiveDevices() {
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
gap: 1, gap: 1,
flexBasis: { xs: '100%', sm: 'auto' }, width: '100%',
mb: { xs: 1, sm: 0 },
minWidth: { sm: '138px' },
order: { xs: 2, sm: 2 }, order: { xs: 2, sm: 2 },
}} }}
> >
@@ -322,6 +327,7 @@ export function ActiveDevices() {
borderColor: 'success.main', borderColor: 'success.main',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
color: 'success.main', color: 'success.main',
textTransform: 'none',
'&.Mui-disabled': { '&.Mui-disabled': {
color: 'success.main', color: 'success.main',
borderColor: 'success.main', borderColor: 'success.main',
@@ -365,6 +371,7 @@ export function ActiveDevices() {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
textTransform: 'none',
'& .MuiButton-startIcon': { '& .MuiButton-startIcon': {
marginRight: 0.5, marginRight: 0.5,
marginLeft: 0, marginLeft: 0,
@@ -372,7 +379,7 @@ export function ActiveDevices() {
}} }}
> >
{loadingDeleteIds.includes(device.id) {loadingDeleteIds.includes(device.id)
? t('active.deleting...') ? t('active.deleting')
: t('active.deleteDevice')} : t('active.deleteDevice')}
</Button> </Button>
</Box> </Box>

View File

@@ -69,7 +69,7 @@ export function PasswordSecurity() {
} }
: { : {
password, password,
confirmPassword, // confirmPassword,
}; };
const res = await apiClient.post(url, payload, { const res = await apiClient.post(url, payload, {
@@ -88,11 +88,9 @@ export function PasswordSecurity() {
setCurrentPassword(''); setCurrentPassword('');
} else { } else {
console.error('Password update failed:', res.data?.message); console.error('Password update failed:', res.data?.message);
// optionally show error toast
} }
} catch (err) { } catch (err) {
console.error('Error updating password:', err); console.error('Error updating password:', err);
// optionally show error toast
} finally { } finally {
setLoading(false); setLoading(false);
} }
@@ -110,6 +108,7 @@ export function PasswordSecurity() {
sx={{ sx={{
backgroundColor: 'primary.main', backgroundColor: 'primary.main',
color: 'background.paper', color: 'background.paper',
textTransform: 'none',
}} }}
> >
{changePassword {changePassword

View File

@@ -236,7 +236,7 @@ export function Setting() {
disabled={loading || isFetching} disabled={loading || isFetching}
> >
{loading {loading
? t('settings.saving...') ? t('settings.saving')
: isEditing : isEditing
? t('settings.saveButton') ? t('settings.saveButton')
: t('settings.editButton')} : t('settings.editButton')}

View File

@@ -8,6 +8,7 @@ import PhoneEditForm from './phoneNumber/PhoneEditForm';
import PhoneActionButtons from './phoneNumber/PhoneActionButtons'; import PhoneActionButtons from './phoneNumber/PhoneActionButtons';
import apiClient from '@/lib/apiClient'; import apiClient from '@/lib/apiClient';
import { CircularProgress, Box, Typography } from '@mui/material'; import { CircularProgress, Box, Typography } from '@mui/material';
import { toLocaleDigits } from '@/utils/persianDigit';
interface Phone { interface Phone {
phone: string; phone: string;
@@ -31,7 +32,7 @@ interface ConfirmApiResponse extends ApiResponse {
} }
export function PhoneNumber() { export function PhoneNumber() {
const { t } = useTranslation('setting'); const { t, i18n } = useTranslation('setting');
const [isEditing, setIsEditing] = useState(false); const [isEditing, setIsEditing] = useState(false);
const [phoneNumber, setPhoneNumber] = useState(''); const [phoneNumber, setPhoneNumber] = useState('');
const [verificationCode, setVerificationCode] = useState(''); const [verificationCode, setVerificationCode] = useState('');
@@ -274,7 +275,18 @@ export function PhoneNumber() {
t={t} t={t}
/> />
) : ( ) : (
<PhoneDisplay phones={phones} /> <PhoneDisplay
phones={phones.map((p) => {
let localPhone = p.withCode;
if (localPhone.startsWith('+98')) {
localPhone = '0' + localPhone.slice(3);
}
return {
...p,
phone: toLocaleDigits(localPhone, i18n.language),
};
})}
/>
)} )}
</CardContainer> </CardContainer>
</PageWrapper> </PageWrapper>

View File

@@ -31,17 +31,17 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) {
const fields = [ const fields = [
{ {
name: 'firstName' as const, name: 'firstName' as const,
label: t('settingForm.name', { ns: 'profileSetting' }), label: t('settingForm.name', { ns: 'setting' }),
value: data.firstName, value: data.firstName,
}, },
{ {
name: 'lastName' as const, name: 'lastName' as const,
label: t('settingForm.familyName', { ns: 'profileSetting' }), label: t('settingForm.familyName', { ns: 'setting' }),
value: data.lastName, value: data.lastName,
}, },
{ {
name: 'nationalCode' as const, name: 'nationalCode' as const,
label: t('settingForm.nationalCode', { ns: 'profileSetting' }), label: t('settingForm.nationalCode', { ns: 'setting' }),
value: data.nationalCode, value: data.nationalCode,
}, },
]; ];
@@ -71,11 +71,11 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) {
<Box sx={{ width: { xs: '100%', sm: '48%', md: 'calc(50% - 8px)' } }}> <Box sx={{ width: { xs: '100%', sm: '48%', md: 'calc(50% - 8px)' } }}>
<FormControl fullWidth> <FormControl fullWidth>
<InputLabel> <InputLabel>
{t('settingForm.genderPlaceholder', { ns: 'profileSetting' })} {t('settingForm.genderPlaceholder', { ns: 'setting' })}
</InputLabel> </InputLabel>
<Select <Select
value={data.gender === Gender.None ? '' : data.gender} value={data.gender === Gender.None ? '' : data.gender}
label={t('settingForm.genderPlaceholder', { ns: 'profileSetting' })} label={t('settingForm.genderPlaceholder', { ns: 'setting' })}
onChange={(e) => onChange={(e) =>
setData((prev) => ({ setData((prev) => ({
...prev, ...prev,
@@ -84,10 +84,10 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) {
} }
> >
<MenuItem value={Gender.Male}> <MenuItem value={Gender.Male}>
{t('settingForm.man', { ns: 'profileSetting' })} {t('settingForm.man', { ns: 'setting' })}
</MenuItem> </MenuItem>
<MenuItem value={Gender.Female}> <MenuItem value={Gender.Female}>
{t('settingForm.woman', { ns: 'profileSetting' })} {t('settingForm.woman', { ns: 'setting' })}
</MenuItem> </MenuItem>
</Select> </Select>
</FormControl> </FormControl>
@@ -113,7 +113,7 @@ export function InfoRowEdit({ data, setData }: InfoRowEditProps) {
renderInput={(params) => ( renderInput={(params) => (
<TextField <TextField
{...params} {...params}
label={t('settingForm.country', { ns: 'profileSetting' })} label={t('settingForm.country', { ns: 'setting' })}
/> />
)} )}
clearOnEscape clearOnEscape

View File

@@ -36,6 +36,7 @@ export default function PhoneActionButtons({
bgcolor: isEditing ? 'primary.main' : 'background.default', bgcolor: isEditing ? 'primary.main' : 'background.default',
color: isEditing ? 'primary.contrastText' : 'primary.main', color: isEditing ? 'primary.contrastText' : 'primary.main',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
textTransform: 'none',
}} }}
> >
{isEditing {isEditing

View File

@@ -161,6 +161,7 @@ export default function PhoneEditForm({
sx={{ sx={{
minWidth: { xs: '100%', sm: 220 }, minWidth: { xs: '100%', sm: 220 },
color: 'primary.main', color: 'primary.main',
textTransform: 'none',
}} }}
> >
{buttonState === 'counting' ? ( {buttonState === 'counting' ? (
@@ -205,6 +206,7 @@ export default function PhoneEditForm({
sx={{ sx={{
minWidth: { xs: '100%', sm: 220 }, minWidth: { xs: '100%', sm: 220 },
bgcolor: 'primary.main', bgcolor: 'primary.main',
textTransform: 'none',
}} }}
> >
{isVerifying ? ( {isVerifying ? (

View File

@@ -59,6 +59,7 @@ export default function SocialMediaMenu({
alignItems: 'center', alignItems: 'center',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
backgroundColor: open ? 'primary.light' : 'primary.default', backgroundColor: open ? 'primary.light' : 'primary.default',
textTransform: 'none',
}} }}
> >
<Box component="span">{t('settingForm.addEmailOrSocialButton')}</Box> <Box component="span">{t('settingForm.addEmailOrSocialButton')}</Box>