import useLocalSettingsStore from "@/store/localSettings"; import { useEffect, useState, ChangeEvent } from "react"; import { useTranslation } from "next-i18next"; type Props = { className?: string; }; export default function ToggleDarkMode({ className }: Props) { const { t } = useTranslation(); const { settings, updateSettings } = useLocalSettingsStore(); const [theme, setTheme] = useState( localStorage.getItem("theme") ); const handleToggle = (e: ChangeEvent) => { setTheme(e.target.checked ? "dark" : "light"); }; useEffect(() => { if (theme) { updateSettings({ theme }); localStorage.setItem("theme", theme); } }, [theme, updateSettings]); return (
); }