From 58e9dc06b1878d2b8ccae7bfdc0a5bbf57f45eb7 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Tue, 28 Jul 2026 16:03:17 -0300 Subject: [PATCH] refactor: simplify purchase status page by removing polling logic and updating messages --- .../purchase-status-page.component.html | 40 +------------ .../purchase-status-page.component.ts | 56 ++----------------- 2 files changed, 8 insertions(+), 88 deletions(-) diff --git a/src/app/features/store/pages/purchase-status-page/purchase-status-page.component.html b/src/app/features/store/pages/purchase-status-page/purchase-status-page.component.html index cb32afd..7953c02 100644 --- a/src/app/features/store/pages/purchase-status-page/purchase-status-page.component.html +++ b/src/app/features/store/pages/purchase-status-page/purchase-status-page.component.html @@ -41,21 +41,7 @@
-

Esta pantalla se actualiza automáticamente cuando el pago impacta.

- @if (isRefreshing()) { -

Actualizando estado...

- } - - - Actualizar estado - +

Te avisaremos cuando el pago sea confirmado.

} @else if (status() === 'expired') {
@@ -83,19 +69,9 @@
-

Si ya pagaste, podés reintentar la consulta o escribirnos para revisarlo.

+

Si ya pagaste, escribinos para que podamos revisarlo.

- - Reintentar - -
-

Reintentá en unos segundos. Si el problema sigue, comunicate con nosotros.

+

Volvé a ingresar más tarde. Si el problema sigue, comunicate con nosotros.

- - Reintentar - - | null = null; protected readonly isLoading = signal(true); - protected readonly isRefreshing = signal(false); protected readonly status = signal('pending'); ngOnInit(): void { @@ -42,45 +39,22 @@ export class PurchaseStatusPageComponent implements OnInit, OnDestroy { this.purchaseId = purchaseId; this.tenantCode = tenant.codigo; - void this.refreshStatus(true); + void this.loadStatus(); } - ngOnDestroy(): void { - this.clearScheduledPoll(); - } - - protected retryStatusCheck(): void { - void this.refreshStatus(false); - } - - private async refreshStatus(showLoader: boolean): Promise { + private async loadStatus(): Promise { if (!this.purchaseId || !this.tenantCode) { return; } - this.clearScheduledPoll(); - - if (showLoader) { - this.isLoading.set(true); - } else { - this.isRefreshing.set(true); - } - try { const purchase = await this.checkoutService.getPurchase(this.tenantCode, this.purchaseId); - const resolvedStatus = this.resolveStatus(purchase); - - this.status.set(resolvedStatus); - - if (resolvedStatus === 'pending') { - this.scheduleNextPoll(); - } + this.status.set(this.resolveStatus(purchase)); } catch (error) { console.error('Failed to fetch purchase status:', error); this.status.set('error'); } finally { this.isLoading.set(false); - this.isRefreshing.set(false); } } @@ -100,26 +74,6 @@ export class PurchaseStatusPageComponent implements OnInit, OnDestroy { return 'pending'; } - private scheduleNextPoll(): void { - if (this.pollTimeoutId !== null) { - return; - } - - this.pollTimeoutId = setTimeout(() => { - this.pollTimeoutId = null; - void this.refreshStatus(false); - }, this.pollIntervalMs); - } - - private clearScheduledPoll(): void { - if (this.pollTimeoutId === null) { - return; - } - - clearTimeout(this.pollTimeoutId); - this.pollTimeoutId = null; - } - protected getWhatsAppLink(): string { const phone = '5493416658247'; const message = encodeURIComponent('Hola! Mi compra fue realizada con \u00E9xito.');