diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index be64f43ba..7ebea2ac3 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -786,6 +786,27 @@ + + saving + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + @@ -1840,6 +1861,53 @@ + + shopinfo + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + + + successes + + + save + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index 93fe41845..a3d385f9b 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -1,5 +1,5 @@ import React from "react"; -import { Form, Input, Button } from "antd"; +import { Form, Input, Button, Collapse } from "antd"; import { useTranslation } from "react-i18next"; import ShopInfoROStatusComponent from "./shop-info.rostatus.component"; import ShopInfoOrderStatusComponent from "./shop-info.orderstatus.component"; @@ -12,56 +12,77 @@ export default function ShopInfoComponent({ form }) { + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); } diff --git a/client/src/components/shop-info/shop-info.container.jsx b/client/src/components/shop-info/shop-info.container.jsx index 63e95494c..134dfdd28 100644 --- a/client/src/components/shop-info/shop-info.container.jsx +++ b/client/src/components/shop-info/shop-info.container.jsx @@ -1,22 +1,35 @@ import React, { useEffect } from "react"; import ShopInfoComponent from "./shop-info.component"; -import { Form } from "antd"; +import { Form, notification } from "antd"; import { useQuery, useMutation } from "react-apollo"; import { QUERY_BODYSHOP, UPDATE_SHOP } from "../../graphql/bodyshop.queries"; import LoadingSpinner from "../loading-spinner/loading-spinner.component"; import AlertComponent from "../alert/alert.component"; - +import { useTranslation } from "react-i18next"; export default function ShopInfoContainer() { const [form] = Form.useForm(); + const { t } = useTranslation(); const [updateBodyshop] = useMutation(UPDATE_SHOP); - const { loading, error, data } = useQuery(QUERY_BODYSHOP, { + const { loading, error, data, refetch } = useQuery(QUERY_BODYSHOP, { fetchPolicy: "network-only" }); const handleFinish = values => { console.log("values", values); - updateBodyshop({ variables: { id: data.bodyshops[0].id, shop: values } }); + updateBodyshop({ + variables: { id: data.bodyshops[0].id, shop: values } + }) + .then(r => { + notification["success"]({ message: t("bodyshop.successes.save") }); + refetch().then(_ => form.resetFields()); + }) + .catch(error => { + notification["error"]( + { message: t("bodyshop.errors.saving") }, + { message: error } + ); + }); }; useEffect(() => { diff --git a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx index c8594acd3..fe7fa6b89 100644 --- a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx +++ b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx @@ -15,15 +15,15 @@ export default function ShopInfoResponsibilityCenterComponent({ form }) { const [options, setOptions] = useState( [ - ...form.getFieldValue(["md_responsibility_centers", "costs"]), - ...form.getFieldValue(["md_responsibility_centers", "profits"]) + ...(form.getFieldValue(["md_responsibility_centers", "costs"]) || []), + ...(form.getFieldValue(["md_responsibility_centers", "profits"]) || []) ] || [] ); const handleBlur = () => { setOptions([ - ...form.getFieldValue(["md_responsibility_centers", "costs"]), - ...form.getFieldValue(["md_responsibility_centers", "profits"]) + ...(form.getFieldValue(["md_responsibility_centers", "costs"]) || []), + ...(form.getFieldValue(["md_responsibility_centers", "profits"]) || []) ]); }; diff --git a/client/src/components/shop-info/shop-info.rostatus.component.jsx b/client/src/components/shop-info/shop-info.rostatus.component.jsx index 96734f3e0..ab22c2ee9 100644 --- a/client/src/components/shop-info/shop-info.rostatus.component.jsx +++ b/client/src/components/shop-info/shop-info.rostatus.component.jsx @@ -23,7 +23,6 @@ export default function ShopInfoROStatusComponent({ form }) { return (
- {t("bodyshop.labels.jobstatuses")} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 746ad10f6..0c71e41b3 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -69,7 +69,8 @@ "newstatus": "Add Status" }, "errors": { - "loading": "Unable to load shop details. Please call technical support." + "loading": "Unable to load shop details. Please call technical support.", + "saving": "Error encountered while saving. {{message}}" }, "fields": { "address1": "Address 1", @@ -128,7 +129,11 @@ "costs": "Cost Centers", "profits": "Profit Centers", "title": "Responsibility Centers" - } + }, + "shopinfo": "Shop Information" + }, + "successes": { + "save": "Bodyshop saved successfully. " } }, "documents": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 30c84bccf..674479dbc 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -69,7 +69,8 @@ "newstatus": "" }, "errors": { - "loading": "No se pueden cargar los detalles de la tienda. Por favor llame al soporte técnico." + "loading": "No se pueden cargar los detalles de la tienda. Por favor llame al soporte técnico.", + "saving": "" }, "fields": { "address1": "", @@ -128,7 +129,11 @@ "costs": "", "profits": "", "title": "" - } + }, + "shopinfo": "" + }, + "successes": { + "save": "" } }, "documents": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 1a33bda41..5966532e4 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -69,7 +69,8 @@ "newstatus": "" }, "errors": { - "loading": "Impossible de charger les détails de la boutique. Veuillez appeler le support technique." + "loading": "Impossible de charger les détails de la boutique. Veuillez appeler le support technique.", + "saving": "" }, "fields": { "address1": "", @@ -128,7 +129,11 @@ "costs": "", "profits": "", "title": "" - } + }, + "shopinfo": "" + }, + "successes": { + "save": "" } }, "documents": {