|
|
|
|
@@ -1,5 +1,5 @@
|
|
|
|
|
import { DeleteFilled, EyeFilled, SyncOutlined } from "@ant-design/icons";
|
|
|
|
|
import { useMutation } from "@apollo/client";
|
|
|
|
|
import { useLazyQuery, useMutation } from "@apollo/client";
|
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Card,
|
|
|
|
|
@@ -13,20 +13,21 @@ import {
|
|
|
|
|
Table,
|
|
|
|
|
} from "antd";
|
|
|
|
|
import queryString from "query-string";
|
|
|
|
|
import React, { useState } from "react";
|
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
|
import { useLocation } from "react-router-dom";
|
|
|
|
|
import { createStructuredSelector } from "reselect";
|
|
|
|
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
|
|
|
|
import { QUERY_BILL_BY_PK } from "../../graphql/bills.queries";
|
|
|
|
|
import { DELETE_PARTS_ORDER } from "../../graphql/parts-orders.queries";
|
|
|
|
|
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
|
|
|
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
|
|
|
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
|
|
|
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
|
|
|
|
import { DateFormatter } from "../../utils/DateFormatter";
|
|
|
|
|
import { alphaSort } from "../../utils/sorters";
|
|
|
|
|
import { TemplateList } from "../../utils/TemplateConstants";
|
|
|
|
|
import { alphaSort } from "../../utils/sorters";
|
|
|
|
|
import DataLabel from "../data-label/data-label.component";
|
|
|
|
|
import PartsOrderBackorderEta from "../parts-order-backorder-eta/parts-order-backorder-eta.component";
|
|
|
|
|
import PartsOrderCmReceived from "../parts-order-cm-received/parts-order-cm-received.component";
|
|
|
|
|
@@ -78,19 +79,46 @@ export function PartsOrderListTableComponent({
|
|
|
|
|
const [state, setState] = useState({
|
|
|
|
|
sortedInfo: {},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const [returnfrombill, setReturnFromBill] = useState();
|
|
|
|
|
const [billData, setBillData] = useState();
|
|
|
|
|
const search = queryString.parse(useLocation().search);
|
|
|
|
|
const selectedpartsorder = search.partsorderid;
|
|
|
|
|
const [searchText, setSearchText] = useState("");
|
|
|
|
|
|
|
|
|
|
const [billQuery] = useLazyQuery(QUERY_BILL_BY_PK);
|
|
|
|
|
const [deletePartsOrder] = useMutation(DELETE_PARTS_ORDER);
|
|
|
|
|
|
|
|
|
|
const parts_orders = billsQuery.data ? billsQuery.data.parts_orders : [];
|
|
|
|
|
const { refetch } = billsQuery;
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (returnfrombill === null) {
|
|
|
|
|
setBillData(null);
|
|
|
|
|
} else {
|
|
|
|
|
const fetchData = async () => {
|
|
|
|
|
const result = await billQuery({
|
|
|
|
|
variables: { billid: returnfrombill },
|
|
|
|
|
});
|
|
|
|
|
setBillData(result.data);
|
|
|
|
|
};
|
|
|
|
|
fetchData();
|
|
|
|
|
}
|
|
|
|
|
}, [returnfrombill, billQuery]);
|
|
|
|
|
|
|
|
|
|
const recordActions = (record, showView = false) => (
|
|
|
|
|
<Space wrap>
|
|
|
|
|
{showView && (
|
|
|
|
|
<Button onClick={() => handleOnRowClick(record)}>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
if (record.returnfrombill) {
|
|
|
|
|
setReturnFromBill(record.returnfrombill);
|
|
|
|
|
} else {
|
|
|
|
|
setReturnFromBill(null);
|
|
|
|
|
}
|
|
|
|
|
handleOnRowClick(record);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<EyeFilled />
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
@@ -417,7 +445,11 @@ export function PartsOrderListTableComponent({
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<PageHeader
|
|
|
|
|
title={record && `${record.vendor.name} - ${record.order_number}`}
|
|
|
|
|
title={
|
|
|
|
|
billData
|
|
|
|
|
? `${record.vendor.name} - ${record.order_number} - ${t("bills.labels.returnfrombill")}: ${billData.bills_by_pk.invoice_number}`
|
|
|
|
|
: `${record.vendor.name} - ${record.order_number}`
|
|
|
|
|
}
|
|
|
|
|
extra={recordActions(record)}
|
|
|
|
|
/>
|
|
|
|
|
<Table
|
|
|
|
|
|