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:
1 parent
0323c3fcaa
commit
4a06b30263
4 files changed
+51
-16
No files matched your search
@@ -8,10 +8,13 @@ export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function EditArticle({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
searchParams: Promise<{ error?: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const { error } = await searchParams;
|
||||
const article = await prisma.websiteArticles.findUnique({
|
||||
where: { id: BigInt(id) },
|
||||
select: { id: true, slug: true, title: true, shortStory: true, fullStory: true, image: true },
|
||||
@@ -24,6 +27,11 @@ export default async function EditArticle({
|
||||
<Link href="/admin/articles">← Articles</Link>
|
||||
</p>
|
||||
<h1>Edit article</h1>
|
||||
{error ? (
|
||||
<p className="muted" style={{ marginBottom: "1rem", color: "#dc2626" }}>
|
||||
Error: {error}
|
||||
</p>
|
||||
) : null}
|
||||
<ArticleForm
|
||||
action={async (fd) => {
|
||||
"use server";
|
||||
|
||||
Reference in new issue
Block a user