40 lines
No EOL
1.2 KiB
TypeScript
40 lines
No EOL
1.2 KiB
TypeScript
import Link from "next/link";
|
|
import { getPb, fmtGBP, fmtDate } from "../lib/pb";
|
|
import UnpaidClient from "./UnpaidClient";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function UnpaidPage() {
|
|
const pb = getPb();
|
|
let records: any[] = [];
|
|
let errorMsg: string | null = null;
|
|
|
|
try {
|
|
const r = await pb.collection("JEI_invoices").getList(1, 500, {
|
|
filter: 'payment_batch=""',
|
|
sort: "-invoice_date",
|
|
fields: "id,invoice_no,invoice_date,buyer_name_variant,customer_order_no,invoice_total,payment_batch",
|
|
});
|
|
records = r.items;
|
|
} catch (e: any) {
|
|
errorMsg = String(e?.message || e);
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<div className="flex items-center justify-between">
|
|
<h1 className="text-2xl font-bold text-brand-dark">Unpaid Invoices</h1>
|
|
<div className="text-sm text-slate-500">{records.length} unpaid</div>
|
|
</div>
|
|
|
|
{errorMsg && (
|
|
<div className="bg-red-50 border border-red-200 text-red-800 rounded p-4">
|
|
<div className="font-semibold">Cannot reach PocketBase</div>
|
|
<div className="text-sm mt-1">{errorMsg}</div>
|
|
</div>
|
|
)}
|
|
|
|
{!errorMsg && <UnpaidClient initialRecords={records} />}
|
|
</div>
|
|
);
|
|
} |