From ed46407c41405014dda4cbd3dc7a39d04d1a15ac Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 31 Mar 2024 17:39:56 +0100 Subject: feature: Split the tags in AllTags page by who used them --- apps/web/app/dashboard/tags/page.tsx | 75 +++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 19 deletions(-) (limited to 'apps/web/app/dashboard') diff --git a/apps/web/app/dashboard/tags/page.tsx b/apps/web/app/dashboard/tags/page.tsx index f87b0fcc..2ba1074c 100644 --- a/apps/web/app/dashboard/tags/page.tsx +++ b/apps/web/app/dashboard/tags/page.tsx @@ -1,8 +1,13 @@ import Link from "next/link"; -import { redirect } from "next/navigation"; import { Separator } from "@/components/ui/separator"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { api } from "@/server/api/client"; -import { getServerAuthSession } from "@/server/auth"; +import { Info } from "lucide-react"; function TagPill({ name, count }: { name: string; count: number }) { return ( @@ -16,30 +21,62 @@ function TagPill({ name, count }: { name: string; count: number }) { } export default async function TagsPage() { - const session = await getServerAuthSession(); - if (!session) { - redirect("/"); - } - - let tags = (await api.tags.list()).tags; + let allTags = (await api.tags.list()).tags; // Sort tags by usage desc - tags = tags.sort((a, b) => b.count - a.count); + allTags = allTags.sort((a, b) => b.count - a.count); + + const humanTags = allTags.filter((t) => (t.countAttachedBy.human ?? 0) > 0); + const aiTags = allTags.filter((t) => (t.countAttachedBy.human ?? 0) == 0); - let tagPill; - if (tags.length) { - tagPill = tags.map((t) => ( - - )); - } else { - tagPill = "No Tags"; - } + const tagsToPill = (tags: typeof allTags) => { + let tagPill; + if (tags.length) { + tagPill = tags.map((t) => ( + + )); + } else { + tagPill = "No Tags"; + } + return tagPill; + }; return ( -
+
All Tags -
{tagPill}
+ + +

Your Tags

+ + + + + + +

Tags that were attached at least once by you

+
+
+
+
+
{tagsToPill(humanTags)}
+ + + + +

AI Tags

+ + + + + + +

Tags that were only attached automatically (by AI)

+
+
+
+
+
{tagsToPill(aiTags)}
); } -- cgit v1.2.3-70-g09d2