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

27 lines
724 B
TypeScript
Raw Normal View History

2022-11-10 02:11:36 -05:00
import { USER_COOKIE_NAME } from "@lib/constants"
import { notFound, redirect, useRouter } from "next/navigation"
2022-11-10 02:11:36 -05:00
import { cookies } from "next/headers"
import { getPostsByUser } from "@lib/server/prisma"
2022-11-10 02:11:36 -05:00
import PostList from "@components/post-list"
import { getCurrentUser } from "@lib/server/session"
import Header from "@components/header"
import { authOptions } from "@lib/server/auth"
2022-11-11 19:33:43 -05:00
2022-11-10 02:11:36 -05:00
export default async function Mine() {
const userId = (await getCurrentUser())?.id
2022-11-10 02:11:36 -05:00
if (!userId) {
redirect(authOptions.pages?.signIn || "/new")
2022-11-10 02:11:36 -05:00
}
const posts = await getPostsByUser(userId, true)
2022-11-10 02:11:36 -05:00
const hasMore = false
return (
<>
<Header signedIn />
<PostList morePosts={hasMore} initialPosts={posts} />
</>
)
2022-11-10 02:11:36 -05:00
}