|
1
|
import { createColumnHelper } from "@tanstack/react-table" |
|
2
|
import { useMemo } from "react" |
|
3
|
|
|
4
|
import { useTranslation } from "react-i18next" |
|
5
|
import { |
|
6
|
TextCell, |
|
7
|
TextHeader, |
|
8
|
} from "../../../components/table/table-cells/common/text-cell" |
|
9
|
import { HttpTypes } from "@medusajs/types" |
|
10
|
|
|
11
|
const columnHelper = createColumnHelper<HttpTypes.AdminCustomerGroup>() |
|
12
|
|
|
13
|
export const useCustomerGroupTableColumns = () => { |
|
14
|
const { t } = useTranslation() |
|
15
|
|
|
16
|
return useMemo( |
|
17
|
() => [ |
|
18
|
columnHelper.accessor("name", { |
|
19
|
header: () => <TextHeader text={t("fields.name")} />, |
|
20
|
cell: ({ getValue }) => <TextCell text={getValue() || "-"} />, |
|
21
|
}), |
|
22
|
columnHelper.accessor("customers", { |
|
23
|
header: () => <TextHeader text={t("customers.domain")} />, |
|
24
|
cell: ({ getValue }) => { |
|
25
|
const count = getValue()?.length ?? 0 |
|
26
|
|
|
27
|
return <TextCell text={count} /> |
|
28
|
}, |
|
29
|
}), |
|
30
|
], |
|
31
|
[t] |
|
32
|
) |
|
33
|
} |