From 9dd2dc4f0ed62bed0f6a300dc04c4f0d60d0a65a Mon Sep 17 00:00:00 2001 From: Samuel Siegart Date: Fri, 21 Jan 2022 14:43:15 -0800 Subject: [PATCH] fix(wallet): handle cancelled offer state (#4292) * fix(wallet): handle cancelled offer state * chore(wallet): simplify conditional --- packages/wallet/ui/src/components/Offer.jsx | 23 ++++++++++--------- .../ui/src/components/tests/Offer.test.jsx | 5 ++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/wallet/ui/src/components/Offer.jsx b/packages/wallet/ui/src/components/Offer.jsx index 53ee42036b1..a5e34f09907 100644 --- a/packages/wallet/ui/src/components/Offer.jsx +++ b/packages/wallet/ui/src/components/Offer.jsx @@ -20,6 +20,7 @@ const statusText = { complete: 'Accepted', pending: 'Pending', proposed: 'Proposed', + cancel: 'Cancelled', }; const statusColors = { @@ -29,6 +30,7 @@ const statusColors = { pending: 'warning', proposed: 'default', complete: 'success', + cancel: 'default', }; const cmp = (a, b) => { @@ -69,7 +71,7 @@ const OfferWithoutContext = ({ setPendingOffers({ offerId: id, isPending: true }); } - // Eagerly show pending and declined offers states. + // Eagerly show pending and declined offers' states. if (status === 'proposed' && pendingOffers.has(id)) { status = 'pending'; } @@ -192,17 +194,16 @@ const OfferWithoutContext = ({ ); + const isOfferCompleted = [ + 'accept', + 'decline', + 'complete', + 'rejected', + 'cancel', + ].includes(status); + return ( - + { rejectedOffer.status = 'rejected'; component = mount(); expect(component.find(Request).props().completed).toEqual(true); + + const cancelledOffer = { ...offer }; + cancelledOffer.status = 'cancel'; + component = mount(); + expect(component.find(Request).props().completed).toEqual(true); }); test('closes the offer', () => {