Squashed commit of the following:
commit38d03588b1Merge:8e987d06f4aa3bAuthor: ncoronel <ncoronel@quo.ar> Date: Wed Aug 26 10:25:23 2026 -0300 Merge branch 'fix/cart-expiration-notification' of https://gitea.quo.ar/tbianchini/shopit-front into fix/cart-expiration-notification commit8e987d0ce6Author: ncoronel <ncoronel@quo.ar> Date: Wed Aug 26 10:02:26 2026 -0300 fix(purchase-status): clear cart on approved purchase commite171b9a233Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 17:06:07 2026 -0300 refactor(checkout): use purchase id route segment commit643d43adeaAuthor: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 17:05:59 2026 -0300 fix(checkout): handle expired purchase exits commitd89d01b511Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 16:47:17 2026 -0300 fix(checkout): refresh expired carts commiteeb245209bAuthor: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 16:46:12 2026 -0300 fix(checkout): show backend start errors commit9d3754c2d8Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 16:33:44 2026 -0300 fix(cart): refresh state after expiration commit6f4aa3b1bdAuthor: ncoronel <ncoronel@quo.ar> Date: Wed Aug 26 10:02:26 2026 -0300 fix(purchase-status): clear cart on approved purchase commit2b342ec235Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 17:06:07 2026 -0300 refactor(checkout): use purchase id route segment commitd06b146104Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 17:05:59 2026 -0300 fix(checkout): handle expired purchase exits commitf4e0a9e028Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 16:47:17 2026 -0300 fix(checkout): refresh expired carts commit8c2b738806Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 16:46:12 2026 -0300 fix(checkout): show backend start errors commit1362d0c163Author: ncoronel <ncoronel@quo.ar> Date: Tue Aug 25 16:33:44 2026 -0300 fix(cart): refresh state after expiration
This commit is contained in:
@@ -98,11 +98,12 @@ export class CartComponent {
|
||||
this.clearOverride(update.cartItemId);
|
||||
},
|
||||
error: (err: HttpErrorResponse) => {
|
||||
console.error('Error updating cart quantity', err);
|
||||
const msg =
|
||||
err.error?.message || 'Error al actualizar la cantidad del producto.';
|
||||
this.toastService.danger(msg);
|
||||
this.clearOverride(update.cartItemId);
|
||||
this.handleMutationError(
|
||||
err,
|
||||
'Error al actualizar la cantidad del producto.',
|
||||
'Error updating cart quantity',
|
||||
);
|
||||
},
|
||||
}),
|
||||
catchError(() => EMPTY),
|
||||
@@ -205,9 +206,12 @@ export class CartComponent {
|
||||
this.toastService.success(response.message || 'Variante actualizada.');
|
||||
},
|
||||
error: (error: HttpErrorResponse) => {
|
||||
console.error('Error updating cart item variant', error);
|
||||
this.clearVariantOverride(cartItemId);
|
||||
this.toastService.danger(error.error?.message || 'No se pudo actualizar la variante.');
|
||||
this.handleMutationError(
|
||||
error,
|
||||
'No se pudo actualizar la variante.',
|
||||
'Error updating cart item variant',
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -305,10 +309,29 @@ export class CartComponent {
|
||||
this.toastService.info(msg);
|
||||
},
|
||||
error: (err: HttpErrorResponse) => {
|
||||
console.error('Error removing item from cart', err);
|
||||
const msg = err.error?.message || 'Error al eliminar el producto del carrito.';
|
||||
this.toastService.danger(msg);
|
||||
this.handleMutationError(
|
||||
err,
|
||||
'Error al eliminar el producto del carrito.',
|
||||
'Error removing item from cart',
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private handleMutationError(
|
||||
error: HttpErrorResponse,
|
||||
fallbackMessage: string,
|
||||
logMessage: string,
|
||||
): void {
|
||||
console.error(logMessage, error);
|
||||
this.toastService.danger(error.error?.message || fallbackMessage);
|
||||
|
||||
if (error.error?.code !== 'stock_reservation.expired') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.cartService.loadCart().subscribe({
|
||||
error: (refreshError) => console.error('Error refreshing expired cart', refreshError),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user