IO-1213 Recalc totals on jobline insert.
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user