import { Switch } from "@headlessui/react"; import TimezoneSelect from "react-timezone-select"; import { useEffect, useState } from "react"; import { timeZone, is24h } from "../../lib/clock"; function classNames(...classes) { return classes.filter(Boolean).join(" "); } const TimeOptions = (props) => { const [selectedTimeZone, setSelectedTimeZone] = useState(""); const [is24hClock, setIs24hClock] = useState(false); useEffect(() => { setIs24hClock(is24h()); setSelectedTimeZone(timeZone()); }, []); useEffect(() => { if (selectedTimeZone && timeZone() && selectedTimeZone !== timeZone()) { props.onSelectTimeZone(timeZone(selectedTimeZone)); } }, [selectedTimeZone]); useEffect(() => { props.onToggle24hClock(is24h(is24hClock)); }, [is24hClock]); return ( selectedTimeZone !== "" && (
Time Options
am/pm Use setting 24h
setSelectedTimeZone(tz.value)} className="mb-2 shadow-sm focus:ring-blue-500 focus:border-blue-500 mt-1 block w-full sm:text-sm border-gray-300 rounded-md" />
) ); }; export default TimeOptions;