From 8592c98b933fe33e427a40ef96587ab1dbaa497c Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 5 Oct 2020 12:27:08 -0700 Subject: [PATCH] Added job recalc when saving a line edit. BOD-385 --- bodyshop_translations.babel | 21 +++++++++++++++++++ client/src/App/App.container.jsx | 3 +++ .../job-detail-lines/job-lines.component.jsx | 3 ++- .../job-detail-lines/job-lines.container.jsx | 3 ++- .../job-lines-upsert-modal.container.jsx | 10 +++++++-- ...obs-documents-gallery.delete.component.jsx | 14 +++++-------- .../vehicle-tag-popover.component.jsx | 2 +- .../jobs-detail.page.component.jsx | 1 + client/src/translations/en_us/common.json | 5 +++-- client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 11 files changed, 48 insertions(+), 16 deletions(-) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 61ee4c189..1621a7dac 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -25960,6 +25960,27 @@ labels + + fromvehicle + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + updatevehicle false diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index f012f1cb5..fc04f2a02 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -37,6 +37,9 @@ export const axiosAuthInterceptorId = axios.interceptors.request.use( (error) => Promise.reject(error) ); +export const cleanAxios = axios.create(); +cleanAxios.interceptors.request.eject(axiosAuthInterceptorId); + if (process.env.NODE_ENV === "production") LogRocket.init("gvfvfw/bodyshopapp"); const httpLink = new HttpLink({ diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index 76482e71f..6f043bef7 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -40,6 +40,7 @@ export function JobLinesComponent({ setSelectedLines, job, setJobLineEditContext, + form, }) { const [state, setState] = useState({ sortedInfo: {}, @@ -259,7 +260,7 @@ export function JobLinesComponent({ disabled={jobRO} onClick={() => { setJobLineEditContext({ - actions: { refetch: refetch }, + actions: { refetch: refetch, submit: form && form.submit }, context: record, }); }} diff --git a/client/src/components/job-detail-lines/job-lines.container.jsx b/client/src/components/job-detail-lines/job-lines.container.jsx index 5a61953ea..ea1906a9b 100644 --- a/client/src/components/job-detail-lines/job-lines.container.jsx +++ b/client/src/components/job-detail-lines/job-lines.container.jsx @@ -1,7 +1,7 @@ import React, { useState } from "react"; import JobLinesComponent from "./job-lines.component"; -function JobLinesContainer({ job, joblines, refetch }) { +function JobLinesContainer({ job, joblines, refetch, form }) { const [searchText, setSearchText] = useState(""); const [selectedLines, setSelectedLines] = useState([]); @@ -39,6 +39,7 @@ function JobLinesContainer({ job, joblines, refetch }) { selectedLines={selectedLines} setSelectedLines={setSelectedLines} job={job} + form={form} /> ); } diff --git a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx index c7442188d..615b70df0 100644 --- a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx +++ b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.container.jsx @@ -1,6 +1,6 @@ +import { useMutation } from "@apollo/react-hooks"; import { notification } from "antd"; import React, { useState } from "react"; -import { useMutation } from "@apollo/react-hooks"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -27,6 +27,7 @@ function JobLinesUpsertModalContainer({ const [insertJobLine] = useMutation(INSERT_NEW_JOB_LINE); const [updateJobLine] = useMutation(UPDATE_JOB_LINE); const [loading, setLoading] = useState(false); + const handleFinish = (values) => { setLoading(true); if (!jobLineEditModal.context.id) { @@ -70,7 +71,12 @@ function JobLinesUpsertModalContainer({ }), }); }); - if (jobLineEditModal.actions.refetch) jobLineEditModal.actions.refetch(); + if (jobLineEditModal.actions.submit) { + jobLineEditModal.actions.submit(); + } else { + if (jobLineEditModal.actions.refetch) + jobLineEditModal.actions.refetch(); + } toggleModalVisible(); } setLoading(false); diff --git a/client/src/components/jobs-documents-gallery/jobs-documents-gallery.delete.component.jsx b/client/src/components/jobs-documents-gallery/jobs-documents-gallery.delete.component.jsx index 550063213..62914c0e5 100644 --- a/client/src/components/jobs-documents-gallery/jobs-documents-gallery.delete.component.jsx +++ b/client/src/components/jobs-documents-gallery/jobs-documents-gallery.delete.component.jsx @@ -1,18 +1,14 @@ +import { QuestionCircleOutlined } from "@ant-design/icons"; +import { useMutation } from "@apollo/react-hooks"; import { Button, notification, Popconfirm } from "antd"; +import axios from "axios"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; -import axios from "axios"; -import { useMutation } from "@apollo/react-hooks"; -import { DELETE_DOCUMENT } from "../../graphql/documents.queries"; +import { cleanAxios } from "../../App/App.container"; import { logImEXEvent } from "../../firebase/firebase.utils"; -import { QuestionCircleOutlined } from "@ant-design/icons"; - -import { axiosAuthInterceptorId } from "../../App/App.container"; +import { DELETE_DOCUMENT } from "../../graphql/documents.queries"; //Context: currentUserEmail, bodyshop, jobid, invoiceid -var cleanAxios = axios.create(); -cleanAxios.interceptors.request.eject(axiosAuthInterceptorId); - export default function JobsDocumentsDeleteButton({ galleryImages, deletionCallback, diff --git a/client/src/components/vehicle-tag-popover/vehicle-tag-popover.component.jsx b/client/src/components/vehicle-tag-popover/vehicle-tag-popover.component.jsx index 4097a9060..f236761af 100644 --- a/client/src/components/vehicle-tag-popover/vehicle-tag-popover.component.jsx +++ b/client/src/components/vehicle-tag-popover/vehicle-tag-popover.component.jsx @@ -35,7 +35,7 @@ export default function VehicleTagPopoverComponent({ job }) { diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index 2ffcfdd4e..4e87de5b9 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -183,6 +183,7 @@ export function JobsDetailPage({ job={job} joblines={job.joblines} refetch={refetch} + form={form} />