CoastalCommitsPastes/client/app/(profiles)/mine/page.tsx

19 lines
596 B
TypeScript
Raw Normal View History

2022-11-10 02:11:36 -05:00
import { USER_COOKIE_NAME } from "@lib/constants"
import { notFound, useRouter } from "next/navigation"
import { cookies } from "next/headers"
import { getPostsByUser } from "app/prisma"
import PostList from "@components/post-list"
export default async function Mine() {
// TODO: fix router usage
// const router = useRouter()
const userId = cookies().get(USER_COOKIE_NAME)?.value
if (!userId) {
// return router.push("/signin")
return notFound()
}
const posts = await getPostsByUser(userId, true)
const hasMore = false
return <PostList morePosts={hasMore} initialPosts={posts} />
}