import useCollectionStore from "@/store/collections"; import useTagStore from "@/store/tags"; import Link from "next/link"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { Disclosure, Transition } from "@headlessui/react"; export default function Sidebar({ className }: { className?: string }) { const [tagDisclosure, setTagDisclosure] = useState(() => { const storedValue = localStorage.getItem("tagDisclosure"); return storedValue ? storedValue === "true" : true; }); const [collectionDisclosure, setCollectionDisclosure] = useState( () => { const storedValue = localStorage.getItem("collectionDisclosure"); return storedValue ? storedValue === "true" : true; }, ); const { collections } = useCollectionStore(); const { tags } = useTagStore(); const router = useRouter(); const [active, setActive] = useState(""); useEffect(() => { localStorage.setItem("tagDisclosure", tagDisclosure ? "true" : "false"); }, [tagDisclosure]); useEffect(() => { localStorage.setItem( "collectionDisclosure", collectionDisclosure ? "true" : "false", ); }, [collectionDisclosure]); useEffect(() => { setActive(router.asPath); }, [router, collections]); return ( ); }