Merged in feature/IO-2261-opensearch-replacements (pull request #777)
IO-2261 Modify Opensearch Data after payment update Approved-by: Patrick Fic
This commit is contained in:
@@ -52,7 +52,7 @@ function PaymentModalContainer({
|
|||||||
const { useStripe, sendby, ...paymentObj } = values;
|
const { useStripe, sendby, ...paymentObj } = values;
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
let updatedPayment; //Moved up from if statement for greater scope.
|
||||||
try {
|
try {
|
||||||
if (!context || (context && !context.id)) {
|
if (!context || (context && !context.id)) {
|
||||||
const newPayment = await insertPayment({
|
const newPayment = await insertPayment({
|
||||||
@@ -87,7 +87,7 @@ function PaymentModalContainer({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const updatedPayment = await updatePayment({
|
updatedPayment = await updatePayment({
|
||||||
variables: {
|
variables: {
|
||||||
paymentId: context.id,
|
paymentId: context.id,
|
||||||
payment: paymentObj,
|
payment: paymentObj,
|
||||||
@@ -101,7 +101,11 @@ function PaymentModalContainer({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actions.refetch) actions.refetch();
|
if (actions.refetch)
|
||||||
|
actions.refetch(
|
||||||
|
updatedPayment && updatedPayment.data.update_payments.returning[0]
|
||||||
|
);
|
||||||
|
|
||||||
if (enterAgain) {
|
if (enterAgain) {
|
||||||
const prev = form.getFieldsValue(["date"]);
|
const prev = form.getFieldsValue(["date"]);
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,20 @@ export function PaymentsListPaginated({
|
|||||||
apolloResults = data.payments_by_pk;
|
apolloResults = data.payments_by_pk;
|
||||||
}
|
}
|
||||||
setPaymentContext({
|
setPaymentContext({
|
||||||
actions: { refetch: refetch },
|
actions: {
|
||||||
|
refetch: apolloResults
|
||||||
|
? (updatedRecord) => {
|
||||||
|
setOpenSearchResults((results) =>
|
||||||
|
results.map((result) => {
|
||||||
|
if (result.id !== record.id) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return updatedRecord;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: refetch,
|
||||||
|
},
|
||||||
context: apolloResults ? apolloResults : record,
|
context: apolloResults ? apolloResults : record,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user