Added confirmation for prod list save button IO-477

This commit is contained in:
Patrick Fic
2020-12-23 09:35:35 -08:00
parent c8532f668b
commit ad8d92e7ed
3 changed files with 18 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project be_version="2.7.1" version="1.2">
<babeledit_project version="1.2" be_version="2.7.1">
<!--
BabelEdit project file

View File

@@ -1,9 +1,9 @@
import { useMutation } from "@apollo/react-hooks";
import React from "react";
import React, { useState } from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { Button } from "antd";
import { Button, notification } from "antd";
import { useTranslation } from "react-i18next";
import { UPDATE_SHOP } from "../../graphql/bodyshop.queries";
import { logImEXEvent } from "../../firebase/firebase.utils";
@@ -22,12 +22,13 @@ export function ProductionListSaveConfigButton({
tableState,
}) {
const [updateShop] = useMutation(UPDATE_SHOP);
const [loading, setLoading] = useState(false);
const { t } = useTranslation();
const handleSaveConfig = async () => {
logImEXEvent("production_save_config");
await updateShop({
setLoading(true);
const result = await updateShop({
variables: {
id: bodyshop.id,
shop: {
@@ -40,10 +41,20 @@ export function ProductionListSaveConfigButton({
},
},
});
if (!!!result.errors) {
notification["success"]({ message: t("bodyshop.successes.save") });
} else {
notification["error"]({
message: t("bodyshop.errors.saving", {
error: JSON.stringify(result.errors),
}),
});
}
setLoading(false);
};
return (
<Button onClick={() => handleSaveConfig()}>
<Button loading={loading} onClick={() => handleSaveConfig()}>
{t("production.actions.saveconfig")}
</Button>
);

View File

@@ -382,7 +382,7 @@
"speedprint": "Speed Print Configuration"
},
"successes": {
"save": "Bodyshop saved successfully. "
"save": "Shop configuration saved successfully. "
},
"validation": {
"useremailmustexist": "This email is not a valid user."