Merge branch 'feature/IO-2727-resolve-payment-refetch' into test-AIO

This commit is contained in:
Patrick Fic
2024-04-08 11:08:57 -07:00
4 changed files with 37 additions and 26 deletions

View File

@@ -8,16 +8,18 @@ import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectCurrentUser } from "../../redux/user/user.selectors";
import { selectPayment } from "../../redux/modals/modals.selectors";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser
currentUser: selectCurrentUser,
paymentModal: selectPayment
});
const mapDispatchToProps = (dispatch) => ({
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
});
const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentContext, currentUser }) => {
const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentContext, currentUser, paymentModal }) => {
const { t } = useTranslation();
const [insertExportLog, { loading: exportLogLoading }] = useMutation(INSERT_EXPORT_LOG);
const [updatePayment, { loading: updatePaymentLoading }] = useMutation(UPDATE_PAYMENT);
@@ -56,17 +58,20 @@ const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentCont
refetch
},
context: {
...paymentModal.context,
...payment,
smartRefetch: true,
exportedat: today
}
});
if (refetch)
refetch(
paymentUpdateResponse &&
paymentUpdateResponse.data.update_payments.returning[0]
);
if (refetch) {
if (paymentModal.context.refetchRequiresContext) {
refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
} else {
refetch();
}
}
} else {
notification["error"]({
message: t("payments.errors.exporting", {