From cd191dae70a6194b7a074dd72296bec7c90c6259 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 9 Dec 2021 14:22:49 -0800 Subject: [PATCH] IO-1567 Resolve refretch on export. --- .../jobs-close-export-button.component.jsx | 14 +++++--------- .../jobs-export-all-button.component.jsx | 4 +++- .../payable-export-all-button.component.jsx | 4 +++- .../payable-export-button.component.jsx | 4 +++- .../payment-export-button.component.jsx | 4 +++- .../payments-export-all-button.component.jsx | 4 +++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx b/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx index 8d783557e..ea1b6c870 100644 --- a/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx +++ b/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx @@ -15,7 +15,6 @@ import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; import { useHistory } from "react-router-dom"; - const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, currentUser: selectCurrentUser, @@ -30,7 +29,7 @@ export function JobsCloseExportButton({ }) { const history = useHistory(); const { t } = useTranslation(); - const [updateJob] = useMutation(UPDATE_JOB); + const [updateJob] = useMutation(UPDATE_JOB, {}); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); const [loading, setLoading] = useState(false); @@ -46,13 +45,9 @@ export function JobsCloseExportButton({ //Check if it's a QBO Setup. let PartnerResponse; if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { - PartnerResponse = await axios.post( - `/qbo/receivables`, - { - jobIds: [jobId], - }, - - ); + PartnerResponse = await axios.post(`/qbo/receivables`, { + jobIds: [jobId], + }); } else { //Default is QBD @@ -155,6 +150,7 @@ export function JobsCloseExportButton({ date_exported: new Date(), }, }, + refetchQueries: ["QUERY_JOBS_FOR_EXPORT "], }); if (!jobUpdateResponse.errors) { diff --git a/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx b/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx index 80aa92f7f..074b312cc 100644 --- a/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx +++ b/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx @@ -28,7 +28,9 @@ export function JobsExportAllButton({ completedCallback, }) { const { t } = useTranslation(); - const [updateJob] = useMutation(UPDATE_JOBS); + const [updateJob] = useMutation(UPDATE_JOBS, { + refetchQueries: ["QUERY_JOBS_FOR_EXPORT "], + }); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); const [loading, setLoading] = useState(false); diff --git a/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx b/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx index 0cfe607df..cb0593ec4 100644 --- a/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx +++ b/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx @@ -29,7 +29,9 @@ export function PayableExportAll({ completedCallback, }) { const { t } = useTranslation(); - const [updateBill] = useMutation(UPDATE_BILLS); + const [updateBill] = useMutation(UPDATE_BILLS, { + refetchQueries: ["QUERY_BILLS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); diff --git a/client/src/components/payable-export-button/payable-export-button.component.jsx b/client/src/components/payable-export-button/payable-export-button.component.jsx index 17a2acedb..4b3135a26 100644 --- a/client/src/components/payable-export-button/payable-export-button.component.jsx +++ b/client/src/components/payable-export-button/payable-export-button.component.jsx @@ -28,7 +28,9 @@ export function PayableExportButton({ setSelectedBills, }) { const { t } = useTranslation(); - const [updateBill] = useMutation(UPDATE_BILLS); + const [updateBill] = useMutation(UPDATE_BILLS, { + refetchQueries: ["QUERY_BILLS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); diff --git a/client/src/components/payment-export-button/payment-export-button.component.jsx b/client/src/components/payment-export-button/payment-export-button.component.jsx index 0d50032c4..4927ca3d9 100644 --- a/client/src/components/payment-export-button/payment-export-button.component.jsx +++ b/client/src/components/payment-export-button/payment-export-button.component.jsx @@ -28,7 +28,9 @@ export function PaymentExportButton({ setSelectedPayments, }) { const { t } = useTranslation(); - const [updatePayment] = useMutation(UPDATE_PAYMENTS); + const [updatePayment] = useMutation(UPDATE_PAYMENTS, { + refetchQueries: ["QUERY_PAYMENTS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); diff --git a/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx b/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx index b24536210..c8f769ec4 100644 --- a/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx +++ b/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx @@ -27,7 +27,9 @@ export function PaymentsExportAllButton({ completedCallback, }) { const { t } = useTranslation(); - const [updatePayments] = useMutation(UPDATE_PAYMENTS); + const [updatePayments] = useMutation(UPDATE_PAYMENTS, { + refetchQueries: ["QUERY_PAYMENTS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);