|
1
|
import { HttpTypes } from "@medusajs/types"; |
|
2
|
import { useMemo } from "react"; |
|
3
|
|
|
4
|
import { createDataTableColumnHelper, Tooltip } from "@medusajs/ui"; |
|
5
|
import { DataTableStatusCell } from "../../components/data-table-status-cell/data-table-status-cell"; |
|
6
|
import { useDataTableDateColumns } from "../general/use-data-table-date-columns"; |
|
7
|
|
|
8
|
const columnHelper = createDataTableColumnHelper<HttpTypes.AdminSalesChannel>(); |
|
9
|
|
|
10
|
export const useSalesChannelTableColumns = () => { |
|
11
|
const dateColumns = useDataTableDateColumns<HttpTypes.AdminSalesChannel>(); |
|
12
|
|
|
13
|
return useMemo( |
|
14
|
() => [ |
|
15
|
columnHelper.accessor("name", { |
|
16
|
header: () => "Name", |
|
17
|
enableSorting: true, |
|
18
|
sortLabel: "Name", |
|
19
|
sortAscLabel: "Asc", |
|
20
|
sortDescLabel: "Desc", |
|
21
|
}), |
|
22
|
columnHelper.accessor("description", { |
|
23
|
header: () => "Description", |
|
24
|
cell: ({ getValue }) => { |
|
25
|
return ( |
|
26
|
<Tooltip content={getValue()}> |
|
27
|
<div className="flex h-full w-full items-center overflow-hidden"> |
|
28
|
<span className="truncate">{getValue()}</span> |
|
29
|
</div> |
|
30
|
</Tooltip> |
|
31
|
); |
|
32
|
}, |
|
33
|
enableSorting: true, |
|
34
|
sortLabel: "Description", |
|
35
|
sortAscLabel: "Asc", |
|
36
|
sortDescLabel: "Desc", |
|
37
|
maxSize: 250, |
|
38
|
minSize: 100, |
|
39
|
}), |
|
40
|
columnHelper.accessor("is_disabled", { |
|
41
|
header: () => "Status", |
|
42
|
enableSorting: true, |
|
43
|
sortLabel: "Status", |
|
44
|
sortAscLabel: "Asc", |
|
45
|
sortDescLabel: "Desc", |
|
46
|
cell: ({ getValue }) => { |
|
47
|
const value = getValue(); |
|
48
|
return ( |
|
49
|
<DataTableStatusCell color={value ? "grey" : "green"}> |
|
50
|
{value ? "Disabled" : "Enabled"} |
|
51
|
</DataTableStatusCell> |
|
52
|
); |
|
53
|
}, |
|
54
|
}), |
|
55
|
...dateColumns, |
|
56
|
], |
|
57
|
[dateColumns] |
|
58
|
); |
|
59
|
}; |