From 8fe08f9c02ec99c1dfd886f8814889b1a7bef7b0 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Fri, 25 Aug 2023 00:12:54 +0800 Subject: [PATCH] Get bookmarks based on user --- app/dashboard/page.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 172003f..197a844 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -1,14 +1,21 @@ import { bookmarkCategoryWithBookmarksSchema } from '@/types' -import { bookmark } from '@/lib/schema' import { db } from '@/lib/db' import EditBookmarkForm from '@/components/editBookmarkForm' import BookmarkTabs from '@/components/tabs' +import { cookies } from 'next/headers' +import { getUser } from '@/lib/auth' export const dynamic = 'force-dynamic' export const fetchCache = 'force-no-store' export default async function DashboardPage() { + const token = cookies().get('token') + + const session_user = await getUser(token) + const data = await db.query.bookmarkCategory.findMany({ + where: (bookmark, { eq }) => + eq(bookmark.userId, session_user ? session_user.id : 0), with: { bookmark: true, },