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