From 1fa83d124d8f1d644ac1f51bc569d4b794f3b72e Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Wed, 27 Mar 2024 12:14:47 -0700 Subject: [PATCH] IO-2727 Payment Re-export/Export button Send data back to page Signed-off-by: Allan Carr --- .../payment-mark-export-button-component.jsx | 23 ++++++++++--------- .../payment-reexport-button.component.jsx | 19 +++++++-------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/client/src/components/payment-mark-export-button/payment-mark-export-button-component.jsx b/client/src/components/payment-mark-export-button/payment-mark-export-button-component.jsx index be6c80356..5f8cb395a 100644 --- a/client/src/components/payment-mark-export-button/payment-mark-export-button-component.jsx +++ b/client/src/components/payment-mark-export-button/payment-mark-export-button-component.jsx @@ -1,13 +1,13 @@ -import React from "react"; -import { Button, notification } from "antd"; import { useMutation } from "@apollo/client"; +import { Button, notification } from "antd"; +import React from "react"; import { useTranslation } from "react-i18next"; -import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; -import { setModalContext } from "../../redux/modals/modals.actions"; import { connect } from "react-redux"; -import { UPDATE_PAYMENT } from "../../graphql/payments.queries"; -import { selectCurrentUser } from "../../redux/user/user.selectors"; import { createStructuredSelector } from "reselect"; +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"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -46,7 +46,6 @@ const PaymentMarkForExportButton = ({ ], }, }); - const paymentUpdateResponse = await updatePayment({ variables: { paymentId: payment.id, @@ -55,16 +54,12 @@ const PaymentMarkForExportButton = ({ }, }, }); - if (!!!paymentUpdateResponse.errors) { notification.open({ type: "success", key: "paymentsuccessmarkforexport", message: t("payments.successes.markexported"), }); - - if (refetch) refetch(); - setPaymentContext({ actions: { refetch, @@ -74,6 +69,12 @@ const PaymentMarkForExportButton = ({ exportedat: today, }, }); + + if (refetch) + refetch( + paymentUpdateResponse && + paymentUpdateResponse.data.update_payments.returning[0] + ); } else { notification["error"]({ message: t("payments.errors.exporting", { diff --git a/client/src/components/payment-reexport-button/payment-reexport-button.component.jsx b/client/src/components/payment-reexport-button/payment-reexport-button.component.jsx index a3adb5422..a7434e76d 100644 --- a/client/src/components/payment-reexport-button/payment-reexport-button.component.jsx +++ b/client/src/components/payment-reexport-button/payment-reexport-button.component.jsx @@ -1,10 +1,10 @@ -import React from "react"; -import { Button, notification } from "antd"; -import { useTranslation } from "react-i18next"; -import { UPDATE_PAYMENT } from "../../graphql/payments.queries"; import { useMutation } from "@apollo/client"; -import { setModalContext } from "../../redux/modals/modals.actions"; +import { Button, notification } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; +import { UPDATE_PAYMENT } from "../../graphql/payments.queries"; +import { setModalContext } from "../../redux/modals/modals.actions"; const mapDispatchToProps = (dispatch) => ({ setPaymentContext: (context) => @@ -24,16 +24,12 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => { }, }, }); - if (!!!paymentUpdateResponse.errors) { notification.open({ type: "success", key: "paymentsuccessexport", message: t("payments.successes.markreexported"), }); - - if (refetch) refetch(); - setPaymentContext({ actions: { refetch, @@ -43,6 +39,11 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => { exportedat: null, }, }); + if (refetch) + refetch( + paymentUpdateResponse && + paymentUpdateResponse.data.update_payments.returning[0] + ); } else { notification["error"]({ message: t("payments.errors.exporting", {