Merge branch 'feature/IO-2727-resolve-payment-refetch' into test-AIO
This commit is contained in:
@@ -8,16 +8,18 @@ import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
|||||||
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
|
import { selectPayment } from "../../redux/modals/modals.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser
|
currentUser: selectCurrentUser,
|
||||||
|
paymentModal: selectPayment
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
|
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
|
||||||
});
|
});
|
||||||
|
|
||||||
const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentContext, currentUser }) => {
|
const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentContext, currentUser, paymentModal }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [insertExportLog, { loading: exportLogLoading }] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog, { loading: exportLogLoading }] = useMutation(INSERT_EXPORT_LOG);
|
||||||
const [updatePayment, { loading: updatePaymentLoading }] = useMutation(UPDATE_PAYMENT);
|
const [updatePayment, { loading: updatePaymentLoading }] = useMutation(UPDATE_PAYMENT);
|
||||||
@@ -56,17 +58,20 @@ const PaymentMarkForExportButton = ({ bodyshop, payment, refetch, setPaymentCont
|
|||||||
refetch
|
refetch
|
||||||
},
|
},
|
||||||
context: {
|
context: {
|
||||||
|
...paymentModal.context,
|
||||||
...payment,
|
...payment,
|
||||||
smartRefetch: true,
|
smartRefetch: true,
|
||||||
exportedat: today
|
exportedat: today
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (refetch)
|
if (refetch) {
|
||||||
refetch(
|
if (paymentModal.context.refetchRequiresContext) {
|
||||||
paymentUpdateResponse &&
|
refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
|
||||||
paymentUpdateResponse.data.update_payments.returning[0]
|
} else {
|
||||||
);
|
refetch();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting", {
|
message: t("payments.errors.exporting", {
|
||||||
|
|||||||
@@ -89,8 +89,11 @@ function PaymentModalContainer({paymentModal, toggleModalVisible, bodyshop }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (actions.refetch) {
|
if (actions.refetch) {
|
||||||
const updatedData = smartRefetch && updatedPayment ? updatedPayment.data.update_payments.returning[0] : undefined;
|
if (context.refetchRequiresContext) {
|
||||||
actions.refetch(updatedData);
|
actions.refetch(updatedPayment && updatedPayment.data.update_payments.returning[0]);
|
||||||
|
} else {
|
||||||
|
actions.refetch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enterAgain) {
|
if (enterAgain) {
|
||||||
@@ -166,13 +169,7 @@ function PaymentModalContainer({paymentModal, toggleModalVisible, bodyshop }) {
|
|||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Form
|
<Form onFinish={handleFinish} autoComplete={"off"} form={form} layout="vertical" disabled={context?.exportedat}>
|
||||||
onFinish={handleFinish}
|
|
||||||
autoComplete={"off"}
|
|
||||||
form={form}
|
|
||||||
layout="vertical"
|
|
||||||
disabled={context?.exportedat}
|
|
||||||
>
|
|
||||||
<PaymentForm form={form} />
|
<PaymentForm form={form} />
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
@@ -5,12 +5,18 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
import { UPDATE_PAYMENT } from "../../graphql/payments.queries";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
|
import { selectPayment } from "../../redux/modals/modals.selectors";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
paymentModal: selectPayment
|
||||||
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
|
setPaymentContext: (context) => dispatch(setModalContext({ context: context, modal: "payment" }))
|
||||||
});
|
});
|
||||||
|
|
||||||
const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
const PaymentReexportButton = ({ paymentModal, payment, refetch, setPaymentContext }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
|
const [updatePayment, { loading }] = useMutation(UPDATE_PAYMENT);
|
||||||
|
|
||||||
@@ -34,16 +40,19 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
|||||||
refetch
|
refetch
|
||||||
},
|
},
|
||||||
context: {
|
context: {
|
||||||
smartRefetch: true,
|
...paymentModal.context,
|
||||||
...payment,
|
...payment,
|
||||||
exportedat: null
|
exportedat: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (refetch)
|
|
||||||
refetch(
|
if (refetch) {
|
||||||
paymentUpdateResponse &&
|
if (paymentModal.context.refetchRequiresContext) {
|
||||||
paymentUpdateResponse.data.update_payments.returning[0]
|
refetch(paymentUpdateResponse && paymentUpdateResponse.data.update_payments.returning[0]);
|
||||||
);
|
} else {
|
||||||
|
refetch();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
message: t("payments.errors.exporting", {
|
message: t("payments.errors.exporting", {
|
||||||
@@ -60,4 +69,4 @@ const PaymentReexportButton = ({ payment, refetch, setPaymentContext }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps)(PaymentReexportButton);
|
export default connect(mapStateToProps, mapDispatchToProps)(PaymentReexportButton);
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ export function PaymentsListPaginated({
|
|||||||
}
|
}
|
||||||
: refetch
|
: refetch
|
||||||
},
|
},
|
||||||
context: apolloResults ? { smartRefetch: true, ...apolloResults} : {smartRefetch: true, ...record}
|
context: { ...(apolloResults ? apolloResults : record), refetchRequiresContext: true }
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user