IO-1863 Delete parts return and order line.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import React from "react";
|
||||
import { Button, Popconfirm } from "antd";
|
||||
import { DeleteFilled } from "@ant-design/icons";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DELETE_PARTS_ORDER_LINE } from "../../graphql/parts-orders.queries";
|
||||
import { useMutation } from "@apollo/client";
|
||||
|
||||
export default function PartsOrderDeleteLine({
|
||||
disabled,
|
||||
partsLineId,
|
||||
partsOrderId,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [deletePartsOrderLine] = useMutation(DELETE_PARTS_ORDER_LINE);
|
||||
return (
|
||||
<Popconfirm
|
||||
title={t("parts_orders.labels.confirmdelete")}
|
||||
disabled={disabled}
|
||||
onConfirm={async () => {
|
||||
//Delete the parts return.!
|
||||
|
||||
await deletePartsOrderLine({
|
||||
variables: { partsOrderLineId: partsLineId },
|
||||
update(cache) {
|
||||
cache.modify({
|
||||
id: cache.identify({
|
||||
__typename: "parts_orders",
|
||||
id: partsOrderId,
|
||||
}),
|
||||
fields: {
|
||||
parts_order_lines(cached, { readField }) {
|
||||
return cached.filter((c) => {
|
||||
return readField("id", c) !== partsLineId;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Button disabled={disabled}>
|
||||
<DeleteFilled />
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
);
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import { TemplateList } from "../../utils/TemplateConstants";
|
||||
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";
|
||||
import PartsOrderDeleteLine from "../parts-order-delete-line/parts-order-delete-line.component";
|
||||
import PartsOrderLineBackorderButton from "../parts-order-line-backorder-button/parts-order-line-backorder-button.component";
|
||||
import PartsReceiveModalContainer from "../parts-receive-modal/parts-receive-modal.container";
|
||||
import PrintWrapper from "../print-wrapper/print-wrapper.component";
|
||||
@@ -391,12 +392,21 @@ export function PartsOrderListTableComponent({
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<PartsOrderLineBackorderButton
|
||||
disabled={jobRO}
|
||||
partsOrderStatus={record.status}
|
||||
partsLineId={record.id}
|
||||
jobLineId={record.job_line_id}
|
||||
/>
|
||||
<Space wrap>
|
||||
<PartsOrderDeleteLine
|
||||
disabled={jobRO}
|
||||
partsOrderStatus={record.status}
|
||||
partsLineId={record.id}
|
||||
partsOrderId={selectedpartsorder}
|
||||
jobLineId={record.job_line_id}
|
||||
/>
|
||||
<PartsOrderLineBackorderButton
|
||||
disabled={jobRO}
|
||||
partsOrderStatus={record.status}
|
||||
partsLineId={record.id}
|
||||
jobLineId={record.job_line_id}
|
||||
/>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -292,6 +292,14 @@ export const DELETE_PARTS_ORDER = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const DELETE_PARTS_ORDER_LINE = gql`
|
||||
mutation DELETE_PARTS_ORDER_LINE($partsOrderLineId: uuid!) {
|
||||
delete_parts_order_lines_by_pk(id: $partsOrderLineId) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const MUTATION_UPDATE_PO_CM_REECEIVED = gql`
|
||||
mutation MUTATION_UPDATE_PO_CM_REECEIVED(
|
||||
$partsLineId: uuid!
|
||||
|
||||
Reference in New Issue
Block a user