|
1
|
import { createColumnHelper } from "@tanstack/react-table" |
|
2
|
import { useMemo } from "react" |
|
3
|
import { useTranslation } from "react-i18next" |
|
4
|
|
|
5
|
import { HttpTypes } from "@medusajs/types" |
|
6
|
import { |
|
7
|
TextCell, |
|
8
|
TextHeader, |
|
9
|
} from "../../../components/table/table-cells/common/text-cell" |
|
10
|
|
|
11
|
import { |
|
12
|
TypeCell, |
|
13
|
TypeHeader, |
|
14
|
} from "../../../components/table/table-cells/taxes/type-cell" |
|
15
|
|
|
16
|
const columnHelper = createColumnHelper<HttpTypes.AdminTaxRate>() |
|
17
|
|
|
18
|
export const useTaxRateTableColumns = () => { |
|
19
|
const { t } = useTranslation() |
|
20
|
|
|
21
|
return useMemo( |
|
22
|
() => [ |
|
23
|
columnHelper.display({ |
|
24
|
id: "name", |
|
25
|
header: () => <TextHeader text={t("fields.name")} />, |
|
26
|
cell: ({ row }) => <TextCell text={row.original.name} />, |
|
27
|
}), |
|
28
|
columnHelper.display({ |
|
29
|
id: "province", |
|
30
|
header: () => <TextHeader text={t("fields.province")} />, |
|
31
|
cell: ({ row }) => ( |
|
32
|
<TextCell text={row.original.tax_region.province_code ?? "-"} /> |
|
33
|
), |
|
34
|
}), |
|
35
|
columnHelper.display({ |
|
36
|
id: "rate", |
|
37
|
header: () => <TextHeader text={t("fields.rate")} />, |
|
38
|
cell: ({ row }) => <TextCell text={`${row.original.rate} %`} />, |
|
39
|
}), |
|
40
|
columnHelper.display({ |
|
41
|
id: "is_combinable", |
|
42
|
header: () => <TypeHeader text={t("fields.type")} />, |
|
43
|
cell: ({ row }) => ( |
|
44
|
<TypeCell is_combinable={row.original.is_combinable} /> |
|
45
|
), |
|
46
|
}), |
|
47
|
columnHelper.display({ |
|
48
|
id: "code", |
|
49
|
header: () => <TextHeader text={t("fields.code")} />, |
|
50
|
cell: ({ row }) => <TextCell text={row.original.code || "-"} />, |
|
51
|
}), |
|
52
|
], |
|
53
|
[] |
|
54
|
) |
|
55
|
} |