import { h } from "@stencil/core";
import { getAlternateTableCellPart, tableHeadCell } from "../../styles/parts";
import { convertToLocal } from "../../utils/utils";
import { TerminalOrderType } from "../../api";
import { MapTerminalOrderStatusToBadge } from "./terminal-order-status";
export const defaultColumnsKeys = 'created_at,updated_at,order_status,quantity';
export const terminalOrdersTableColumns = {
    created_at: () => (h("th", { part: tableHeadCell, scope: "col", title: "The date and time the order was created" }, "Created At")),
    updated_at: () => (h("th", { part: tableHeadCell, scope: "col", title: "The date and time the order was last updated" }, "Updated At")),
    order_status: () => (h("th", { part: tableHeadCell, scope: "col", title: "The current status of the order" }, "Order Status")),
    business_id: () => (h("th", { part: tableHeadCell, scope: "col", title: "The business ID associated with the order" }, "Business ID")),
    company_name: () => (h("th", { part: tableHeadCell, scope: "col", title: "The business name associated with the order" }, "Business Name")),
    provider: () => (h("th", { part: tableHeadCell, scope: "col", title: "The provider associated with the order" }, "Provider")),
    order_type: () => (h("th", { part: tableHeadCell, scope: "col", title: "The type of order" }, "Order Type")),
    quantity: () => (h("th", { part: tableHeadCell, scope: "col", title: "The number of terminals associated with the order" }, "Order Quantity")),
};
export const terminalOrdersTableCells = {
    created_at: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, h("div", { class: "fw-bold" }, convertToLocal(terminalOrder.created_at, { showDisplayDate: true })), h("div", { class: "fw-bold" }, convertToLocal(terminalOrder.created_at, { showTime: true })))),
    updated_at: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, h("div", { class: "fw-bold" }, convertToLocal(terminalOrder.updated_at, { showDisplayDate: true })), h("div", { class: "fw-bold" }, convertToLocal(terminalOrder.updated_at, { showTime: true })))),
    order_status: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, MapTerminalOrderStatusToBadge(terminalOrder.order_status))),
    business_id: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, terminalOrder.business_id)),
    company_name: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, terminalOrder.company_name)),
    provider: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, terminalOrder.provider)),
    order_type: (terminalOrder, index) => {
        let orderType;
        if (terminalOrder.order_type === TerminalOrderType.boardingOnly) {
            orderType = 'Boarding Only';
        }
        else if (terminalOrder.order_type === TerminalOrderType.boardingShipping) {
            orderType = 'Boarding & Shipping';
        }
        return (h("td", { part: getAlternateTableCellPart(index) }, orderType));
    },
    quantity: (terminalOrder, index) => (h("td", { part: getAlternateTableCellPart(index) }, terminalOrder.terminals.length)),
};
