feat: complete admin error handling improvements - add error display to articles pages

- Add error display to articles pages (overview, edit, new)
- Improve createArticle action to handle database errors gracefully
- Redirect with error query params for user feedback on failure
- Completes error handling improvements across admin pages
- Enhances error reporting for better user experience
This commit is contained in:
remco committed 2026-07-01 21:32:59 +02:00
1 parent 0323c3fcaa
commit 4a06b30263
4 files changed
+51 -16

No files matched your search

+12 -1
View File
@@ -2,13 +2,24 @@ import Link from "next/link";
import { createArticle } from "@/actions/admin-articles";
import { ArticleForm } from "@/components/admin/article-form";
export default function NewArticle() {
export default async function NewArticle({
searchParams,
}: {
searchParams: Promise<{ error?: string }>;
}) {
const { error } = await searchParams;
return (
<main>
<p className="muted">
<Link href="/admin/articles">← Articles</Link>
</p>
<h1>New article</h1>
{error ? (
<p className="muted" style={{ marginBottom: "1rem", color: "#dc2626" }}>
Error: {error}
</p>
) : null}
<ArticleForm action={createArticle} />
</main>
);