Files
Checkmate/client/src/Pages/Settings/SettingsTimeZone.jsx
T

75 lines
1.8 KiB
React
Raw Normal View History

2025-05-09 13:28:44 -07:00
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import ConfigBox from "../../Components/ConfigBox";
import Search from "../../Components/Inputs/Search";
2025-05-09 13:28:44 -07:00
import timezones from "../../Utils/timezones.json";
// Utils
import { useTheme } from "@emotion/react";
import { PropTypes } from "prop-types";
import { useTranslation } from "react-i18next";
import { useCallback, useMemo, useState } from "react";
2025-05-09 13:28:44 -07:00
const SettingsTimeZone = ({ HEADING_SX, handleChange, timezone }) => {
const theme = useTheme();
const { t } = useTranslation();
const [rawInput, setRawInput] = useState("");
const selectedTimezone = useMemo(
() => timezones.find((tz) => tz._id === timezone) ?? null,
[timezone]
);
const handleTimezoneChange = useCallback(
(newValue) => {
setRawInput("");
handleChange({
target: {
name: "timezone",
value: newValue?._id ?? "",
},
});
},
[handleChange]
);
2025-05-09 13:28:44 -07:00
return (
<ConfigBox>
<Box>
2025-05-27 09:10:32 -07:00
<Typography
component="h1"
variant="h2"
>
2025-06-24 14:30:14 +08:00
{t("settingsPage.timezoneSettings.title")}
2025-05-27 09:10:32 -07:00
</Typography>
2025-05-09 13:28:44 -07:00
<Typography sx={HEADING_SX}>
2025-06-24 14:30:14 +08:00
<Typography component="span">
{t("settingsPage.timezoneSettings.description")}
</Typography>
2025-05-09 13:28:44 -07:00
</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
<Search
id="timezone"
label={t("settingsDisplayTimezone")}
options={timezones}
filteredBy="name"
value={selectedTimezone}
inputValue={rawInput}
handleInputChange={(val) => setRawInput(val)}
handleChange={handleTimezoneChange}
isAdorned={false}
unit="timezone"
2025-05-09 13:28:44 -07:00
/>
</Stack>
</ConfigBox>
);
};
SettingsTimeZone.propTypes = {
HEADING_SX: PropTypes.object,
handleChange: PropTypes.func,
timezone: PropTypes.string,
};
export default SettingsTimeZone;