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 BabelEdit project file

View File

@@ -1,9 +1,9 @@
import { useMutation } from "@apollo/react-hooks"; import { useMutation } from "@apollo/react-hooks";
import React from "react"; import React, { useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import { Button } from "antd"; import { Button, notification } from "antd";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { UPDATE_SHOP } from "../../graphql/bodyshop.queries"; import { UPDATE_SHOP } from "../../graphql/bodyshop.queries";
import { logImEXEvent } from "../../firebase/firebase.utils"; import { logImEXEvent } from "../../firebase/firebase.utils";
@@ -22,12 +22,13 @@ export function ProductionListSaveConfigButton({
tableState, tableState,
}) { }) {
const [updateShop] = useMutation(UPDATE_SHOP); const [updateShop] = useMutation(UPDATE_SHOP);
const [loading, setLoading] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
const handleSaveConfig = async () => { const handleSaveConfig = async () => {
logImEXEvent("production_save_config"); logImEXEvent("production_save_config");
setLoading(true);
await updateShop({ const result = await updateShop({
variables: { variables: {
id: bodyshop.id, id: bodyshop.id,
shop: { 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 ( return (
<Button onClick={() => handleSaveConfig()}> <Button loading={loading} onClick={() => handleSaveConfig()}>
{t("production.actions.saveconfig")} {t("production.actions.saveconfig")}
</Button> </Button>
); );

View File

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