diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 2bf1b9018..d6fc28db9 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -5736,6 +5736,27 @@ inventory + + delete + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + list false @@ -17371,6 +17392,48 @@ + + edit + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + new + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -17399,6 +17462,74 @@ + + fields + + + comment + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + manualinvoicenumber + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + manualvendor + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + labels @@ -17423,6 +17554,27 @@ + + deleteconfirm + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + frombillinvoicenumber false @@ -17533,6 +17685,27 @@ successes + + deleted + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + inserted false @@ -17554,6 +17727,27 @@ + + updated + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/src/components/inventory-line-delete/inventory-line-delete.component.jsx b/client/src/components/inventory-line-delete/inventory-line-delete.component.jsx new file mode 100644 index 000000000..d31be9384 --- /dev/null +++ b/client/src/components/inventory-line-delete/inventory-line-delete.component.jsx @@ -0,0 +1,67 @@ +import { DeleteFilled } from "@ant-design/icons"; +import { useMutation } from "@apollo/client"; +import { Button, notification, Popconfirm } from "antd"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { DELETE_INVENTORY_LINE } from "../../graphql/inventory.queries"; +import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component"; + +export default function InventoryLineDelete({ + inventoryline, + disabled, + refetch, +}) { + const [loading, setLoading] = useState(false); + const { t } = useTranslation(); + const [deleteInventoryLine] = useMutation(DELETE_INVENTORY_LINE); + + const handleDelete = async () => { + setLoading(true); + const result = await deleteInventoryLine({ + variables: { lineId: inventoryline.id }, + // update(cache, { errors }) { + // cache.modify({ + // fields: { + // inventory(existingInventory, { readField }) { + // console.log(existingInventory); + // return existingInventory.filter( + // (invRef) => inventoryline.id !== readField("id", invRef) + // ); + // }, + // }, + // }); + // }, + }); + + if (!!!result.errors) { + notification["success"]({ message: t("inventory.successes.deleted") }); + } else { + //Check if it's an fkey violation. + + notification["error"]({ + message: t("bills.errors.deleting", { + error: JSON.stringify(result.errors), + }), + }); + } + if (refetch) refetch(); + setLoading(false); + }; + + return ( + }> + + + + + ); +} diff --git a/client/src/components/inventory-list/inventory-list.component.jsx b/client/src/components/inventory-list/inventory-list.component.jsx index 95dcdea13..9baa66de0 100644 --- a/client/src/components/inventory-list/inventory-list.component.jsx +++ b/client/src/components/inventory-list/inventory-list.component.jsx @@ -1,4 +1,4 @@ -import { SyncOutlined } from "@ant-design/icons"; +import { EditFilled, SyncOutlined, FileAddFilled } from "@ant-design/icons"; import { Button, Card, Input, Space, Table, Typography } from "antd"; import queryString from "query-string"; import React from "react"; @@ -6,18 +6,28 @@ import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { Link, useHistory, useLocation } from "react-router-dom"; import { createStructuredSelector } from "reselect"; +import { setModalContext } from "../../redux/modals/modals.actions"; import { selectBodyshop } from "../../redux/user/user.selectors"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import InventoryBillRo from "../inventory-bill-ro/inventory-bill-ro.component"; +import InventoryLineDelete from "../inventory-line-delete/inventory-line-delete.component"; const mapStateToProps = createStructuredSelector({ //currentUser: selectCurrentUser bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + setInventoryUpsertContext: (context) => + dispatch(setModalContext({ context: context, modal: "inventoryUpsert" })), }); -export function JobsList({ bodyshop, refetch, loading, jobs, total }) { +export function JobsList({ + bodyshop, + refetch, + loading, + jobs, + total, + setInventoryUpsertContext, +}) { const search = queryString.parse(useLocation().search); const { page, sortcolumn, sortorder } = search; const history = useHistory(); @@ -31,6 +41,15 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { sorter: true, //(a, b) => alphaSort(a.line_desc, b.line_desc), sortOrder: sortcolumn === "line_desc" && sortorder, + render: (text, record) => + record.billline?.bill?.job ? ( +
+
{text}
+ {`(${record.billline?.bill?.job?.v_model_yr} ${record.billline?.bill?.job?.v_make_desc} ${record.billline?.bill?.job?.v_model_desc})`} +
+ ) : ( + text + ), }, { title: t("inventory.labels.frombillinvoicenumber"), @@ -40,7 +59,12 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { //sorter: true, // (a, b) => alphaSort(a.ownr_ln, b.ownr_ln), //sortOrder: sortcolumn === "ownr_ln" && sortorder, - render: (text, record) => record.billline?.bill?.invoice_number, + render: (text, record) => + ( + (record.billline?.bill?.invoice_number || "") + + " " + + (record.manualinvoicenumber || "") + ).trim(), }, { title: t("inventory.labels.fromvendor"), @@ -50,7 +74,12 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { //sorter: true, // (a, b) => alphaSort(a.ownr_ln, b.ownr_ln), //sortOrder: sortcolumn === "ownr_ln" && sortorder, - render: (text, record) => record.billline?.bill?.vendor?.name, + render: (text, record) => + ( + (record.billline?.bill?.vendor?.name || "") + + " " + + (record.manualvendor || "") + ).trim(), }, { title: t("billlines.fields.actual_price"), @@ -70,6 +99,11 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { {record.actual_cost} ), }, + { + title: t("inventory.fields.comment"), + dataIndex: "comment", + key: "comment", + }, { title: t("inventory.labels.consumedbyjob"), dataIndex: "consumedbyjob", @@ -85,6 +119,30 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { ), }, + { + title: t("general.labels.actions"), + dataIndex: "actions", + key: "actions", + + ellipsis: true, + render: (text, record) => ( + + + + + ), + }, ]; const handleTableChange = (pagination, filters, sorter) => { @@ -113,7 +171,16 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) { )} - +