committing summative
This commit is contained in:
1 parent
73ac8e85be
commit
95b138f29e
44 files changed
+5319
-755
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { getUserNewsletter, editNewsletter } from "@/app/actions/NewsletterActions";
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
import EditNewsletterForm from "./EditNewsletterForm";
|
||||
|
||||
export default async function NewsletterPage({ params }: { params: Promise<{ id: string }>; }) { // next passes in params object when this comp is called
|
||||
const { id } = await params; // [id] catches the value from the url and gives it a param value with the key of id
|
||||
const newsletter = await getUserNewsletter(id);
|
||||
|
||||
if (!newsletter) { // otherwise tries to reference things that dont exist
|
||||
notFound();
|
||||
}
|
||||
|
||||
if (newsletter.status === "Sent") {
|
||||
redirect(`/newsletters/${newsletter.id}`); // if sent dont let them access edit page
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="mx-auto w-full max-w-3xl px-6 py-10">
|
||||
<h1 className="text-4xl font-bold tracking-tight">
|
||||
Edit newsletter
|
||||
</h1>
|
||||
|
||||
<EditNewsletterForm
|
||||
key={newsletter.id}
|
||||
newsletter={newsletter}
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user