diff --git a/src/routes/dashboard/wallet/invoices.tsx b/src/routes/dashboard/wallet/invoices.tsx new file mode 100644 index 0000000..c0df219 --- /dev/null +++ b/src/routes/dashboard/wallet/invoices.tsx @@ -0,0 +1,120 @@ +import { createResource, createSignal, Show, For } from 'solid-js'; +import { A } from '@solidjs/router'; +import { getAuthHeader, authState, getRoleApiPath } from '~/lib/auth'; + +const API = import.meta.env.VITE_API_URL ?? 'http://localhost:8000'; + +const STATUS_BADGE: Record = { + ISSUED: 'badge--blue', + PAID: 'badge--green', +}; + +export default function WalletInvoices() { + const [page, setPage] = createSignal(1); + + const rc = () => authState().runtime_config; + const rolePrefix = () => getRoleApiPath(rc()?.role); + + const [invoices] = createResource(() => page(), async (p) => { + const auth = getAuthHeader(); + if (!auth.Authorization || !rc()?.role) return { data: [], pagination: null }; + const res = await fetch(`${API}${rolePrefix()}/invoices?page=${p}&limit=20`, { headers: auth }); + if (!res.ok) return { data: [], pagination: null }; + return res.json(); + }); + + return ( +
+
+
+

Invoices

+

+ Download receipts for all your purchases. +

+
+ ← Wallet +
+ +
+ +
Loading invoices…
+
+ + +
+
🧾
+

No invoices yet. Invoices are generated after a successful payment.

+
+
+ + 0}> + + + + + + + + + + + + + {(inv: any) => ( + + + + + + + + )} + + +
Invoice #DateAmountStatusDownload
+ {inv.invoice_number ?? '—'} + + {inv.issued_at ? new Date(inv.issued_at).toLocaleDateString('en-IN', { dateStyle: 'medium' }) : '—'} + + ₹{((inv.total ?? 0) / 100).toLocaleString('en-IN', { minimumFractionDigits: 2 })} + + + {inv.status ?? '—'} + + + + + Download PDF + + + + Generating… + +
+
+
+ + 1}> +
+ + + Page {page()} of {invoices()?.pagination?.total_pages} + + +
+
+
+ ); +}