import { Image as LucideImage } from "lucide-react"; import NextImage from "next/image"; import Link from "next/link"; import { getTranslations } from "next-intl/server"; import { createRadioBanner, deleteRadioBanner, updateRadioBanner, } from "@/actions/admin-radio-extra"; import { StatusCard } from "@/components/admin/dashboard"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; type Banner = { id: bigint; userId: bigint; imagePath: string; title: string | null; description: string | null; sortOrder: number; isActive: boolean; createdAt: Date | null; }; function formatDate(d: Date | null): string { return d ? d.toISOString().slice(0, 16).replace("T", " ") : "\u2014"; } export default async function AdminRadioBannersPage() { const t = await getTranslations("pages.admin.radio"); let banners: Banner[] = []; let dbError = false; try { banners = await prisma.radioBanners.findMany({ select: { id: true, userId: true, imagePath: true, title: true, description: true, sortOrder: true, isActive: true, createdAt: true, }, orderBy: [{ sortOrder: "asc" }, { id: "asc" }], }); } catch { dbError = true; banners = []; } const activeCount = banners.filter((b) => b.isActive).length; const hiddenCount = banners.length - activeCount; return (

{t("banners.heading")}

{t("banners.description")}

{dbError ? (

{t("banners.dbError")}

) : (
0 ? "ok" : "neutral"} icon="✅" /> 0 ? "warn" : "neutral"} icon="🚫" />
)}

{t("banners.addBanner")}