From 515de38fe6bbb6b19709b87f7f05f385255a5dd4 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 11 Apr 2022 17:12:27 -0700 Subject: [PATCH] IO-1689 Remove partner and acct path popups. --- .../partner-ping/partner-ping.component.jsx | 71 +++++++++---------- .../accounting-payables.container.jsx | 22 +++++- .../accounting-payments.container.jsx | 22 +++++- .../accounting-receivables.container.jsx | 23 +++++- .../jobs-available.page.container.jsx | 17 ++++- 5 files changed, 114 insertions(+), 41 deletions(-) diff --git a/client/src/components/partner-ping/partner-ping.component.jsx b/client/src/components/partner-ping/partner-ping.component.jsx index c61848dce..a911261f9 100644 --- a/client/src/components/partner-ping/partner-ping.component.jsx +++ b/client/src/components/partner-ping/partner-ping.component.jsx @@ -1,8 +1,5 @@ -import { notification } from "antd"; import axios from "axios"; import React, { useEffect } from "react"; -import { useTranslation } from "react-i18next"; - import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { setPartnerVersion } from "../../redux/application/application.actions"; @@ -22,44 +19,46 @@ export default connect( )(PartnerPingComponent); export function PartnerPingComponent({ bodyshop, setPartnerVersion }) { - const { t } = useTranslation(); - useEffect(() => { // Create an scoped async function in the hook - async function checkPartnerStatus() { - if (!bodyshop) return; - try { - //if (process.env.NODE_ENV === "development") return; - const PartnerResponse = await axios.post("http://localhost:1337/ping/"); - const { appver, qbpath } = PartnerResponse.data; - setPartnerVersion(appver); - console.log({ appver, qbpath }); - if ( - !qbpath && - !( - bodyshop && - (bodyshop.cdk_dealerid || - bodyshop.pbs_serialnumber || - bodyshop.accountingconfig.qbo) - ) - ) { - notification["error"]({ - title: "", - message: t("general.messages.noacctfilepath"), - }); - } - } catch (error) { - console.log(error); - notification["error"]({ - title: "", - message: t("general.messages.partnernotrunning"), - }); - } - } + // Execute the created function directly - checkPartnerStatus(); + checkPartnerStatus(bodyshop); // eslint-disable-next-line react-hooks/exhaustive-deps }, [bodyshop]); return <>; } + +export async function checkPartnerStatus(bodyshop, checkAcctPath = false) { + if (!bodyshop) return; + try { + //if (process.env.NODE_ENV === "development") return; + const PartnerResponse = await axios.post("http://localhost:1337/ping/"); + // const { + // appver, //qbpath + // } = PartnerResponse.data; + setPartnerVersion(PartnerResponse.data); + // if ( + // checkAcctPath && + // !qbpath && + // !( + // bodyshop && + // (bodyshop.cdk_dealerid || + // bodyshop.pbs_serialnumber || + // bodyshop.accountingconfig.qbo) + // ) + // ) { + // notification["error"]({ + // title: "", + // message: i18n.t("general.messages.noacctfilepath"), + // }); + // } + } catch (error) { + console.log("ImEX Online Partner is not running.", error); + // notification["error"]({ + // title: "", + // message: i18n.t("general.messages.partnernotrunning"), + // }); + } +} diff --git a/client/src/pages/accounting-payables/accounting-payables.container.jsx b/client/src/pages/accounting-payables/accounting-payables.container.jsx index 5cdc88857..b9e2a1a1e 100644 --- a/client/src/pages/accounting-payables/accounting-payables.container.jsx +++ b/client/src/pages/accounting-payables/accounting-payables.container.jsx @@ -5,16 +5,19 @@ import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import AccountingPayablesTable from "../../components/accounting-payables-table/accounting-payables-table.component"; import AlertComponent from "../../components/alert/alert.component"; +import { checkPartnerStatus } from "../../components/partner-ping/partner-ping.component"; import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component"; import { QUERY_BILLS_FOR_EXPORT } from "../../graphql/accounting.queries"; import { setBreadcrumbs, setSelectedHeader, } from "../../redux/application/application.actions"; +import { selectPartnerVersion } from "../../redux/application/application.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, + partnerVersion: selectPartnerVersion, }); const mapDispatchToProps = (dispatch) => ({ @@ -26,6 +29,7 @@ export function AccountingPayablesContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, + partnerVersion, }) { const { t } = useTranslation(); @@ -38,7 +42,8 @@ export function AccountingPayablesContainer({ label: t("titles.bc.accounting-payables"), }, ]); - }, [t, setBreadcrumbs, setSelectedHeader]); + checkPartnerStatus(bodyshop, true); + }, [t, setBreadcrumbs, setSelectedHeader, bodyshop]); const { loading, error, data } = useQuery(QUERY_BILLS_FOR_EXPORT, { fetchPolicy: "network-only", @@ -47,9 +52,24 @@ export function AccountingPayablesContainer({ if (error) return ; + const noPath = + !partnerVersion?.qbpath && + !( + bodyshop && + (bodyshop.cdk_dealerid || + bodyshop.pbs_serialnumber || + bodyshop.accountingconfig.qbo) + ); + return (
+ {noPath && ( + + )} ({ @@ -25,6 +28,7 @@ export function AccountingPaymentsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, + partnerVersion, }) { const { t } = useTranslation(); @@ -37,7 +41,8 @@ export function AccountingPaymentsContainer({ label: t("titles.bc.accounting-payments"), }, ]); - }, [t, setBreadcrumbs, setSelectedHeader]); + checkPartnerStatus(bodyshop, true); + }, [t, setBreadcrumbs, setSelectedHeader, bodyshop]); const { loading, error, data } = useQuery(QUERY_PAYMENTS_FOR_EXPORT, { fetchPolicy: "network-only", @@ -45,10 +50,23 @@ export function AccountingPaymentsContainer({ }); if (error) return ; - + const noPath = + !partnerVersion?.qbpath && + !( + bodyshop && + (bodyshop.cdk_dealerid || + bodyshop.pbs_serialnumber || + bodyshop.accountingconfig.qbo) + ); return (
+ {noPath && ( + + )} ({ @@ -25,6 +28,7 @@ export function AccountingReceivablesContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, + partnerVersion, }) { const { t } = useTranslation(); @@ -37,7 +41,8 @@ export function AccountingReceivablesContainer({ label: t("titles.bc.accounting-receivables"), }, ]); - }, [t, setBreadcrumbs, setSelectedHeader]); + checkPartnerStatus(bodyshop, true); + }, [t, setBreadcrumbs, setSelectedHeader, bodyshop]); const { loading, error, data } = useQuery(QUERY_JOBS_FOR_EXPORT, { variables: { @@ -48,9 +53,25 @@ export function AccountingReceivablesContainer({ }); if (error) return ; + + const noPath = + !partnerVersion?.qbpath && + !( + bodyshop && + (bodyshop.cdk_dealerid || + bodyshop.pbs_serialnumber || + bodyshop.accountingconfig.qbo) + ); + return (
+ {noPath && ( + + )} ({ setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)), @@ -16,6 +23,7 @@ const mapDispatchToProps = (dispatch) => ({ }); export function JobsAvailablePageContainer({ + partnerVersion, setBreadcrumbs, setSelectedHeader, }) { @@ -40,9 +48,16 @@ export function JobsAvailablePageContainer({ } /> +
); } -export default connect(null, mapDispatchToProps)(JobsAvailablePageContainer); +export default connect( + mapStateToProps, + mapDispatchToProps +)(JobsAvailablePageContainer);