diff --git a/app/categories/page.tsx b/app/categories/page.tsx
index 5528bea..787f7a7 100644
--- a/app/categories/page.tsx
+++ b/app/categories/page.tsx
@@ -1,6 +1,4 @@
-import {
- bookmarkCategorySchema,
-} from '@/types'
+import { bookmarkCategoryWithBookmarksSchema } from '@/types'
import { db } from '@/lib/db'
import { cookies } from 'next/headers'
import { getUser } from '@/lib/auth'
@@ -17,9 +15,14 @@ export default async function CategoriesPage() {
const data = await db.query.bookmarkCategory.findMany({
where: (bookmarkCategory, { eq }) =>
eq(bookmarkCategory.userId, session_user ? session_user.id : 0),
+ with: {
+ bookmark: true,
+ },
})
- const bookmarkCategories = bookmarkCategorySchema.array().parse(data)
+ const bookmarkCategories = bookmarkCategoryWithBookmarksSchema
+ .array()
+ .parse(data)
return (
diff --git a/app/categories/table.tsx b/app/categories/table.tsx
index 9976c46..58118d7 100644
--- a/app/categories/table.tsx
+++ b/app/categories/table.tsx
@@ -10,19 +10,20 @@ import {
Tooltip,
} from '@nextui-org/react'
import { DeleteIcon, EditIcon } from '@/components/icons'
-import { BookmarkCategory } from '@/types'
+import { BookmarkCategoryWithBookmarks } from '@/types'
import { useRouter } from 'next/navigation'
const columns = [
{ name: 'NAME', uid: 'name' },
+ { name: 'BOOKMARK COUNT', uid: 'bookmarkcount' },
{ name: 'ACTIONS', uid: 'actions' },
]
export default function TableComponent({
bookmarkCategories,
}: {
- bookmarkCategories: BookmarkCategory[]
+ bookmarkCategories: BookmarkCategoryWithBookmarks[]
}) {
const router = useRouter()
@@ -54,6 +55,7 @@ export default function TableComponent({
{(item) => (
{item.name}
+ {item.bookmark.length}