IO-2298 removed import destructure and added context reload

This commit is contained in:
swtmply
2023-05-26 00:48:28 +08:00
parent 209245187f
commit 3c4902f71f
2 changed files with 22 additions and 16 deletions

View File

@@ -3,8 +3,15 @@ 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 { connect } from "react-redux";
const PaymentReexportButton = ({ payment, refetch }) => {
const mapDispatchToProps = (dispatch) => ({
setPaymentContext: (context) =>
dispatch(setModalContext({ context: context, modal: "payment" })),
});
const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
const { t } = useTranslation();
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
@@ -26,6 +33,16 @@ const PaymentReexportButton = ({ payment, refetch }) => {
});
if (refetch) refetch();
setPaymentContext({
actions: {
refetch,
},
context: {
...payment,
exportedat: null,
},
});
} else {
notification["error"]({
message: t("payments.errors.exporting", {
@@ -46,4 +63,4 @@ const PaymentReexportButton = ({ payment, refetch }) => {
);
};
export default PaymentReexportButton;
export default connect(null, mapDispatchToProps)(PaymentReexportButton);