import useCollectionStore from "@/store/collections"; import { faChartSimple, faChevronDown, faThumbTack, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import MainLayout from "@/layouts/MainLayout"; import useLinkStore from "@/store/links"; import useTagStore from "@/store/tags"; import LinkCard from "@/components/LinkCard"; import { useEffect, useState } from "react"; import useLinks from "@/hooks/useLinks"; export default function Dashboard() { const { collections } = useCollectionStore(); const { links } = useLinkStore(); const { tags } = useTagStore(); const [numberOfLinks, setNumberOfLinks] = useState(0); const [linkPinDisclosure, setLinkPinDisclosure] = useState(() => { const storedValue = typeof window !== "undefined" && localStorage.getItem("linkPinDisclosure"); return storedValue ? storedValue === "true" : true; }); useLinks({ pinnedOnly: true, sort: 0 }); useEffect(() => { setNumberOfLinks( collections.reduce( (accumulator, collection) => accumulator + (collection._count as any).links, 0 ) ); }, [collections]); useEffect(() => { localStorage.setItem( "linkPinDisclosure", linkPinDisclosure ? "true" : "false" ); }, [linkPinDisclosure]); return (

Dashboard

{numberOfLinks}

{numberOfLinks === 1 ? "Link" : "Links"}

{collections.length}

{collections.length === 1 ? "Collection" : "Collections"}

{tags.length}

{tags.length === 1 ? "Tag" : "Tags"}

Pinned Links

{links.some((e) => e.pinnedBy && e.pinnedBy[0]) ? ( ) : undefined}
{links.some((e) => e.pinnedBy && e.pinnedBy[0]) ? (
{links .filter((e) => e.pinnedBy && e.pinnedBy[0]) .map((e, i) => ( ))}
) : (

No Pinned Links

You can Pin your favorite Links by clicking on the three dots on each Link and clicking{" "} Pin to Dashboard.

)}
); }