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;
|
||||
|
||||
setLoading(true);
|
||||
|
||||
let updatedPayment; //Moved up from if statement for greater scope.
|
||||
try {
|
||||
if (!context || (context && !context.id)) {
|
||||
const newPayment = await insertPayment({
|
||||
@@ -87,7 +87,7 @@ function PaymentModalContainer({
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const updatedPayment = await updatePayment({
|
||||
updatedPayment = await updatePayment({
|
||||
variables: {
|
||||
paymentId: context.id,
|
||||
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) {
|
||||
const prev = form.getFieldsValue(["date"]);
|
||||
|
||||
|
||||
@@ -169,7 +169,20 @@ export function PaymentsListPaginated({
|
||||
apolloResults = data.payments_by_pk;
|
||||
}
|
||||
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,
|
||||
});
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user