CoastalCommitsPastes/client/app/mine/page.tsx
Max Leiter 12d9eafcd9 lint
2022-11-17 22:36:53 -08:00

25 lines
632 B
TypeScript

import { redirect } from "next/navigation"
import { getPostsByUser } from "@lib/server/prisma"
import PostList from "@components/post-list"
import { getCurrentUser } from "@lib/server/session"
import { authOptions } from "@lib/server/auth"
export default async function Mine() {
const userId = (await getCurrentUser())?.id
if (!userId) {
return redirect(authOptions.pages?.signIn || "/new")
}
const posts = await getPostsByUser(userId, true)
const hasMore = false
const stringifiedPosts = JSON.stringify(posts)
return (
<PostList
userId={userId}
morePosts={hasMore}
initialPosts={stringifiedPosts}
/>
)
}