IO-1689 Remove partner and acct path popups.
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
import { notification } from "antd";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { setPartnerVersion } from "../../redux/application/application.actions";
|
import { setPartnerVersion } from "../../redux/application/application.actions";
|
||||||
@@ -22,44 +19,46 @@ export default connect(
|
|||||||
)(PartnerPingComponent);
|
)(PartnerPingComponent);
|
||||||
|
|
||||||
export function PartnerPingComponent({ bodyshop, setPartnerVersion }) {
|
export function PartnerPingComponent({ bodyshop, setPartnerVersion }) {
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Create an scoped async function in the hook
|
// 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
|
// Execute the created function directly
|
||||||
checkPartnerStatus();
|
checkPartnerStatus(bodyshop);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [bodyshop]);
|
}, [bodyshop]);
|
||||||
|
|
||||||
return <></>;
|
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"),
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,16 +5,19 @@ import { connect } from "react-redux";
|
|||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import AccountingPayablesTable from "../../components/accounting-payables-table/accounting-payables-table.component";
|
import AccountingPayablesTable from "../../components/accounting-payables-table/accounting-payables-table.component";
|
||||||
import AlertComponent from "../../components/alert/alert.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 RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||||
import { QUERY_BILLS_FOR_EXPORT } from "../../graphql/accounting.queries";
|
import { QUERY_BILLS_FOR_EXPORT } from "../../graphql/accounting.queries";
|
||||||
import {
|
import {
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
|
import { selectPartnerVersion } from "../../redux/application/application.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
|
partnerVersion: selectPartnerVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@@ -26,6 +29,7 @@ export function AccountingPayablesContainer({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
|
partnerVersion,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -38,7 +42,8 @@ export function AccountingPayablesContainer({
|
|||||||
label: t("titles.bc.accounting-payables"),
|
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, {
|
const { loading, error, data } = useQuery(QUERY_BILLS_FOR_EXPORT, {
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only",
|
||||||
@@ -47,9 +52,24 @@ export function AccountingPayablesContainer({
|
|||||||
|
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
|
|
||||||
|
const noPath =
|
||||||
|
!partnerVersion?.qbpath &&
|
||||||
|
!(
|
||||||
|
bodyshop &&
|
||||||
|
(bodyshop.cdk_dealerid ||
|
||||||
|
bodyshop.pbs_serialnumber ||
|
||||||
|
bodyshop.accountingconfig.qbo)
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<RbacWrapper action="accounting:payables">
|
<RbacWrapper action="accounting:payables">
|
||||||
|
{noPath && (
|
||||||
|
<AlertComponent
|
||||||
|
type="error"
|
||||||
|
message={t("general.messages.noacctfilepath")}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<AccountingPayablesTable
|
<AccountingPayablesTable
|
||||||
loadaing={loading}
|
loadaing={loading}
|
||||||
bills={data ? data.bills : []}
|
bills={data ? data.bills : []}
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ import {
|
|||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||||
|
import { checkPartnerStatus } from "../../components/partner-ping/partner-ping.component";
|
||||||
|
import { selectPartnerVersion } from "../../redux/application/application.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
|
partnerVersion: selectPartnerVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@@ -25,6 +28,7 @@ export function AccountingPaymentsContainer({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
|
partnerVersion,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -37,7 +41,8 @@ export function AccountingPaymentsContainer({
|
|||||||
label: t("titles.bc.accounting-payments"),
|
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, {
|
const { loading, error, data } = useQuery(QUERY_PAYMENTS_FOR_EXPORT, {
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only",
|
||||||
@@ -45,10 +50,23 @@ export function AccountingPaymentsContainer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
|
const noPath =
|
||||||
|
!partnerVersion?.qbpath &&
|
||||||
|
!(
|
||||||
|
bodyshop &&
|
||||||
|
(bodyshop.cdk_dealerid ||
|
||||||
|
bodyshop.pbs_serialnumber ||
|
||||||
|
bodyshop.accountingconfig.qbo)
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<RbacWrapper action="accounting:payments">
|
<RbacWrapper action="accounting:payments">
|
||||||
|
{noPath && (
|
||||||
|
<AlertComponent
|
||||||
|
type="error"
|
||||||
|
message={t("general.messages.noacctfilepath")}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<AccountingPaymentsTable
|
<AccountingPaymentsTable
|
||||||
loadaing={loading}
|
loadaing={loading}
|
||||||
payments={data ? data.payments : []}
|
payments={data ? data.payments : []}
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ import {
|
|||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||||
|
import { checkPartnerStatus } from "../../components/partner-ping/partner-ping.component";
|
||||||
|
import { selectPartnerVersion } from "../../redux/application/application.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
|
partnerVersion: selectPartnerVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
@@ -25,6 +28,7 @@ export function AccountingReceivablesContainer({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
|
partnerVersion,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -37,7 +41,8 @@ export function AccountingReceivablesContainer({
|
|||||||
label: t("titles.bc.accounting-receivables"),
|
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, {
|
const { loading, error, data } = useQuery(QUERY_JOBS_FOR_EXPORT, {
|
||||||
variables: {
|
variables: {
|
||||||
@@ -48,9 +53,25 @@ export function AccountingReceivablesContainer({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||||
|
|
||||||
|
const noPath =
|
||||||
|
!partnerVersion?.qbpath &&
|
||||||
|
!(
|
||||||
|
bodyshop &&
|
||||||
|
(bodyshop.cdk_dealerid ||
|
||||||
|
bodyshop.pbs_serialnumber ||
|
||||||
|
bodyshop.accountingconfig.qbo)
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<RbacWrapper action="accounting:receivables">
|
<RbacWrapper action="accounting:receivables">
|
||||||
|
{noPath && (
|
||||||
|
<AlertComponent
|
||||||
|
type="error"
|
||||||
|
message={t("general.messages.noacctfilepath")}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<AccountingReceivablesTable
|
<AccountingReceivablesTable
|
||||||
loadaing={loading}
|
loadaing={loading}
|
||||||
jobs={data ? data.jobs : []}
|
jobs={data ? data.jobs : []}
|
||||||
|
|||||||
@@ -3,12 +3,19 @@ import React, { useEffect } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import AlertComponent from "../../components/alert/alert.component";
|
||||||
import JobsAvailableTableContainer from "../../components/jobs-available-table/jobs-available-table.container";
|
import JobsAvailableTableContainer from "../../components/jobs-available-table/jobs-available-table.container";
|
||||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||||
import {
|
import {
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
|
import { selectPartnerVersion } from "../../redux/application/application.selectors";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
partnerVersion: selectPartnerVersion,
|
||||||
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
setBreadcrumbs: (breadcrumbs) => dispatch(setBreadcrumbs(breadcrumbs)),
|
||||||
@@ -16,6 +23,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export function JobsAvailablePageContainer({
|
export function JobsAvailablePageContainer({
|
||||||
|
partnerVersion,
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
}) {
|
}) {
|
||||||
@@ -40,9 +48,16 @@ export function JobsAvailablePageContainer({
|
|||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<AlertComponent
|
||||||
|
type="warning"
|
||||||
|
message={t("general.messages.partnernotrunning")}
|
||||||
|
/>
|
||||||
<JobsAvailableTableContainer />
|
<JobsAvailableTableContainer />
|
||||||
</div>
|
</div>
|
||||||
</RbacWrapper>
|
</RbacWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default connect(null, mapDispatchToProps)(JobsAvailablePageContainer);
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(JobsAvailablePageContainer);
|
||||||
|
|||||||
Reference in New Issue
Block a user