You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
818 B
TypeScript

import {
bookmarkCategorySchema,
} from '@/types'
import { db } from '@/lib/db'
import { cookies } from 'next/headers'
import { getUser } from '@/lib/auth'
import TableComponent from './table'
export const dynamic = 'force-dynamic'
export const fetchCache = 'force-no-store'
export default async function CategoriesPage() {
const token = cookies().get('token')
const session_user = await getUser(token)
const data = await db.query.bookmarkCategory.findMany({
where: (bookmarkCategory, { eq }) =>
eq(bookmarkCategory.userId, session_user ? session_user.id : 0),
})
const bookmarkCategories = bookmarkCategorySchema.array().parse(data)
return (
<div className='flex w-full max-w-4xl flex-row flex-wrap justify-start gap-6'>
<TableComponent bookmarkCategories={bookmarkCategories} />
</div>
)
}