Revert "Add missing admin action files and navigation links"

This reverts commit 41be6835bf.
This commit is contained in:
Simo committed 2026-07-11 20:37:56 +02:00
1 parent 4a1e1115b3
commit 4d515bc400
338 files changed
+5949 -28144

No files matched your search

+34 -42
View File
@@ -1,10 +1,10 @@
import Link from "next/link";
import { prisma } from "@/lib/prisma";
import { deleteShout } from "@/actions/admin-radio-moderation";
import { StatusCard } from "@/components/admin/dashboard";
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";
export const dynamic = 'force-dynamic';
type Shout = {
id: bigint;
@@ -35,18 +35,18 @@ type Schedule = {
};
function formatDate(d: Date | null): string {
return d ? d.toISOString().slice(0, 16).replace("T", " ") : "\u2014";
return d ? d.toISOString().slice(0, 16).replace('T', ' ') : '\u2014';
}
function formatTime(d: Date | null): string {
return d ? d.toISOString().slice(11, 16) : "\u2014";
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 "";
if (s === 'approved' || s === 'accepted') return 'ok';
if (s === 'rejected' || s === 'denied') return 'danger';
return '';
}
export default async function AdminRadioPage() {
@@ -59,7 +59,7 @@ export default async function AdminRadioPage() {
try {
shouts = await prisma.radioShouts.findMany({
select: { id: true, userId: true, message: true, createdAt: true },
orderBy: { id: "desc" },
orderBy: { id: 'desc' },
take: 25,
});
} catch {
@@ -78,7 +78,7 @@ export default async function AdminRadioPage() {
discordUsername: true,
createdAt: true,
},
orderBy: { id: "desc" },
orderBy: { id: 'desc' },
take: 25,
});
} catch {
@@ -96,50 +96,52 @@ export default async function AdminRadioPage() {
showName: true,
isActive: true,
},
orderBy: { id: "desc" },
orderBy: { id: 'desc' },
take: 25,
});
} catch {
schedules = [];
}
const pendingApps = applications.filter((a) => a.status.toLowerCase() === "pending").length;
const pendingApps = applications.filter(
(a) => a.status.toLowerCase() === 'pending',
).length;
const activeSchedules = schedules.filter((sc) => sc.isActive).length;
return (
<main>
<nav className="text-xs text-gray-500 dark:text-gray-400 mb-2">
<Link href="/admin/radio">{t("title")}</Link> ·{" "}
<Link href="/admin/radio/settings">{t("settings")}</Link> ·{" "}
<Link href="/admin/radio/banners">{t("banners.title")}</Link> ·{" "}
<Link href="/admin/radio/ranks">{t("ranks")}</Link> ·{" "}
<Link href="/admin/radio">{t("title")}</Link> ·{' '}
<Link href="/admin/radio/settings">{t("settings")}</Link> ·{' '}
<Link href="/admin/radio/banners">{t("banners.title")}</Link> ·{' '}
<Link href="/admin/radio/ranks">{t("ranks")}</Link> ·{' '}
<Link href="/admin/radio/history">{t("history")}</Link>
</nav>
<h1>{t("title")}</h1>
<p className="text-xs text-gray-500 dark:text-gray-400">{t("subtitle")}</p>
<p className="text-xs text-gray-500 dark:text-gray-400">
{t("subtitle")}
</p>
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard label={t("shouts")} value={shouts.length} icon="\u{1F4E3}" />
<StatusCard
label={t("pendingApplications")}
value={pendingApps}
state={pendingApps > 0 ? "warn" : "ok"}
state={pendingApps > 0 ? 'warn' : 'ok'}
icon="\u{1F4DD}"
/>
<StatusCard label={t("schedules")} value={schedules.length} icon="\u{1F5D3}\uFE0F" />
<StatusCard
label={t("activeSchedules")}
value={activeSchedules}
state={activeSchedules > 0 ? "ok" : "neutral"}
state={activeSchedules > 0 ? 'ok' : 'neutral'}
icon="\u{1F399}\uFE0F"
/>
</div>
<section className="mt-6">
<h2>
{t("shouts")} ({shouts.length})
</h2>
<h2>{t("shouts")} ({shouts.length})</h2>
{shouts.length === 0 ? (
<p className="text-xs text-gray-500 dark:text-gray-400">{t("noShouts")}</p>
) : (
@@ -156,9 +158,7 @@ export default async function AdminRadioPage() {
<tbody>
{shouts.map((s) => (
<tr key={String(s.id)}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{String(s.id)}
</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{String(s.id)}</td>
<td>{String(s.userId)}</td>
<td>{s.message}</td>
<td className="text-sm text-gray-500 dark:text-gray-400">{formatDate(s.createdAt)}</td>
@@ -178,9 +178,7 @@ export default async function AdminRadioPage() {
</section>
<section className="mt-6">
<h2>
{t("applications")} ({applications.length})
</h2>
<h2>{t("applications")} ({applications.length})</h2>
{applications.length === 0 ? (
<p className="text-xs text-gray-500 dark:text-gray-400">{t("noApplications")}</p>
) : (
@@ -204,12 +202,10 @@ export default async function AdminRadioPage() {
<td>{String(a.userId)}</td>
<td>{a.realName}</td>
<td>{a.age}</td>
<td>{a.musicStyle ?? "\u2014"}</td>
<td>{a.discordUsername ?? "\u2014"}</td>
<td>{a.musicStyle ?? '\u2014'}</td>
<td>{a.discordUsername ?? '\u2014'}</td>
<td>
<span
className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${statusBadgeClass(a.status) === "ok" ? "bg-green-600/20 text-[var(--color-text)]" : statusBadgeClass(a.status) === "danger" ? "bg-red-500/22 text-[var(--color-text)]" : "bg-[var(--color-primary)]/18 text-[var(--color-text)]"}`}
>
<span className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${statusBadgeClass(a.status) === 'ok' ? 'bg-green-600/20 text-[var(--color-text)]' : statusBadgeClass(a.status) === 'danger' ? 'bg-red-500/22 text-[var(--color-text)]' : 'bg-[var(--color-primary)]/18 text-[var(--color-text)]'}`}>
{a.status}
</span>
</td>
@@ -222,9 +218,7 @@ export default async function AdminRadioPage() {
</section>
<section className="mt-6">
<h2>
{t("schedules")} ({schedules.length})
</h2>
<h2>{t("schedules")} ({schedules.length})</h2>
{schedules.length === 0 ? (
<p className="text-xs text-gray-500 dark:text-gray-400">{t("noSchedules")}</p>
) : (
@@ -248,11 +242,9 @@ export default async function AdminRadioPage() {
<td>{sc.day}</td>
<td>{formatTime(sc.startTime)}</td>
<td>{formatTime(sc.endTime)}</td>
<td>{sc.showName ?? "\u2014"}</td>
<td>{sc.showName ?? '\u2014'}</td>
<td>
<span
className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${sc.isActive ? "bg-green-600/20 text-[var(--color-text)]" : "bg-red-500/22 text-[var(--color-text)]"}`}
>
<span className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${sc.isActive ? 'bg-green-600/20 text-[var(--color-text)]' : 'bg-red-500/22 text-[var(--color-text)]'}`}>
{sc.isActive ? t("active") : t("inactive")}
</span>
</td>