// TODO: replace headlessui with radix-ui import { Switch } from "@headlessui/react"; import { FC, useEffect, useState } from "react"; import TimezoneSelect, { ITimezoneOption } from "react-timezone-select"; import classNames from "@lib/classNames"; import { useLocale } from "@lib/hooks/useLocale"; import { is24h, timeZone } from "../../lib/clock"; type Props = { onSelectTimeZone: (selectedTimeZone: string) => void; onToggle24hClock: (is24hClock: boolean) => void; }; const TimeOptions: FC = (props) => { const [selectedTimeZone, setSelectedTimeZone] = useState(""); const [is24hClock, setIs24hClock] = useState(false); const { t } = useLocale(); useEffect(() => { setIs24hClock(is24h()); setSelectedTimeZone(timeZone()); }, []); useEffect(() => { if (selectedTimeZone && timeZone() && selectedTimeZone !== timeZone()) { props.onSelectTimeZone(timeZone(selectedTimeZone)); } }, [selectedTimeZone]); const handle24hClockToggle = (is24hClock: boolean) => { setIs24hClock(is24hClock); props.onToggle24hClock(is24h(is24hClock)); }; return selectedTimeZone !== "" ? (
{t("time_options")}
{t("am_pm")} {t("use_setting")} {t("24_h")}
setSelectedTimeZone(tz.value)} className="focus:border-brand mt-1 mb-2 block w-full rounded-md border-gray-300 shadow-sm focus:ring-black sm:text-sm" />
) : null; }; export default TimeOptions;