fix: settings defualt values
This commit is contained in:
@@ -100,8 +100,7 @@
|
|||||||
"dark": "Dark",
|
"dark": "Dark",
|
||||||
"language": "زبان/language",
|
"language": "زبان/language",
|
||||||
"calendar": "Calendar and date format",
|
"calendar": "Calendar and date format",
|
||||||
"solar": "Solar",
|
"jalali": "jalali",
|
||||||
"lunar": "Lunar",
|
|
||||||
"christian": "Christian",
|
"christian": "Christian",
|
||||||
"iran": "Iran",
|
"iran": "Iran",
|
||||||
"saving": "Saving...",
|
"saving": "Saving...",
|
||||||
|
|||||||
@@ -100,8 +100,7 @@
|
|||||||
"dark": "تاریک",
|
"dark": "تاریک",
|
||||||
"language": "زبان/language",
|
"language": "زبان/language",
|
||||||
"calendar": "فرمت تقویم و تاریخ",
|
"calendar": "فرمت تقویم و تاریخ",
|
||||||
"solar": "شمسی",
|
"jalali": "شمسی",
|
||||||
"lunar": "قمری",
|
|
||||||
"christian": "میلادی",
|
"christian": "میلادی",
|
||||||
"iran": "ایران",
|
"iran": "ایران",
|
||||||
"saving": "در حال ذخیرهسازی...",
|
"saving": "در حال ذخیرهسازی...",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { saveSettings } from '../api/settingsApi';
|
|||||||
import { useProfile } from '../hooks/useProfile';
|
import { useProfile } from '../hooks/useProfile';
|
||||||
|
|
||||||
type ThemeMode = 'light' | 'dark';
|
type ThemeMode = 'light' | 'dark';
|
||||||
type CalendarType = 'christian' | 'solar' | 'lunar';
|
type CalendarType = 'christian' | 'jalali';
|
||||||
|
|
||||||
interface SettingsState {
|
interface SettingsState {
|
||||||
language: string;
|
language: string;
|
||||||
@@ -33,9 +33,8 @@ const languageOptions = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const calendarOptions: { key: CalendarType; apiValue: number }[] = [
|
const calendarOptions: { key: CalendarType; apiValue: number }[] = [
|
||||||
{ key: 'christian', apiValue: 1 },
|
{ key: 'jalali', apiValue: 1 },
|
||||||
{ key: 'solar', apiValue: 2 },
|
{ key: 'christian', apiValue: 2 },
|
||||||
{ key: 'lunar', apiValue: 3 },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const themeApiMap: Record<ThemeMode, number> = { light: 1, dark: 2 };
|
const themeApiMap: Record<ThemeMode, number> = { light: 1, dark: 2 };
|
||||||
@@ -46,7 +45,7 @@ export function SettingPage() {
|
|||||||
|
|
||||||
const [savedSettings, setSavedSettings] = useState<SettingsState>({
|
const [savedSettings, setSavedSettings] = useState<SettingsState>({
|
||||||
language: i18n.language,
|
language: i18n.language,
|
||||||
calendar: 'solar',
|
calendar: 'jalali',
|
||||||
theme: mode === 'light' || mode === 'dark' ? mode : 'light',
|
theme: mode === 'light' || mode === 'dark' ? mode : 'light',
|
||||||
});
|
});
|
||||||
const [draftSettings, setDraftSettings] =
|
const [draftSettings, setDraftSettings] =
|
||||||
@@ -78,9 +77,9 @@ export function SettingPage() {
|
|||||||
theme: themeReverseMap[theme] || 'light',
|
theme: themeReverseMap[theme] || 'light',
|
||||||
calendar:
|
calendar:
|
||||||
calendarOptions.find((c) => c.apiValue === calendarType)?.key ||
|
calendarOptions.find((c) => c.apiValue === calendarType)?.key ||
|
||||||
'solar',
|
'jalali',
|
||||||
language:
|
language:
|
||||||
languageOptions.find((l) => l.apiValue === language)?.code || 'en',
|
languageOptions.find((l) => l.apiValue === language)?.code || 'fa',
|
||||||
};
|
};
|
||||||
setSavedSettings(newSettings);
|
setSavedSettings(newSettings);
|
||||||
setDraftSettings(newSettings);
|
setDraftSettings(newSettings);
|
||||||
|
|||||||
Reference in New Issue
Block a user