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