import { redirect } from "next/navigation";
import { ArticleComposer } from "@/components/article-composer";
import { auth } from "@/lib/auth";
import { getCategories } from "@/lib/data";

export const dynamic = "force-dynamic";

export default async function NewArticlePage() {
  const session = await auth();
  if (!session?.user) redirect("/login");
  const categories = await getCategories();

  return (
    <section className="px-4 py-10 sm:px-6 lg:px-8">
      <div className="mx-auto max-w-5xl">
        <p className="font-display text-xs font-bold uppercase tracking-[.28em] text-cyanx">CMS</p>
        <h1 className="mt-3 font-display text-4xl font-black text-white">Submit a story</h1>
        <ArticleComposer categories={categories} />
      </div>
    </section>
  );
}
