From dde49dd60e00653960223b8dcea3488b7845d43b Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 14 Feb 2024 00:30:58 +0000 Subject: feature: Sort tags by usage and show usage numbers --- packages/web/app/dashboard/tags/page.tsx | 33 ++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/web/app/dashboard/tags/page.tsx b/packages/web/app/dashboard/tags/page.tsx index ad5c99b8..dc0d2ef7 100644 --- a/packages/web/app/dashboard/tags/page.tsx +++ b/packages/web/app/dashboard/tags/page.tsx @@ -1,9 +1,22 @@ -import { Button } from "@/components/ui/button"; import { getServerAuthSession } from "@/server/auth"; import { prisma } from "@remember/db"; import Link from "next/link"; import { redirect } from "next/navigation"; +function TagPill({ name, count }: { name: string; count: number }) { + return ( + + {name} + + {count} + + + ); +} + export default async function TagsPage() { const session = await getServerAuthSession(); if (!session) { @@ -14,21 +27,25 @@ export default async function TagsPage() { where: { userId: session.user.id, }, + include: { + _count: { + select: { + bookmarks: true, + }, + }, + }, }); + // Sort tags by usage desc + tags.sort((a, b) => b._count.bookmarks - a._count.bookmarks); + return (
All Tags
{tags.map((t) => ( - - {t.name} - + ))}
-- cgit v1.2.3-70-g09d2