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