// Copyright (C) 2022-present Daniel31x13 // This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with this program. If not, see . 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 ); }, [collections]); return ( // ml-80

Dashboard

{links.length}

Links

{collections.length}

Collections

{tags.length}

Tags

Recently added Links

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

Top Collections

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