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,8 +44,11 @@ function JobLinesUpsertModalContainer({
}, },
], ],
}, },
}) });
.then((r) => { if (!r.errors) {
await Axios.post("/job/totalsssu", {
id: jobLineEditModal.context.jobid,
});
if (jobLineEditModal.actions.refetch) if (jobLineEditModal.actions.refetch)
jobLineEditModal.actions.refetch(); jobLineEditModal.actions.refetch();
//Need to recalcuate totals. //Need to recalcuate totals.
@@ -53,33 +56,32 @@ function JobLinesUpsertModalContainer({
notification["success"]({ notification["success"]({
message: t("joblines.successes.created"), message: t("joblines.successes.created"),
}); });
}) } else {
.catch((error) => {
notification["error"]({ notification["error"]({
message: t("joblines.errors.creating", { message: t("joblines.errors.creating", {
message: error.message, 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"),
}); });
}) } else {
.catch((error) => {
notification["success"]({ notification["success"]({
message: t("joblines.errors.updating", { message: t("joblines.errors.updating", {
message: error.message, message: JSON.stringify(r.errors.message),
}), }),
}); });
}); }
if (jobLineEditModal.actions.submit) { if (jobLineEditModal.actions.submit) {
jobLineEditModal.actions.submit(); jobLineEditModal.actions.submit();
} else { } else {