Add contextRefect to payment export buttons.

This commit is contained in:
Patrick Fic
2024-04-08 09:48:39 -07:00
parent 1469960643
commit a2a7c1c58c
2 changed files with 24 additions and 12 deletions

View File

@@ -61,11 +61,13 @@ const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentCont
} }
}); });
if (refetch) if (refetch) {
refetch( if (context.refetchRequiresContext) {
paymentUpdateResponse && refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
paymentUpdateResponse.data.update_payments.returning[0] } else {
); refetch();
}
}
} else { } else {
notification["error"]({ notification["error"]({
message: t("payments.errors.exporting", { message: t("payments.errors.exporting", {

View File

@@ -5,12 +5,18 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { UPDATE_PAYMENT } from "../../graphql/payments.queries"; import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
import { setModalContext } from "../../redux/modals/modals.actions"; import { setModalContext } from "../../redux/modals/modals.actions";
import { selectPayment } from "../../redux/modals/modals.selectors";
import { createStructuredSelector } from "reselect";
const mapStateToProps = createStructuredSelector({
paymentModal: selectPayment
});
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" })) setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
}); });
const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => { const PaymentReexportButton = ({ paymentModal, payment, refetch, setPaymentContext }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT); const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
@@ -34,15 +40,19 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
refetch refetch
}, },
context: { context: {
...paymentModal.context,
...payment, ...payment,
exportedat: null exportedat: null
} }
}); });
if (refetch)
refetch( if (refetch) {
paymentUpdateResponse && if (context.refetchRequiresContext) {
paymentUpdateResponse.data.update_payments.returning[0] refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
); } else {
refetch();
}
}
} else { } else {
notification["error"]({ notification["error"]({
message: t("payments.errors.exporting", { message: t("payments.errors.exporting", {
@@ -59,4 +69,4 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
); );
}; };
export default connect(null, mapDispatchToProps)(PaymentReexportButton); export default connect(mapStateToProps, mapDispatchToProps)(PaymentReexportButton);