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"; import SidebarHighlightLink from "@/components/SidebarHighlightLink"; import CollectionListing from "@/components/CollectionListing"; import { useTranslation } from "next-i18next"; import { useCollections } from "@/hooks/store/collections"; export default function Sidebar({ className }: { className?: string }) { const { t } = useTranslation(); 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 { data: { response: collections } = { response: [] } } = useCollections(); const { tags } = useTagStore(); const [active, setActive] = useState(""); const router = useRouter(); useEffect(() => { localStorage.setItem("tagDisclosure", tagDisclosure ? "true" : "false"); }, [tagDisclosure]); useEffect(() => { localStorage.setItem( "collectionDisclosure", collectionDisclosure ? "true" : "false" ); }, [collectionDisclosure]); useEffect(() => { setActive(router.asPath); }, [router, collections]); return ( ); }