import { redirect } from "next/navigation"; import { getTranslations } from "next-intl/server"; import { getSessionUser } from "@/lib/session"; import { listInvoices, syncOverdueInvoices } from "@/lib/db"; import { BackLink } from "@/components/ui/back-link"; import { InvoicesTable } from "@/components/admin/billing/invoices-table"; /** * /admin/billing/invoices — list of all issued invoices, filterable * by status and month. Click a row to drill into detail. * * Server-renders the initial table with no filters applied (showing * the most recent 200). Client filters trigger a fetch with query * params and re-render in place. */ export default async function AdminInvoicesListPage() { const user = await getSessionUser(); if (!user) redirect("/login"); if (!user.isPlatform) redirect("/dashboard"); const t = await getTranslations("adminBilling"); await syncOverdueInvoices().catch((e) => console.error("syncOverdueInvoices failed:", e) ); const invoices = await listInvoices({ limit: 200 }); return (

{t("invoicesTitle")}

{t("invoicesPageDesc")}

); }