Fixes #494: TimeOptions 24h clock toggle broken (#495)

This commit is contained in:
Alex van Andel 2021-08-19 13:36:17 +01:00 committed by GitHub
parent a8ef195546
commit afb8ce7109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,9 +19,10 @@ const TimeOptions = (props) => {
}
}, [selectedTimeZone]);
useEffect(() => {
const handle24hClockToggle = (is24hClock: boolean) => {
setIs24hClock(is24hClock);
props.onToggle24hClock(is24h(is24hClock));
}, [is24hClock]);
};
return (
selectedTimeZone !== "" && (
@ -35,7 +36,7 @@ const TimeOptions = (props) => {
</Switch.Label>
<Switch
checked={is24hClock}
onChange={setIs24hClock}
onChange={handle24hClockToggle}
className={classNames(
is24hClock ? "bg-black" : "dark:bg-gray-600 bg-gray-200",
"relative inline-flex flex-shrink-0 h-5 w-8 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black"