IO-1213 Recalc totals on jobline insert.

This commit is contained in:
Patrick Fic
2021-06-21 09:36:03 -07:00
parent 0b2584e2f1
commit 6de9007c3a
2 changed files with 34 additions and 33 deletions

View File

@@ -73,7 +73,6 @@ class ErrorBoundary extends React.Component {
};
render() {
console.log("this.props :>> ", this.props);
const { t } = this.props;
const { error, info } = this.state;
if (this.state.hasErrored === true) {

View File

@@ -12,7 +12,7 @@ import { toggleModalVisible } from "../../redux/modals/modals.actions";
import { selectJobLineEditModal } from "../../redux/modals/modals.selectors";
import UndefinedToNull from "../../utils/undefinedtonull";
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
import Axios from "axios";
const mapStateToProps = createStructuredSelector({
jobLineEditModal: selectJobLineEditModal,
});
@@ -29,10 +29,10 @@ function JobLinesUpsertModalContainer({
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
const [loading, setLoading] = useState(false);
const handleFinish = (values) => {
const handleFinish = async (values) => {
setLoading(true);
if (!jobLineEditModal.context.id) {
insertJobLine({
const r = await insertJobLine({
variables: {
lineInput: [
{
@@ -44,42 +44,44 @@ function JobLinesUpsertModalContainer({
},
],
},
})
.then((r) => {
if (jobLineEditModal.actions.refetch)
jobLineEditModal.actions.refetch();
//Need to recalcuate totals.
toggleModalVisible();
notification["success"]({
message: t("joblines.successes.created"),
});
})
.catch((error) => {
notification["error"]({
message: t("joblines.errors.creating", {
message: error.message,
}),
});
});
if (!r.errors) {
await Axios.post("/job/totalsssu", {
id: jobLineEditModal.context.jobid,
});
if (jobLineEditModal.actions.refetch)
jobLineEditModal.actions.refetch();
//Need to recalcuate totals.
toggleModalVisible();
notification["success"]({
message: t("joblines.successes.created"),
});
} else {
notification["error"]({
message: t("joblines.errors.creating", {
message: JSON.stringify(r.errors.message),
}),
});
}
} else {
updateJobLine({
const r = await updateJobLine({
variables: {
lineId: jobLineEditModal.context.id,
line: values,
},
})
.then((r) => {
notification["success"]({
message: t("joblines.successes.updated"),
});
})
.catch((error) => {
notification["success"]({
message: t("joblines.errors.updating", {
message: error.message,
}),
});
});
if (!r.errors) {
notification["success"]({
message: t("joblines.successes.updated"),
});
} else {
notification["success"]({
message: t("joblines.errors.updating", {
message: JSON.stringify(r.errors.message),
}),
});
}
if (jobLineEditModal.actions.submit) {
jobLineEditModal.actions.submit();
} else {