diff --git a/src/app/components/cart/components/checkout/checkout-overlay.component.ts b/src/app/components/cart/components/checkout/checkout-overlay.component.ts index 4b78109..b21c476 100644 --- a/src/app/components/cart/components/checkout/checkout-overlay.component.ts +++ b/src/app/components/cart/components/checkout/checkout-overlay.component.ts @@ -185,6 +185,7 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy { (val).payload?.chainReference, ); + this.removePurchasedGroupItems(); this.currentStep = StepType.COMPLETE; this.updateStep(this.currentStep); this.cd.markForCheck(); @@ -493,7 +494,8 @@ export class CheckoutOverlayComponent implements OnInit, OnDestroy { private removePurchasedGroupItems(): void { if (this.selectedNetwork) { this.cartService.removeGroupItemsFromCart(this.selectedNetwork); - this.cartService.clearNetworkSelection(); + } else { + this.cartService.removeGroupItemsFromCart(); } } diff --git a/src/app/components/cart/services/cart.service.ts b/src/app/components/cart/services/cart.service.ts index b3eaee4..3ebe16b 100644 --- a/src/app/components/cart/services/cart.service.ts +++ b/src/app/components/cart/services/cart.service.ts @@ -16,6 +16,7 @@ import { Nft, Collection, Transaction, + TransactionType, MIN_AMOUNT_TO_TRANSFER, TRANSACTION_AUTO_EXPIRY_MS, DEFAULT_NETWORK, @@ -172,13 +173,31 @@ export class CartService { transaction.payload?.void || transaction.payload?.reconciled ) { - removeItem(StorageItem.CheckoutTransaction); - this.pendingTransaction$.next(undefined); - this.triggerChangeDetectionSubject$.next(); - clearInterval(this.transactionCheckInterval); - this.transactionCheckInterval = null; + if (transaction.payload?.reconciled) { + this.removeGroupItemsFromCart(); + this.notification.success($localize`NFT(s) successfully purchased.`, ''); + this.setCurrentStep(StepType.CONFIRM); + removeItem(StorageItem.CheckoutTransaction); + this.pendingTransaction$.next(undefined); + this.triggerChangeDetectionSubject$.next(); + clearInterval(this.transactionCheckInterval); + this.transactionCheckInterval = null; + } else if (transaction.payload?.void && !transaction.payload?.reconciled) { + this.notification.error($localize`NFT purchase transaction expired.`, ''); + this.setCurrentStep(StepType.CONFIRM); + removeItem(StorageItem.CheckoutTransaction); + this.pendingTransaction$.next(undefined); + this.triggerChangeDetectionSubject$.next(); + clearInterval(this.transactionCheckInterval); + this.transactionCheckInterval = null; + } else { + removeItem(StorageItem.CheckoutTransaction); + this.pendingTransaction$.next(undefined); + this.triggerChangeDetectionSubject$.next(); + } } } else { + this.setCurrentStep(StepType.CONFIRM); removeItem(StorageItem.CheckoutTransaction); this.pendingTransaction$.next(undefined); this.triggerChangeDetectionSubject$.next(); @@ -688,7 +707,21 @@ export class CartService { return this.calc(itemPrice, discount); } - public removeGroupItemsFromCart(tokenSymbol: string): void { + public removeGroupItemsFromCart(tokenSymbol?: string): void { + if (!tokenSymbol) { + this.selectedNetwork$.pipe(take(1)).subscribe((defaultTokenSymbol) => { + if (defaultTokenSymbol == null) { + console.warn('No default token symbol found, no updates performed.'); + } else { + this.performCartUpdate(defaultTokenSymbol); + } + }); + } else { + this.performCartUpdate(tokenSymbol); + } + } + + private performCartUpdate(tokenSymbol: string): void { const updatedCartItems = this.cartItemsSubject$.value.filter((item) => { const itemTokenSymbol = (item.nft?.placeholderNft diff --git a/src/app/components/nft/components/nft-checkout/nft-checkout.component.html b/src/app/components/nft/components/nft-checkout/nft-checkout.component.html index 3c7e742..2108834 100644 --- a/src/app/components/nft/components/nft-checkout/nft-checkout.component.html +++ b/src/app/components/nft/components/nft-checkout/nft-checkout.component.html @@ -556,6 +556,7 @@

{{ getTitle() }}

> +
network print: {{ collection?.mintingData?.network }}