mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-02 16:19:08 +00:00
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
ColumnDef,
|
|
} from "@tanstack/react-table";
|
|
import { DataTable } from "@app/components/ui/data-table";
|
|
|
|
type TabFilter = {
|
|
id: string;
|
|
label: string;
|
|
filterFn: (row: any) => boolean;
|
|
};
|
|
|
|
interface DataTableProps<TData, TValue> {
|
|
columns: ColumnDef<TData, TValue>[];
|
|
data: TData[];
|
|
onRefresh?: () => void;
|
|
isRefreshing?: boolean;
|
|
addClient?: () => void;
|
|
columnVisibility?: Record<string, boolean>;
|
|
enableColumnVisibility?: boolean;
|
|
hideHeader?: boolean;
|
|
tabs?: TabFilter[];
|
|
defaultTab?: string;
|
|
}
|
|
|
|
export function ClientsDataTable<TData, TValue>({
|
|
columns,
|
|
data,
|
|
addClient,
|
|
onRefresh,
|
|
isRefreshing,
|
|
columnVisibility,
|
|
enableColumnVisibility,
|
|
hideHeader = false,
|
|
tabs,
|
|
defaultTab
|
|
}: DataTableProps<TData, TValue>) {
|
|
return (
|
|
<DataTable
|
|
columns={columns}
|
|
data={data || []}
|
|
persistPageSize="clients-table"
|
|
title={hideHeader ? undefined : "Clients"}
|
|
searchPlaceholder="Search clients..."
|
|
searchColumn="name"
|
|
onAdd={hideHeader ? undefined : addClient}
|
|
onRefresh={hideHeader ? undefined : onRefresh}
|
|
isRefreshing={isRefreshing}
|
|
addButtonText={hideHeader ? undefined : "Add Client"}
|
|
columnVisibility={columnVisibility}
|
|
enableColumnVisibility={enableColumnVisibility}
|
|
tabs={tabs}
|
|
defaultTab={defaultTab}
|
|
/>
|
|
);
|
|
}
|