From c3d618e239098ef637839693ff857bf434a8f591 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 27 Apr 2020 15:22:22 -0700 Subject: [PATCH] Implemented BOD-22 removing from production board. No automation surrounding it at this time. --- bodyshop_translations.babel | 47 +++++++++++++++++++ .../parts-status-pie.component.jsx | 14 +----- .../production-list-detail.component.jsx | 4 +- .../production-remove-button.component.jsx | 26 ++++++++++ client/src/translations/en_us/common.json | 6 ++- client/src/translations/es/common.json | 4 ++ client/src/translations/fr/common.json | 4 ++ 7 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 client/src/components/production-remove-button/production-remove-button.component.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index e0e128297..77be72128 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -11221,6 +11221,27 @@ + + remove + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + removecolumn false @@ -11265,6 +11286,32 @@ + + errors + + + removing + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + labels diff --git a/client/src/components/parts-status-pie/parts-status-pie.component.jsx b/client/src/components/parts-status-pie/parts-status-pie.component.jsx index 866a02eb2..7d9697a6d 100644 --- a/client/src/components/parts-status-pie/parts-status-pie.component.jsx +++ b/client/src/components/parts-status-pie/parts-status-pie.component.jsx @@ -1,16 +1,7 @@ -import React, { useState } from "react"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; import { Pie } from "@nivo/pie"; -import { useTranslation } from "react-i18next"; +import React from "react"; -const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, -}); - -export function PartsStatusPie({ partsList }) { - const { t } = useTranslation(); +export default function PartsStatusPie({ partsList }) { //const [pieData, setPieData] = useState([]); const result = partsList @@ -40,4 +31,3 @@ export function PartsStatusPie({ partsList }) { return ; } -export default connect(mapStateToProps, null)(PartsStatusPie); diff --git a/client/src/components/production-list-detail/production-list-detail.component.jsx b/client/src/components/production-list-detail/production-list-detail.component.jsx index 3c4cce7eb..fda1c792f 100644 --- a/client/src/components/production-list-detail/production-list-detail.component.jsx +++ b/client/src/components/production-list-detail/production-list-detail.component.jsx @@ -5,6 +5,7 @@ import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { DateFormatter } from "../../utils/DateFormatter"; import PartsPieGraph from "../parts-status-pie/parts-status-pie.component"; import Barcode from "react-barcode"; +import ProductionRemoveButton from "../production-remove-button/production-remove-button.component"; export default function ProductionListDetail({ selected, setSelected, jobs }) { const { t } = useTranslation(); @@ -14,7 +15,7 @@ export default function ProductionListDetail({ selected, setSelected, jobs }) { setSelected(null)} visible={!!selected}>
@@ -52,6 +53,7 @@ export default function ProductionListDetail({ selected, setSelected, jobs }) { +
); diff --git a/client/src/components/production-remove-button/production-remove-button.component.jsx b/client/src/components/production-remove-button/production-remove-button.component.jsx new file mode 100644 index 000000000..2a1d6fb4b --- /dev/null +++ b/client/src/components/production-remove-button/production-remove-button.component.jsx @@ -0,0 +1,26 @@ +import React from "react"; +import { useMutation } from "@apollo/react-hooks"; +import { UPDATE_JOB } from "../../graphql/jobs.queries"; +import { Button, notification } from "antd"; +import { useTranslation } from "react-i18next"; + +export default function ProductionRemoveButton({ jobId }) { + const [removeJobFromProduction] = useMutation(UPDATE_JOB); + const { t } = useTranslation(); + const handleRemoveFromProd = () => { + removeJobFromProduction({ + variables: { jobId: jobId, job: { inproduction: false } }, + }).catch((error) => { + notification["error"]({ + message: t("production.errors.removing", { + error: JSON.stringify(error), + }), + }); + }); + }; + return ( + + ); +} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 23cfff0d8..b69542675 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -61,7 +61,7 @@ "created": "Time", "operation": "Operation", "useremail": "User", - "values": "" + "values": "Values" } }, "bodyshop": { @@ -729,9 +729,13 @@ "bodypriority-set": "Set Body Priority", "paintpriority-clear": "Clear Paint Priority", "paintpriority-set": "Set Paint Priority", + "remove": "Remove from Production", "removecolumn": "Remove Column", "saveconfig": "Save Configuration" }, + "errors": { + "removing": "Error removing from production board. {{error}}" + }, "labels": { "alert": "Alert", "alertoff": "Remove alert from job", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 7e345dc89..12a92e53e 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -729,9 +729,13 @@ "bodypriority-set": "", "paintpriority-clear": "", "paintpriority-set": "", + "remove": "", "removecolumn": "", "saveconfig": "" }, + "errors": { + "removing": "" + }, "labels": { "alert": "", "alertoff": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 60a5e7e83..da725daef 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -729,9 +729,13 @@ "bodypriority-set": "", "paintpriority-clear": "", "paintpriority-set": "", + "remove": "", "removecolumn": "", "saveconfig": "" }, + "errors": { + "removing": "" + }, "labels": { "alert": "", "alertoff": "",