@@ -1,32 +1,30 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, Form, Modal, notification, Space } from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { INSERT_NEW_PAYMENT, UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectPayment } from "../../redux/modals/modals.selectors";
|
||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import {useMutation} from "@apollo/client";
|
||||
import {Button, Form, Modal, notification, Space} from "antd";
|
||||
import React, {useEffect, useState} from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {connect} from "react-redux";
|
||||
import {createStructuredSelector} from "reselect";
|
||||
import {INSERT_NEW_PAYMENT, UPDATE_PAYMENT} from "../../graphql/payments.queries";
|
||||
import {toggleModalVisible} from "../../redux/modals/modals.actions";
|
||||
import {selectPayment} from "../../redux/modals/modals.selectors";
|
||||
import {selectBodyshop} from "../../redux/user/user.selectors";
|
||||
import {GenerateDocument} from "../../utils/RenderTemplate";
|
||||
import {TemplateList} from "../../utils/TemplateConstants";
|
||||
import PaymentForm from "../payment-form/payment-form.component";
|
||||
import PaymentMarkForExportButton from "../payment-mark-export-button/payment-mark-export-button-component";
|
||||
import PaymentMarkForExportButton
|
||||
from "../payment-mark-export-button/payment-mark-export-button-component";
|
||||
import PaymentReexportButton from "../payment-reexport-button/payment-reexport-button.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
paymentModal: selectPayment,
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||
toggleModalVisible: () => dispatch(toggleModalVisible("payment"))
|
||||
});
|
||||
|
||||
function PaymentModalContainer({ paymentModal, toggleModalVisible, bodyshop, currentUser, setEmailOptions }) {
|
||||
function PaymentModalContainer({paymentModal, toggleModalVisible, bodyshop }) {
|
||||
const [form] = Form.useForm();
|
||||
const [enterAgain, setEnterAgain] = useState(false);
|
||||
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
||||
@@ -34,7 +32,7 @@ function PaymentModalContainer({ paymentModal, toggleModalVisible, bodyshop, cur
|
||||
|
||||
const { t } = useTranslation();
|
||||
const { context, actions, open } = paymentModal;
|
||||
|
||||
const { smartRefetch } = context;
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
@@ -90,8 +88,11 @@ function PaymentModalContainer({ paymentModal, toggleModalVisible, bodyshop, cur
|
||||
}
|
||||
}
|
||||
|
||||
if (actions.refetch) actions.refetch();
|
||||
|
||||
if (actions.refetch) {
|
||||
const updatedData = smartRefetch && updatedPayment ? updatedPayment.data.update_payments.returning[0] : undefined;
|
||||
actions.refetch(updatedData);
|
||||
}
|
||||
|
||||
if (enterAgain) {
|
||||
const prev = form.getFieldsValue(["date"]);
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ export function PaymentsListPaginated({
|
||||
}
|
||||
: refetch
|
||||
},
|
||||
context: apolloResults ? apolloResults : record
|
||||
context: apolloResults ? { smartRefetch: true, ...apolloResults} : {smartRefetch: true, ...record}
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user