- env.ts: added 10 missing Zod-validated env vars (imager, paypal currency, argon2/bcrypt params) - Migrated 6 modules from process.env to validated env.* (auth, proxy-auth, paypal, password, redis, imager, moderation, alert, logger) - Replaced console.warn/error with pino logger in 9 server-side modules - Removed 50+ dead exports (SWF wrappers, coalesceHotelName, signIn, isStaff re-export, formatTimestamp, Skeleton/SkeletonCard, 4 unused housekeeping sections) - Consolidated date formatting: 28 files migrated to shared formatDate() from @/lib/format-date - Wired 4 radio/settings API routes through cached siteSettings service instead of raw Prisma queries - Added getMany()/getAll() helpers to SiteSettings service - Removed 88 dead Prisma model definitions (schema 2763→1846 lines) - Created admin action-helper.ts with wrapAction() for standardized error handling - Fixed useEffect dependency arrays in 4 data-heavy components - Replaced raw btn CSS classes with shadcn Button component across admin pages - Stripped dead i18n namespaces (common, pages.client) from all 22 translation files - Removed 2 dead scripts (create-release.sh, check-local-imports.ts) - Fixed knip.json configuration - Added 7 new test suites: format-date, paypal, moderation, alert, webhook, action-helper, and fixed password.test.ts for env mocking - All 358 tests passing across 72 test files - TypeScript: 0 errors
93 lines
2.1 KiB
TypeScript
93 lines
2.1 KiB
TypeScript
import { getTranslations } from "next-intl/server";
|
|
import { formatDate } from "@/lib/format-date";
|
|
import { deleteShout } from "@/actions/admin-radio-moderation";
|
|
import { StatusCard } from "@/components/admin/dashboard";
|
|
import { Button } from "@/components/ui/button";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
type Shout = {
|
|
id: bigint;
|
|
userId: bigint;
|
|
message: string;
|
|
createdAt: Date | null;
|
|
updatedAt: Date | null;
|
|
};
|
|
|
|
|
|
export default async function AdminRadioModerationPage() {
|
|
const t = await getTranslations("pages.admin.radio");
|
|
|
|
let shouts: Shout[] = [];
|
|
try {
|
|
shouts = await prisma.radioShouts.findMany({
|
|
select: {
|
|
id: true,
|
|
userId: true,
|
|
message: true,
|
|
createdAt: true,
|
|
updatedAt: true,
|
|
},
|
|
orderBy: { id: "desc" },
|
|
take: 50,
|
|
});
|
|
} catch {
|
|
shouts = [];
|
|
}
|
|
|
|
return (
|
|
<main>
|
|
|
|
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
|
|
<StatusCard
|
|
label={t("shouts")}
|
|
value={shouts.length}
|
|
icon="📣"
|
|
/>
|
|
</div>
|
|
|
|
<section className="mt-6">
|
|
<h2 className="admin-section-title">
|
|
{t("moderationPage.recentShouts", { count: shouts.length })}
|
|
</h2>
|
|
{shouts.length === 0 ? (
|
|
<div className="admin-empty">{t("noShouts")}</div>
|
|
) : (
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>{t("user")}</th>
|
|
<th>{t("message")}</th>
|
|
<th>{t("posted")}</th>
|
|
<th />
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{shouts.map((s) => (
|
|
<tr key={String(s.id)}>
|
|
<td>{String(s.id)}</td>
|
|
<td>{String(s.userId)}</td>
|
|
<td>{s.message}</td>
|
|
<td className="text-sm theme-text-muted dark:theme-text-muted whitespace-nowrap">
|
|
{formatDate(s.createdAt, "datetime", "\u2014")}
|
|
</td>
|
|
<td>
|
|
<form action={deleteShout}>
|
|
<input type="hidden" name="id" value={String(s.id)} />
|
|
<Button type="submit" variant="destructive">
|
|
{t("deleteShout")}
|
|
</Button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
)}
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|