"use client" import { Plus } from "lucide-react" import { Button } from "@/components/ui/button" interface Column { key: string header: string render?: (item: T) => React.ReactNode } interface DataTableProps { title: string data: T[] columns: Column[] onAddNew: () => void addButtonText: string isLoading?: boolean } export function DataTable>({ title, data, columns, onAddNew, addButtonText, isLoading = false }: DataTableProps) { return (
{/* Header with Title and Add Button */}

{title}

Total items: {data.length}

{/* Table */}
{columns.map((col) => ( ))} {isLoading ? ( ) : data.length === 0 ? ( ) : ( data.map((item, idx) => ( {columns.map((col) => ( ))} )) )}
{col.header}
Loading records...

No data available

Click "{addButtonText}" to get started

{col.render ? col.render(item) : item[col.key] || "—"}
) }