import { HttpTypes } from "@medusajs/types" import { createDataTableColumnHelper, StatusBadge } from "@medusajs/ui" import { useTranslation } from "react-i18next" import { useMemo } from "react" import { PlaceholderCell } from "../../../components/table/table-cells/common/placeholder-cell" import { getFormattedAddress } from "../../../lib/addresses" import { FulfillmentSetType } from "../common/constants" import { ListSummary } from "../../../components/common/list-summary" import { LocationListTableActions } from "./location-list-table-actions" const columnHelper = createDataTableColumnHelper() export const useLocationListTableColumns = () => { const { t } = useTranslation() return useMemo( () => [ columnHelper.accessor("name", { header: t("fields.name"), cell: ({ getValue }) => { const name = getValue() if (!name) { return } return ( {name} ) }, }), columnHelper.accessor("address", { header: t("fields.address"), cell: ({ getValue, row }) => { const address = getValue() const location = row.original if (!address) { return } return (
{getFormattedAddress({ address: location.address as HttpTypes.AdminOrderAddress, }).join(", ")}
) }, }), columnHelper.accessor("fulfillment_sets", { id: "shipping_fulfillment", header: t("stockLocations.fulfillmentSets.shipping.header"), cell: ({ getValue }) => { const fulfillmentSets = getValue() const shippingSet = fulfillmentSets?.find( (f) => f.type === FulfillmentSetType.Shipping ) const fulfillmentSetExists = !!shippingSet return ( {t( fulfillmentSetExists ? "statuses.enabled" : "statuses.disabled" )} ) }, }), columnHelper.accessor("fulfillment_sets", { id: "pickup_fulfillment", header: t("stockLocations.fulfillmentSets.pickup.header"), cell: ({ getValue }) => { const fulfillmentSets = getValue() const pickupSet = fulfillmentSets?.find( (f) => f.type === FulfillmentSetType.Pickup ) const fulfillmentSetExists = !!pickupSet return ( {t( fulfillmentSetExists ? "statuses.enabled" : "statuses.disabled" )} ) }, }), columnHelper.accessor("sales_channels", { header: t("stockLocations.salesChannels.label"), cell: ({ getValue }) => { const salesChannels = getValue() if (!salesChannels?.length) { return } return (
s.name)} />
) }, }), columnHelper.display({ id: "action", cell: ({ row }) => , }), ], [t] ) }