feat(checkout): restore cart before modifying items
This commit is contained in:
@@ -199,9 +199,28 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (editing && !this.canModifyCart()) {
|
if (editing && !this.canModifyCart()) {
|
||||||
await this.router.navigate(['/'], {
|
const tenant = this.tenantService.tenant();
|
||||||
queryParams: { openCart: true },
|
const purchaseId = this.createdPurchaseId();
|
||||||
});
|
|
||||||
|
if (!tenant || !purchaseId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isPreparingItemEdit.set(true);
|
||||||
|
try {
|
||||||
|
await this.checkoutService.cancelPurchase(tenant.codigo, purchaseId);
|
||||||
|
this.createdPurchaseId.set(null);
|
||||||
|
this.createdPurchase.set(null);
|
||||||
|
await firstValueFrom(this.cartService.loadCart());
|
||||||
|
await this.router.navigate(['/'], {
|
||||||
|
queryParams: { openCart: true },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to restore cart for editing:', error);
|
||||||
|
} finally {
|
||||||
|
this.isPreparingItemEdit.set(false);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user