import useCollectionStore from "@/store/collections"; import { faArrowRight, faChartSimple } 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 LinkItem from "@/components/Dashboard/LinkItem"; import Link from "next/link"; import CollectionItem from "@/components/Dashboard/CollectionItem"; import { useEffect, useState } from "react"; export default function () { const { collections } = useCollectionStore(); const { links } = useLinkStore(); const { tags } = useTagStore(); const [sortedCollections, setSortedCollections] = useState([]); useEffect(() => { const collectionsWithLinkCount = collections.map((collection) => { const linkCount = links.filter( (link) => link.collectionId === collection.id ).length; return { ...collection, linkCount }; }); setSortedCollections( collectionsWithLinkCount.sort((a, b) => b.linkCount - a.linkCount) as any ); // console.log(links.length); }, [collections]); return ( // ml-80

Dashboard

{links.length}

Links {/* {links.length == 1 ? "Links" : "Link"} */}

{collections.length}

Collections

{tags.length}

Tags

Recently added Links

View All
{links .sort( (a, b) => new Date(b.createdAt as string).getTime() - new Date(a.createdAt as string).getTime() ) .slice(0, 5) .map((e, i) => ( ))}

Top Collections

View All
{sortedCollections.map((e, i) => ( ))}

Top Tags

{tags.slice(0, 19).map((e, i) => ( # {e.name} ))}
); }