2022-11-12 01:28:06 -08:00
|
|
|
import NewPost from "../../components/new"
|
2022-11-09 19:46:12 -08:00
|
|
|
import { useRouter } from "next/navigation"
|
2022-11-12 01:28:06 -08:00
|
|
|
import Header from "@components/header"
|
|
|
|
import { getPostById } from "@lib/server/prisma"
|
2022-11-09 23:11:36 -08:00
|
|
|
|
2022-11-09 19:46:12 -08:00
|
|
|
const NewFromExisting = async ({
|
|
|
|
params
|
|
|
|
}: {
|
|
|
|
params: {
|
|
|
|
id: string
|
|
|
|
}
|
|
|
|
}) => {
|
|
|
|
const { id } = params
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
if (!id) {
|
2022-11-11 23:59:33 -08:00
|
|
|
router.push("/new")
|
|
|
|
return;
|
2022-11-09 19:46:12 -08:00
|
|
|
}
|
|
|
|
|
2022-11-12 01:28:06 -08:00
|
|
|
const post = await getPostById(id, true)
|
2022-11-09 19:46:12 -08:00
|
|
|
|
2022-11-11 19:17:44 -08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Header signedIn />
|
|
|
|
<NewPost initialPost={post} newPostParent={id} />
|
|
|
|
</>
|
|
|
|
)
|
2022-11-09 18:38:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default NewFromExisting
|