import Link from 'next/link'; import { prisma } from '@/lib/prisma'; import { deleteShout } from '@/actions/admin-radio'; import { StatusCard } from '@/components/admin/dashboard'; import { getTranslations } from "next-intl/server"; export const dynamic = 'force-dynamic'; type Shout = { id: bigint; userId: bigint; message: string; createdAt: Date | null; }; type Application = { id: bigint; userId: bigint; realName: string; age: number; status: string; musicStyle: string | null; discordUsername: string | null; createdAt: Date | null; }; type Schedule = { id: bigint; userId: bigint; day: string; startTime: Date; endTime: Date; showName: string | null; isActive: boolean; }; function formatDate(d: Date | null): string { return d ? d.toISOString().slice(0, 16).replace('T', ' ') : '\u2014'; } function formatTime(d: Date | null): string { return d ? d.toISOString().slice(11, 16) : '\u2014'; } function statusBadgeClass(status: string): string { const s = status.toLowerCase(); if (s === 'approved' || s === 'accepted') return 'ok'; if (s === 'rejected' || s === 'denied') return 'danger'; return ''; } export default async function AdminRadioPage() { const t = await getTranslations("pages.admin.radio"); let shouts: Shout[] = []; let applications: Application[] = []; let schedules: Schedule[] = []; try { shouts = await prisma.radioShouts.findMany({ select: { id: true, userId: true, message: true, createdAt: true }, orderBy: { id: 'desc' }, take: 25, }); } catch { shouts = []; } try { applications = await prisma.radioApplications.findMany({ select: { id: true, userId: true, realName: true, age: true, status: true, musicStyle: true, discordUsername: true, createdAt: true, }, orderBy: { id: 'desc' }, take: 25, }); } catch { applications = []; } try { schedules = await prisma.radioSchedules.findMany({ select: { id: true, userId: true, day: true, startTime: true, endTime: true, showName: true, isActive: true, }, orderBy: { id: 'desc' }, take: 25, }); } catch { schedules = []; } const pendingApps = applications.filter( (a) => a.status.toLowerCase() === 'pending', ).length; const activeSchedules = schedules.filter((sc) => sc.isActive).length; return (

{t("title")}

{t("subtitle")}

0 ? 'warn' : 'ok'} icon="\u{1F4DD}" /> 0 ? 'ok' : 'neutral'} icon="\u{1F399}\uFE0F" />

{t("shouts")} ({shouts.length})

{shouts.length === 0 ? (

{t("noShouts")}

) : ( {shouts.map((s) => ( ))}
ID {t("user")} {t("message")} {t("posted")}
{String(s.id)} {String(s.userId)} {s.message} {formatDate(s.createdAt)}
)}

{t("applications")} ({applications.length})

{applications.length === 0 ? (

{t("noApplications")}

) : ( {applications.map((a) => ( ))}
ID {t("user")} {t("realName")} {t("age")} {t("style")} Discord {t("status")} {t("applied")}
{String(a.id)} {String(a.userId)} {a.realName} {a.age} {a.musicStyle ?? '\u2014'} {a.discordUsername ?? '\u2014'} {a.status} {formatDate(a.createdAt)}
)}

{t("schedules")} ({schedules.length})

{schedules.length === 0 ? (

{t("noSchedules")}

) : ( {schedules.map((sc) => ( ))}
ID {t("user")} {t("day")} {t("start")} {t("end")} {t("show")} {t("active")}
{String(sc.id)} {String(sc.userId)} {sc.day} {formatTime(sc.startTime)} {formatTime(sc.endTime)} {sc.showName ?? '\u2014'} {sc.isActive ? t("active") : t("inactive")}
)}
); }