From 2c2d05fd0a2c3c26d765f8a6beb88d907a097c1d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 11 Feb 2024 14:54:52 +0000 Subject: refactor: Migrating to trpc instead of next's route handers --- .../web/app/dashboard/bookmarks/components/Bookmarks.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'packages/web/app/dashboard/bookmarks/components/Bookmarks.tsx') diff --git a/packages/web/app/dashboard/bookmarks/components/Bookmarks.tsx b/packages/web/app/dashboard/bookmarks/components/Bookmarks.tsx index 6a9ffe1b..d7e3f1f3 100644 --- a/packages/web/app/dashboard/bookmarks/components/Bookmarks.tsx +++ b/packages/web/app/dashboard/bookmarks/components/Bookmarks.tsx @@ -1,25 +1,26 @@ import { redirect } from "next/navigation"; import BookmarksGrid from "./BookmarksGrid"; -import { authOptions } from "@/lib/auth"; -import { getServerSession } from "next-auth"; -import { getBookmarks } from "@/lib/services/bookmarks"; import { ZGetBookmarksRequest } from "@/lib/types/api/bookmarks"; +import { api } from "@/server/api/client"; +import { getServerAuthSession } from "@/server/auth"; export default async function Bookmarks({ favourited, archived, title, }: ZGetBookmarksRequest & { title: string }) { - const session = await getServerSession(authOptions); + const session = await getServerAuthSession(); if (!session) { redirect("/"); } - const bookmarks = await getBookmarks(session.user.id, { + + // TODO: Migrate to a server side call in trpc instead + const bookmarks = await api.bookmarks.getBookmarks({ favourited, archived, }); - if (bookmarks.length == 0) { + if (bookmarks.bookmarks.length == 0) { // TODO: This needs to be polished return ( <> @@ -32,7 +33,7 @@ export default async function Bookmarks({ return ( <>
{title}
- + ); } -- cgit v1.2.3-70-g09d2