IO-751 Resolve job close hang with unsaved changes

This commit is contained in:
Patrick Fic
2021-03-09 09:51:38 -08:00
parent 0ab019b9f7
commit 8651e03de1
2 changed files with 11 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import { useApolloClient, useMutation } from "@apollo/client";
import { Button, Form, notification, Popconfirm, Space } from "antd";
import React, { useState } from "react";
import { useApolloClient, useMutation } from "@apollo/client";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { useHistory } from "react-router-dom";
@@ -34,6 +34,8 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
setLoading(true);
const result = await client.mutate({
mutation: generateJobLinesUpdatesForInvoicing(values.joblines),
refetchQueries: ["QUERY_JOB_CLOSE_DETAILS"],
awaitRefetchQueries: true,
});
if (!!!result.errors) {
notification["success"]({ message: t("jobs.successes.save") });
@@ -45,8 +47,8 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
}),
});
}
// form.resetFields();
// form.resetFields();
form.resetFields();
form.resetFields();
setLoading(false);
};
@@ -63,7 +65,11 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
});
if (!!!result.errors) {
notification["success"]({ message: t("job.successes.closed") });
setLoading(false);
notification["success"]({
message: t("jobs.successes.closed"),
});
history.push(`/manage/jobs/${job.id}`);
} else {
setLoading(false);