import { createColumnHelper } from "@tanstack/react-table" import { useMemo } from "react" import { useTranslation } from "react-i18next" import { DateCell } from "../../../../../components/table/table-cells/common/date-cell" import { PlaceholderCell } from "../../../../../components/table/table-cells/common/placeholder-cell" import { formatQuantity } from "../../../../../lib/format-quantity" import { ReservationActions } from "./reservation-actions" import { ExtendedReservationItem } from "../../../../inventory/inventory-detail/components/reservations-table/use-reservation-list-table-columns" const columnHelper = createColumnHelper() export const useReservationTableColumns = () => { const { t } = useTranslation() return useMemo( () => [ columnHelper.accessor("inventory_item", { header: t("fields.sku"), cell: ({ getValue }) => { const inventoryItem = getValue() if (!inventoryItem || !inventoryItem.sku) { return } return (
{inventoryItem.sku}
) }, }), /** * TEMP: hide this column until a link is added */ // columnHelper.accessor("line_item", { // header: t("fields.order"), // cell: ({ getValue }) => { // const inventoryItem = getValue() // // if (!inventoryItem || !inventoryItem.order?.display_id) { // return // } // // return ( //
// // // #{inventoryItem.order.display_id} // // //
// ) // }, // }), columnHelper.accessor("description", { header: t("fields.description"), cell: ({ getValue }) => { const description = getValue() if (!description) { return } return (
{description}
) }, }), columnHelper.accessor("created_at", { header: t("fields.created"), cell: ({ getValue }) => { const created = getValue() return }, }), columnHelper.accessor("quantity", { header: () => (
{t("fields.quantity")}
), cell: ({ getValue, row }) => { const quantity = getValue() return (
{formatQuantity( quantity, row.original.inventory_item?.unit_of_measure )}
) }, }), columnHelper.display({ id: "actions", cell: ({ row }) => { const reservation = row.original return }, }), ], [t] ) }