1 import { createColumnHelper } from "@tanstack/react-table"
2 import { useMemo } from "react"
3
4 import {
5 CollectionCell,
6 CollectionHeader,
7 } from "../../../components/table/table-cells/product/collection-cell/collection-cell"
8 import {
9 ProductCell,
10 ProductHeader,
11 } from "../../../components/table/table-cells/product/product-cell"
12 import {
13 ProductStatusCell,
14 ProductStatusHeader,
15 } from "../../../components/table/table-cells/product/product-status-cell"
16 import {
17 SalesChannelHeader,
18 SalesChannelsCell,
19 } from "../../../components/table/table-cells/product/sales-channels-cell"
20 import {
21 VariantCell,
22 VariantHeader,
23 } from "../../../components/table/table-cells/product/variant-cell"
24 import { HttpTypes } from "@medusajs/types"
25
26 const columnHelper = createColumnHelper<HttpTypes.AdminProduct>()
27
28 export const useProductTableColumns = () => {
29 return useMemo(
30 () => [
31 columnHelper.display({
32 id: "product",
33 header: () => <ProductHeader />,
34 cell: ({ row }) => <ProductCell product={row.original} />,
35 }),
36 columnHelper.accessor("collection", {
37 header: () => <CollectionHeader />,
38 cell: ({ row }) => (
39 <CollectionCell collection={row.original.collection} />
40 ),
41 }),
42 columnHelper.accessor("sales_channels", {
43 header: () => <SalesChannelHeader />,
44 cell: ({ row }) => (
45 <SalesChannelsCell salesChannels={row.original.sales_channels} />
46 ),
47 }),
48 columnHelper.accessor("variants", {
49 header: () => <VariantHeader />,
50 cell: ({ row }) => <VariantCell variants={row.original.variants} />,
51 }),
52 columnHelper.accessor("status", {
53 header: () => <ProductStatusHeader />,
54 cell: ({ row }) => <ProductStatusCell status={row.original.status} />,
55 }),
56 ],
57 []
58 )
59 }