Billing Table
A paginated table of invoice dates, status, amounts, and PDF links.
Página 1 de 1
0 de 5 seleccionados
Items por página
Página 1 de 1
Installation
pnpm dlx shadcn@latest add @ecodeliver/billing-tableInstalling this item also copies paginated-table.tsx.
Usage
Pass the full billings array. Date filtering is a TanStack column filter on emissionDate; the parent owns that state. Rows sort by emissionDate descending and paginate at 10 by default.
import { useState } from "react";
import { endOfDay, startOfDay, subDays } from "date-fns";
import { BillingTable } from "@/components/registry/billing-table";
import { DateRangeSelector } from "@/components/registry/date-range-picker";
export function Example() {
const [columnFilters, setColumnFilters] = useState(() => {
const to = endOfDay(new Date());
return [
{
id: "emissionDate",
value: { from: startOfDay(subDays(to, 29)), to },
},
];
});
return (
<>
<DateRangeSelector
value={columnFilters.find((filter) => filter.id === "emissionDate")?.value}
onDateChange={(range) =>
setColumnFilters([{ id: "emissionDate", value: range }])
}
presets={[
{ value: "30days", label: "Último mes", daysBack: 29 },
{ value: "90days", label: "Últimos 3 meses", daysBack: 89 },
{ value: "365days", label: "Último año", daysBack: 364 },
]}
/>
<BillingTable
billings={billings}
columnFilters={columnFilters}
onColumnFiltersChange={setColumnFilters}
/>
</>
);
}Display
- Fecha de emisión:
format(parseISO(emissionDate), "PP", { locale: es }) - Estado: badge, "Pendiente" or "Enviada"
- Importe:
es-ESEUR - Factura: link labeled
Factura <date>, opens in a new tab
The date-range filter uses isWithinInterval from date-fns. If from or to is missing, every row passes.
API Reference
BillingTable
The BillingTable component wraps PaginatedTable with billing columns.
| Prop | Type | Default |
|---|---|---|
billings | BillingEntry[] | - |
columnFilters | ColumnFiltersState | - |
onColumnFiltersChange | OnChangeFn<ColumnFiltersState> | - |
isPending | boolean | false |
BillingEntry
| Prop | Type | Default |
|---|---|---|
emissionDate | string | - |
state | "pending" | "sent" | - |
imports | number | - |
bill | string | - |