import { redirect } from "next/navigation"; import { getTranslations } from "next-intl/server"; import { createTicket } from "@/actions/help-tickets"; import { ContentCard, EmptyState, StatBlock } from "@/components/public/ui"; import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; function formatDate(d: Date | null): string { return d ? d.toISOString().slice(0, 16).replace("T", " ") : ""; } export default async function HelpTicketsPage() { const session = await auth(); if (!session?.user?.id) redirect("/login"); const t = await getTranslations("pages.helpTickets"); const userId = Number(session.user.id); let tickets: Awaited< ReturnType > = []; try { tickets = await prisma.websiteHelpCenterTickets.findMany({ where: { userId }, orderBy: { createdAt: "desc" }, take: 100, }); } catch { tickets = []; } const openCount = tickets.filter((t) => t.open).length; const closedCount = tickets.length - openCount; return (