Reapply "Add missing admin action files and navigation links"

This reverts commit 4d515bc400.
This commit is contained in:
Simo committed 2026-07-11 20:52:56 +02:00
1 parent 96ed768f14
commit 5b4228261a
338 files changed
+28143 -5948

No files matched your search

+33 -30
View File
@@ -1,10 +1,10 @@
import Link from 'next/link';
import { prisma } from '@/lib/prisma';
import { StatusCard } from '@/components/admin/dashboard';
import { Clock } from 'lucide-react';
import Link from "next/link";
import { prisma } from "@/lib/prisma";
import { StatusCard } from "@/components/admin/dashboard";
import { Clock } from "lucide-react";
import { getTranslations } from "next-intl/server";
export const dynamic = 'force-dynamic';
export const dynamic = "force-dynamic";
type History = {
id: bigint;
@@ -17,13 +17,13 @@ type History = {
};
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 formatDuration(start: Date, end: Date | null): string {
if (!end) return '\u2014';
if (!end) return "\u2014";
const ms = end.getTime() - start.getTime();
if (ms <= 0) return '\u2014';
if (ms <= 0) return "\u2014";
const mins = Math.round(ms / 60000);
const h = Math.floor(mins / 60);
const m = mins % 60;
@@ -48,7 +48,7 @@ export default async function AdminRadioHistoryPage() {
listenersCount: true,
notes: true,
},
orderBy: { startedAt: 'desc' },
orderBy: { startedAt: "desc" },
take: 100,
});
@@ -68,19 +68,16 @@ export default async function AdminRadioHistoryPage() {
}
const liveCount = history.filter((h) => !h.endedAt).length;
const peakListeners = history.reduce(
(max, h) => (h.listenersCount > max ? h.listenersCount : max),
0,
);
const peakListeners = history.reduce((max, h) => (h.listenersCount > max ? h.listenersCount : max), 0);
const uniqueDjs = new Set(history.map((h) => String(h.userId))).size;
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>
@@ -96,9 +93,7 @@ export default async function AdminRadioHistoryPage() {
{dbError ? (
<div className="admin-card mb-6">
<p className="text-xs text-gray-500 dark:text-gray-400 m-0">
{t("historyPage.dbError")}
</p>
<p className="text-xs text-gray-500 dark:text-gray-400 m-0">{t("historyPage.dbError")}</p>
</div>
) : (
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
@@ -106,7 +101,7 @@ export default async function AdminRadioHistoryPage() {
<StatusCard
label={t("historyPage.onAirNow")}
value={liveCount}
state={liveCount > 0 ? 'ok' : 'neutral'}
state={liveCount > 0 ? "ok" : "neutral"}
icon="\u{1F534}"
/>
<StatusCard label={t("historyPage.uniqueDjs")} value={uniqueDjs} icon="\u{1F9D1}\u200D\u{1F3A4}" />
@@ -114,9 +109,7 @@ export default async function AdminRadioHistoryPage() {
</div>
)}
{!dbError && history.length === 0 ? (
<div className="admin-empty">{t("historyPage.empty")}</div>
) : null}
{!dbError && history.length === 0 ? <div className="admin-empty">{t("historyPage.empty")}</div> : null}
{history.length > 0 ? (
<section className="mt-6">
@@ -139,18 +132,28 @@ export default async function AdminRadioHistoryPage() {
<tr key={String(h.id)}>
<td>{String(h.id)}</td>
<td>{names.get(String(h.userId)) ?? `#${String(h.userId)}`}</td>
<td>{h.showName ?? '\u2014'}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{formatDate(h.startedAt)}</td>
<td>{h.showName ?? "\u2014"}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{formatDate(h.startedAt)}
</td>
<td>
{h.endedAt ? (
<span className="text-sm text-gray-500 dark:text-gray-400">{formatDate(h.endedAt)}</span>
<span className="text-sm text-gray-500 dark:text-gray-400">
{formatDate(h.endedAt)}
</span>
) : (
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-green-600/20 text-[var(--color-text)]">{t("historyPage.onAir")}</span>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-green-600/20 text-[var(--color-text)]">
{t("historyPage.onAir")}
</span>
)}
</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{formatDuration(h.startedAt, h.endedAt)}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{formatDuration(h.startedAt, h.endedAt)}
</td>
<td>{h.listenersCount}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{h.notes ?? '\u2014'}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{h.notes ?? "\u2014"}
</td>
</tr>
))}
</tbody>