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 { GenerateDocument } from "../../utils/RenderTemplate";
|
||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
import PaymentForm from "../payment-form/payment-form.component";
|
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";
|
import PaymentReexportButton from "../payment-reexport-button/payment-reexport-button.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
@@ -179,23 +179,12 @@ function PaymentModalContainer({
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Space>
|
<Space>
|
||||||
<PaymentReexportButton
|
<PaymentReexportButton payment={context} refetch={actions.refetch} />
|
||||||
payment={context}
|
|
||||||
refetch={() => {
|
|
||||||
toggleModalVisible();
|
|
||||||
|
|
||||||
return actions.refetch;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<PaymentExportButton
|
<PaymentExportButton
|
||||||
bodyshop={bodyshop}
|
bodyshop={bodyshop}
|
||||||
paymentId={context.id}
|
paymentId={context.id}
|
||||||
disabled={!!context.exportedat}
|
disabled={!!context.exportedat}
|
||||||
refetch={() => {
|
refetch={actions.refetch}
|
||||||
toggleModalVisible();
|
|
||||||
|
|
||||||
return actions.refetch;
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
<Form
|
<Form
|
||||||
|
|||||||
@@ -3,8 +3,15 @@ import { Button, notification } from "antd";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||||
import { useMutation } from "@apollo/client";
|
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 { t } = useTranslation();
|
||||||
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
|
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
|
||||||
|
|
||||||
@@ -26,6 +33,16 @@ const PaymentReexportButton = ({ payment, refetch }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (refetch) refetch();
|
if (refetch) refetch();
|
||||||
|
|
||||||
|
setPaymentContext({
|
||||||
|
actions: {
|
||||||
|
refetch,
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
...payment,
|
||||||
|
exportedat: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting", {
|
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