import moment from "moment"
import { useMemo } from "react"
import ReactCountryFlag from "react-country-flag"
import { useTranslation } from "react-i18next"
import { getColor } from "../../../utils/color"
import { isoAlpha2Countries } from "../../../utils/countries"
import { formatAmountWithSymbol } from "../../../utils/prices"
import Tooltip from "../../atoms/tooltip"
import StatusDot from "../../fundamentals/status-indicator"
import CustomerAvatarItem from "../../molecules/customer-avatar-item"
const useOrderTableColums = () => {
const { t } = useTranslation()
const decideStatus = (status) => {
switch (status) {
case "captured":
return (
)
case "awaiting":
return (
)
case "requires_action":
return (
)
case "canceled":
return (
)
default:
return (
)
}
}
const columns = useMemo(
() => [
{
Header:
{t("order-table-order", "Order")}
,
accessor: "display_id",
Cell: ({ cell: { value } }) => (
{`#${value}`}
),
},
{
Header: t("order-table-date-added", "Date added"),
accessor: "created_at",
Cell: ({ cell: { value } }) => (
{moment(value).format("DD MMM YYYY")}
),
},
{
Header: t("order-table-customer", "Customer"),
accessor: "customer",
Cell: ({ row, cell: { value } }) => (
),
},
{
Header: t("order-table-fulfillment", "Fulfillment"),
accessor: "fulfillment_status",
Cell: ({ cell: { value } }) => value,
},
{
Header: t("order-table-payment-status", "Payment status"),
accessor: "payment_status",
Cell: ({ cell: { value } }) => decideStatus(value),
},
{
Header: t("order-table-sales-channel", "Sales Channel"),
accessor: "sales_channel",
Cell: ({ cell: { value } }) => value?.name ?? "N/A",
},
{
Header: () => (
{t("order-table-total", "Total")}
),
accessor: "total",
Cell: ({ row, cell: { value } }) => (
{formatAmountWithSymbol({
amount: value,
currency: row.original.currency_code,
digits: 2,
})}
),
},
{
Header: "",
accessor: "currency_code",
Cell: ({ cell: { value } }) => (
{value.toUpperCase()}
),
},
{
Header: "",
accessor: "country_code",
Cell: ({ row }) => (
),
},
],
[]
)
return [columns]
}
export default useOrderTableColums