1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
"use client"
import * as React from "react"
import type {
DataTableAdvancedFilterField,
DataTableFilterField,
} from "@/types/table"
import { useDataTable } from "@/hooks/use-data-table"
import { DataTable } from "@/components/data-table/data-table"
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar"
import { getColumns, type EDPVendorRow } from "./edp-progress-table-columns"
import { EDPProgressTableToolbarActions } from "./edp-progress-table-toolbar-actions"
interface Props {
promises: Promise<[
{ data: EDPVendorRow[]; pageCount: number },
]>
}
export function EDPProgressTable({ promises }: Props) {
const columns = React.useMemo(() => getColumns(), [])
const [{ data, pageCount }] = React.use(promises)
const filterFields: DataTableFilterField<EDPVendorRow>[] = []
const advancedFilterFields: DataTableAdvancedFilterField<EDPVendorRow>[] = [
{ id: "vendorName", label: "Vendor Name", type: "text" },
{ id: "totalTags", label: "Tags", type: "number" },
{ id: "totalForms", label: "Forms", type: "number" },
{ id: "completionPercentage", label: "Completion %", type: "number" },
]
const { table } = useDataTable({
data,
columns,
pageCount,
filterFields,
enablePinning: true,
enableAdvancedFilter: true,
initialState: {
sorting: [{ id: "completionPercentage", desc: true }],
columnPinning: { left: ["select"], right: [] },
},
getRowId: (row) => String(row.vendorId),
shallow: false,
clearOnDefault: true,
})
return (
<DataTable table={table}>
<DataTableAdvancedToolbar
table={table}
filterFields={advancedFilterFields}
shallow={false}
>
<EDPProgressTableToolbarActions />
</DataTableAdvancedToolbar>
</DataTable>
)
}
|