From 60467f1d7fdc63e8ec3b10ad0d183248cebac4ee Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 17 Mar 2024 15:38:03 +0000 Subject: feature(web): A better tags editor using react select with auto complete and auto create --- apps/web/app/dashboard/tags/page.tsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'apps/web/app') diff --git a/apps/web/app/dashboard/tags/page.tsx b/apps/web/app/dashboard/tags/page.tsx index 08acd968..dec11527 100644 --- a/apps/web/app/dashboard/tags/page.tsx +++ b/apps/web/app/dashboard/tags/page.tsx @@ -1,11 +1,8 @@ import Link from "next/link"; import { redirect } from "next/navigation"; import { Separator } from "@/components/ui/separator"; +import { api } from "@/server/api/client"; import { getServerAuthSession } from "@/server/auth"; -import { count, eq } from "drizzle-orm"; - -import { db } from "@hoarder/db"; -import { bookmarkTags, tagsOnBookmarks } from "@hoarder/db/schema"; function TagPill({ name, count }: { name: string; count: number }) { return ( @@ -24,16 +21,7 @@ export default async function TagsPage() { redirect("/"); } - let tags = await db - .select({ - id: tagsOnBookmarks.tagId, - name: bookmarkTags.name, - count: count(), - }) - .from(tagsOnBookmarks) - .where(eq(bookmarkTags.userId, session.user.id)) - .groupBy(tagsOnBookmarks.tagId) - .innerJoin(bookmarkTags, eq(bookmarkTags.id, tagsOnBookmarks.tagId)); + let tags = (await api.tags.list()).tags; // Sort tags by usage desc tags = tags.sort((a, b) => b.count - a.count); -- cgit v1.2.3-70-g09d2