IO-2298 removed import destructure and added context reload
This commit is contained in:
@@ -19,7 +19,7 @@ import {
|
||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import PaymentForm from "../payment-form/payment-form.component";
|
||||
import { PaymentExportButton } from "../payment-export-button/payment-export-button.component";
|
||||
import PaymentExportButton from "../payment-export-button/payment-export-button.component";
|
||||
import PaymentReexportButton from "../payment-reexport-button/payment-reexport-button.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
@@ -179,23 +179,12 @@ function PaymentModalContainer({
|
||||
}
|
||||
>
|
||||
<Space>
|
||||
<PaymentReexportButton
|
||||
payment={context}
|
||||
refetch={() => {
|
||||
toggleModalVisible();
|
||||
|
||||
return actions.refetch;
|
||||
}}
|
||||
/>
|
||||
<PaymentReexportButton payment={context} refetch={actions.refetch} />
|
||||
<PaymentExportButton
|
||||
bodyshop={bodyshop}
|
||||
paymentId={context.id}
|
||||
disabled={!!context.exportedat}
|
||||
refetch={() => {
|
||||
toggleModalVisible();
|
||||
|
||||
return actions.refetch;
|
||||
}}
|
||||
refetch={actions.refetch}
|
||||
/>
|
||||
</Space>
|
||||
<Form
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user