- Add error display to help questions new/edit pages - Improve error visibility in admin-badges, admin-applications, admin-logs, admin-users pages - Update createHelpQuestion action to properly handle and display unique name collisions and database errors - Add user-friendly error messages to admin error handling - Enhances admin page error reporting for better user experience
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import Link from "next/link";
|
|
import { createHelpQuestion } from "@/actions/admin-help";
|
|
|
|
export default async function NewHelpQuestion({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ error?: string }>;
|
|
}) {
|
|
const { error } = await searchParams;
|
|
|
|
return (
|
|
<main>
|
|
<p className="muted">
|
|
<Link href="/admin/help-questions">← Help Center</Link>
|
|
</p>
|
|
<h1>New help-center entry</h1>
|
|
{error ? (
|
|
<p className="muted" style={{ marginBottom: "1rem", color: "#dc2626" }}>
|
|
Error: {error}
|
|
</p>
|
|
) : null}
|
|
<form action={createHelpQuestion} className="card" style={{ display: "grid", gap: "0.6rem" }}>
|
|
<input name="name" placeholder="Name / title" required maxLength={255} />
|
|
<textarea name="content" placeholder="Content" rows={6} required />
|
|
<input name="position" type="number" min={1} defaultValue={1} placeholder="Position" />
|
|
<input name="imageUrl" placeholder="Image URL (optional)" maxLength={255} />
|
|
<input name="buttonText" placeholder="Button text (optional)" maxLength={255} />
|
|
<input name="buttonUrl" placeholder="Button URL (optional)" maxLength={255} />
|
|
<label style={{ display: "flex", gap: "0.4rem", alignItems: "center" }}>
|
|
Button color
|
|
<input name="buttonColor" type="color" defaultValue="#eeb425" />
|
|
</label>
|
|
<label style={{ display: "flex", gap: "0.4rem", alignItems: "center" }}>
|
|
Button border color
|
|
<input name="buttonBorderColor" type="color" defaultValue="#facc15" />
|
|
</label>
|
|
<label style={{ display: "flex", gap: "0.4rem", alignItems: "center" }}>
|
|
<input name="smallBox" type="checkbox" value="1" />
|
|
Small box
|
|
</label>
|
|
<button type="submit" className="btn btn-primary">
|
|
Create
|
|
</button>
|
|
</form>
|
|
</main>
|
|
);
|
|
}
|