Add contextRefect to payment export buttons.
This commit is contained in:
@@ -61,11 +61,13 @@ const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentCont
|
||||
}
|
||||
});
|
||||
|
||||
if (refetch)
|
||||
refetch(
|
||||
paymentUpdateResponse &&
|
||||
paymentUpdateResponse.data.update_payments.returning[0]
|
||||
);
|
||||
if (refetch) {
|
||||
if (context.refetchRequiresContext) {
|
||||
refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
|
||||
} else {
|
||||
refetch();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("payments.errors.exporting", {
|
||||
|
||||
@@ -5,12 +5,18 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||
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) => ({
|
||||
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
|
||||
});
|
||||
|
||||
const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
||||
const PaymentReexportButton = ({ paymentModal, payment, refetch, setPaymentContext }) => {
|
||||
const { t } = useTranslation();
|
||||
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
|
||||
|
||||
@@ -34,15 +40,19 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
||||
refetch
|
||||
},
|
||||
context: {
|
||||
...paymentModal.context,
|
||||
...payment,
|
||||
exportedat: null
|
||||
}
|
||||
});
|
||||
if (refetch)
|
||||
refetch(
|
||||
paymentUpdateResponse &&
|
||||
paymentUpdateResponse.data.update_payments.returning[0]
|
||||
);
|
||||
|
||||
if (refetch) {
|
||||
if (context.refetchRequiresContext) {
|
||||
refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
|
||||
} else {
|
||||
refetch();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notification["error"]({
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user