diff --git a/src/app/features/store/pages/checkout-page/checkout-page.component.html b/src/app/features/store/pages/checkout-page/checkout-page.component.html index 7bd8d57..ade0df5 100644 --- a/src/app/features/store/pages/checkout-page/checkout-page.component.html +++ b/src/app/features/store/pages/checkout-page/checkout-page.component.html @@ -51,7 +51,7 @@ [allowModify]="true" [showModifyWhenReadonly]="true" [modifyAsAction]="true" - [editingDisabled]="isCancellingPurchase()" + [editingDisabled]="isPurchaseModificationDisabled()" backgroundColor="transparent" (modify)="onModifyPurchase()" /> diff --git a/src/app/features/store/pages/checkout-page/checkout-page.component.spec.ts b/src/app/features/store/pages/checkout-page/checkout-page.component.spec.ts index 0444625..622495e 100644 --- a/src/app/features/store/pages/checkout-page/checkout-page.component.spec.ts +++ b/src/app/features/store/pages/checkout-page/checkout-page.component.spec.ts @@ -211,6 +211,22 @@ describe('CheckoutPageComponent payment validation', () => { expect(routerStub.navigate).not.toHaveBeenCalled(); }); + it('prevents modifying the purchase after Ya transferí is clicked', async () => { + const { component } = createComponent(); + component.selectedPaymentMethod.set('transfer'); + + await component.onComplete(); + + expect(component.hasSubmittedTransfer()).toBe(true); + expect(component.isPurchaseModificationDisabled()).toBe(true); + + await component.onModifyPurchase(); + + expect(checkoutServiceStub.cancelPurchase).not.toHaveBeenCalled(); + expect(globalLoadingServiceStub.start).not.toHaveBeenCalled(); + expect(routerStub.navigate).not.toHaveBeenCalled(); + }); + it('navigates after a transfer is confirmed as paid', async () => { checkoutServiceStub.getPurchase.mockResolvedValue({ status: 'paid' }); const { component } = createComponent(); @@ -508,7 +524,6 @@ describe('CheckoutPageComponent payment validation', () => { expect(globalLoadingServiceStub.stop).toHaveBeenCalledOnce(); await component.canDeactivate(); - }); it('updates customer data on the existing purchase before payment', async () => { diff --git a/src/app/features/store/pages/checkout-page/checkout-page.component.ts b/src/app/features/store/pages/checkout-page/checkout-page.component.ts index 3bdc1a3..3573e18 100644 --- a/src/app/features/store/pages/checkout-page/checkout-page.component.ts +++ b/src/app/features/store/pages/checkout-page/checkout-page.component.ts @@ -122,6 +122,10 @@ export class CheckoutPageComponent implements OnInit, OnDestroy { protected readonly isUpdatingPurchase = signal(false); protected readonly isCancellingPurchase = signal(false); + protected readonly hasSubmittedTransfer = signal(false); + protected readonly isPurchaseModificationDisabled = computed( + () => this.isCancellingPurchase() || this.hasSubmittedTransfer(), + ); protected readonly createdPurchaseId = signal(null); protected readonly isGeneratingIntent = signal(false); protected readonly isPaymentLoading = computed(() => this.isGeneratingIntent()); @@ -187,7 +191,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy { } protected async onModifyPurchase(): Promise { - if (this.isCancellingPurchase()) { + if (this.isPurchaseModificationDisabled()) { return; } @@ -413,6 +417,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy { } this.stopTransferPolling(); + this.hasSubmittedTransfer.set(true); this.transferValidationStatus.set('checking'); this.transferPollingAttempts = 0;