From 09d54722f0aaf74be55d125b990ee97f972075de Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 6 May 2022 14:25:02 -0700 Subject: [PATCH] IO-1863 Delete parts return and order line. --- .../parts-order-delete-line.component.jsx | 47 +++++++++++++++++++ .../parts-order-list-table.component.jsx | 22 ++++++--- client/src/graphql/parts-orders.queries.js | 8 ++++ 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx diff --git a/client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx b/client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx new file mode 100644 index 000000000..0edad9bb5 --- /dev/null +++ b/client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx @@ -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 ( + { + //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; + }); + }, + }, + }); + }, + }); + }} + > + + + ); +} diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index 9806b6cca..ed66ecdd7 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -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) => ( - + + + + ), }, ]; diff --git a/client/src/graphql/parts-orders.queries.js b/client/src/graphql/parts-orders.queries.js index e95537021..f415eeab6 100644 --- a/client/src/graphql/parts-orders.queries.js +++ b/client/src/graphql/parts-orders.queries.js @@ -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!