import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; type SubRow = { id: number; userId: number | null; subscriptionType: string | null; expiresAt: number; }; function fmt(ts: number): string { return new Date(ts * 1000).toISOString().slice(0, 16).replace("T", " "); } export default async function AdminSubscriptions() { const now = Math.floor(Date.now() / 1000); let active: SubRow[] = []; try { // Schema has no timestamp_end column; expiry = timestamp_start + duration. // Active subs are active=1 with a computed expiry still in the future. const rows = await prisma.usersSubscriptions.findMany({ where: { active: 1 }, orderBy: { id: "desc" }, take: 500, }); active = rows .map((r) => ({ id: r.id, userId: r.userId, subscriptionType: r.subscriptionType, expiresAt: (r.timestampStart ?? 0) + (r.duration ?? 0), })) .filter((r) => r.expiresAt > now) .sort((a, b) => a.expiresAt - b.expiresAt); } catch { active = []; } return (

Subscriptions

Active Habbo Club / VIP subscriptions (expiry > now). Read-only.

{active.map((s) => ( ))}
Sub ID User ID Type Expires
{s.id} {s.userId ?? "—"} {s.subscriptionType ?? "—"} {fmt(s.expiresAt)}
{active.length === 0 ?

No active subscriptions.

: null}
); }