diff --git a/client/src/Pages/Settings/index.tsx b/client/src/Pages/Settings/index.tsx new file mode 100644 index 000000000..c1b3ecdfa --- /dev/null +++ b/client/src/Pages/Settings/index.tsx @@ -0,0 +1,136 @@ +import { BasePage, ConfigBox } from "@/Components/v2/design-elements"; +import { Autocomplete, Select } from "@/Components/v2/inputs"; +import { Stack, useTheme, MenuItem, type SelectChangeEvent } from "@mui/material"; +import { useTranslation } from "react-i18next"; +import { useSelector, useDispatch } from "react-redux"; +import DummyChart from "@/Pages/Settings/DummyChart"; + +import { + setTimezone, + setMode, + setLanguage, + setChartType, + type ThemeMode, + type ChartType, +} from "@/Features/UI/uiSlice.js"; +import timezones from "@/Utils/timezones.json"; +import type { RootState } from "@/Types/state"; + +interface Timezone { + id: string; + name: string; +} + +export const SettingsPage = () => { + const theme = useTheme(); + const { t, i18n } = useTranslation(); + const dispatch = useDispatch(); + const { + timezone: selectedTimezoneId, + mode, + language = "en", + chartType = "histogram", + } = useSelector((state: RootState) => state.ui); + + // Convert timezones to match AutoComplete format (id instead of _id) + const timezoneOptions: Timezone[] = timezones.map((tz) => ({ + id: tz._id, + name: tz.name, + })); + + const selectedTimezone = + timezoneOptions.find((tz) => tz.id === selectedTimezoneId) ?? null; + + const handleTimezoneChange = (newValue: Timezone | null) => { + const newId = newValue?.id ?? ""; + dispatch(setTimezone({ timezone: newId })); + }; + + const handleModeChange = (e: SelectChangeEvent) => { + dispatch(setMode(e.target.value)); + }; + + const handleLanguageChange = (e: SelectChangeEvent) => { + dispatch(setLanguage(e.target.value)); + }; + + const handleChartTypeChange = (e: SelectChangeEvent) => { + dispatch(setChartType(e.target.value)); + }; + + const languages = Object.keys(i18n.options.resources || {}); + + return ( + + + option.name} + isOptionEqualToValue={(option: Timezone, value: Timezone) => + option.id === value.id + } + onChange={(_, newValue) => { + handleTimezoneChange(newValue as Timezone | null); + }} + fieldLabel={t("pages.settings.form.timezone.option.timezone.label")} + /> + } + /> + + + + + + + } + /> + + + ); +}; + +export default SettingsPage; diff --git a/client/src/Pages/Settings/index.jsx b/client/src/Pages/Settings/old.jsx similarity index 100% rename from client/src/Pages/Settings/index.jsx rename to client/src/Pages/Settings/old.jsx diff --git a/client/src/Routes/index.tsx b/client/src/Routes/index.tsx index e3c0b0667..582461d81 100644 --- a/client/src/Routes/index.tsx +++ b/client/src/Routes/index.tsx @@ -44,6 +44,7 @@ import CreateNotifications from "@/Pages/Notifications/create"; import Account from "@/Pages/Account"; import EditUser from "@/Pages/Account/EditUser"; import Settings from "@/Pages/Settings"; +import OldSettings from "@/Pages/Settings/old.jsx"; import Maintenance from "@/Pages/Maintenance"; import CreateNewMaintenanceWindow from "@/Pages/Maintenance/create"; @@ -319,7 +320,17 @@ const Routes = () => { /> } + element={ + <> + + + + + } + /> + } />