diff --git a/client/src/components/payment-modal/payment-modal.container.jsx b/client/src/components/payment-modal/payment-modal.container.jsx index b7152b8e3..a2e7e37fe 100644 --- a/client/src/components/payment-modal/payment-modal.container.jsx +++ b/client/src/components/payment-modal/payment-modal.container.jsx @@ -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"]); diff --git a/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx b/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx index 06bebafd1..d34b56f9c 100644 --- a/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx +++ b/client/src/components/payments-list-paginated/payment-list-paginated.component.jsx @@ -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, }); }}