import Link from 'next/link'; import { createRadioBanner, deleteRadioBanner, updateRadioBanner, } from '@/actions/admin-radio-extra'; import { prisma } from '@/lib/prisma'; import { StatusCard } from '@/components/admin/dashboard'; import NextImage from 'next/image'; import { Image as LucideImage } from 'lucide-react'; import { getTranslations } from "next-intl/server"; 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="\u{2705}" /> 0 ? 'warn' : 'neutral'} icon="\u{1F6AB}" />
)}

{t("banners.addBanner")}