import { Table } from "antd"; import Dinero from "dinero.js"; import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { alphaSort } from "../../utils/sorters"; export default function JobTotalsTableOther({ job }) { const { t } = useTranslation(); const [state, setState] = useState({ sortedInfo: {}, filteredInfo: {}, }); const data = useMemo(() => { return [ ...((job.job_totals.additional.additionalCostItems && job.job_totals.additional.additionalCostItems.map((i) => { return { key: i.key, total: i.total, }; })) || []), { key: t("jobs.fields.adjustment_bottom_line"), total: job.job_totals.additional.adjustments, }, { key: t("jobs.fields.towing_payable"), total: job.job_totals.additional.towing, }, { key: t("jobs.fields.storage_payable"), total: job.job_totals.additional.storage, }, // { // key: t("jobs.fields.ca_bc_pvrt"), // total: job.job_totals.additional.pvrt, // }, ]; }, [job.job_totals, t]); const columns = [ { title: t("general.labels.item"), dataIndex: "key", key: "key", sorter: (a, b) => alphaSort(a.key, b.key), sortOrder: state.sortedInfo.columnKey === "key" && state.sortedInfo.order, width: "0%", }, { title: t("joblines.fields.total"), dataIndex: "total", key: "total", sorter: (a, b) => a.total.amount - b.total.amount, sortOrder: state.sortedInfo.columnKey === "total" && state.sortedInfo.order, width: "20%", align: "right", render: (text, record) => Dinero(record.total).toFormat(), }, ]; const handleTableChange = (pagination, filters, sorter) => { setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); }; return (