- Replace 'card' class with 'admin-card' (gradient cards, dark mode support) - Replace 'muted' class with consistent Tailwind muted states - Standardize page headers with gradient backgrounds and Lucide icons - Convert all inline styles to Tailwind classes - Add admin-page CSS helpers (admin-card, admin-filter-bar, admin-section-title) - Apply pattern to all 42 admin pages (was only 6 before) - Zero TypeScript errors, production builds successfully Co-authored-by: openhands <[email protected]>
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import Link from "next/link";
|
|
import { Megaphone } from "lucide-react";
|
|
import { notFound } from "next/navigation";
|
|
import { deleteAd, updateAd } from "@/actions/admin-ads";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function EditAd({
|
|
params,
|
|
}: {
|
|
params: Promise<{ id: string }>;
|
|
}) {
|
|
const { id } = await params;
|
|
let ad: Awaited<ReturnType<typeof prisma.websiteAds.findUnique>> = null;
|
|
try {
|
|
ad = await prisma.websiteAds.findUnique({ where: { id: BigInt(id) } });
|
|
} catch {
|
|
notFound();
|
|
}
|
|
if (!ad) notFound();
|
|
|
|
return (
|
|
<main>
|
|
<div className="flex items-center gap-3 mb-6">
|
|
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--color-primary)]/20 to-[var(--color-primary)]/5 grid place-items-center">
|
|
<Megaphone size={20} className="text-[var(--color-primary)]" />
|
|
</div>
|
|
<div>
|
|
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Edit advertisement</h1>
|
|
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5"><Link href="/admin/ads">← Advertisements</Link></p>
|
|
</div>
|
|
</div>
|
|
<form action={updateAd} className="admin-card">
|
|
<input type="hidden" name="id" value={String(ad.id)} />
|
|
<input name="image" defaultValue={ad.image} placeholder="Image URL" required maxLength={255} />
|
|
<button type="submit" className="btn btn-primary">
|
|
Save
|
|
</button>
|
|
</form>
|
|
<form action={deleteAd} style={{ marginTop: "1rem" }}>
|
|
<input type="hidden" name="id" value={String(ad.id)} />
|
|
<button type="submit" className="btn btn-danger">
|
|
Delete advertisement
|
|
</button>
|
|
</form>
|
|
</main>
|
|
);
|
|
}
|