2022-11-09 21:38:05 -05:00
|
|
|
import NewPost from "@components/new-post"
|
2022-11-09 22:46:12 -05:00
|
|
|
import { useRouter } from "next/navigation"
|
2022-11-11 22:17:44 -05:00
|
|
|
import { getPostWithFiles } from "@lib/server/prisma"
|
|
|
|
import Header from "@components/header"
|
2022-11-10 02:11:36 -05:00
|
|
|
|
2022-11-09 22:46:12 -05:00
|
|
|
const NewFromExisting = async ({
|
|
|
|
params
|
|
|
|
}: {
|
|
|
|
params: {
|
|
|
|
id: string
|
|
|
|
}
|
|
|
|
}) => {
|
|
|
|
const { id } = params
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
if (!id) {
|
|
|
|
return router.push("/new")
|
|
|
|
}
|
|
|
|
|
|
|
|
const post = await getPostWithFiles(id)
|
|
|
|
|
2022-11-11 22:17:44 -05:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Header signedIn />
|
|
|
|
<NewPost initialPost={post} newPostParent={id} />
|
|
|
|
</>
|
|
|
|
)
|
2022-11-09 21:38:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export default NewFromExisting
|