diff --git a/src/public/borne/assets/js/page-cart.js b/src/public/borne/assets/js/page-cart.js index a4a7b79..5354b83 100644 --- a/src/public/borne/assets/js/page-cart.js +++ b/src/public/borne/assets/js/page-cart.js @@ -2,8 +2,14 @@ * page-cart.js — Shopping cart screen. * * Displays all cart lines with quantity controls and totals. + * Handles two item shapes: + * - Simple product: { id, type, libelle, prix_cents, quantite, image } + * - Composed menu: { ...above, composition: {...}, supplement_cents: number } * - * TVA: 10% (taux normal restauration, France 2024 — simplification MVPp). + * Menu lines render a composition breakdown beneath the product name. + * Simple product lines render as before (no composition block). + * + * TVA: 10% (taux normal restauration, France 2024 — simplification MVP). * TODO: verify exact applicable TVA rate with an accountant in P3. * The real rate depends on sur-place vs a-emporter, alcohol content, etc. * @@ -11,7 +17,7 @@ * requires prices shown to end-consumers to include all taxes. */ -import { getCart, removeFromCart, updateQuantity, getTotalCents, clearCart, formatPrice } from './state.js'; +import { getCart, removeFromCart, updateQuantity, getTotalCents, computeMenuLineCents, clearCart, formatPrice } from './state.js'; import { refreshCartBadge } from './nav.js'; /* TVA rate used for display breakdown only — stored prices are already TTC */ @@ -38,14 +44,16 @@ function renderCart() { return; } - emptyBlock.hidden = false; /* keep structure; toggle via class */ emptyBlock.hidden = true; summaryBlock.hidden = false; if (payBtn) payBtn.disabled = false; cartList.innerHTML = ''; items.forEach((item, index) => { - const lineTotalCents = item.prix_cents * item.quantite; + const isMenu = item.type === 'menu'; + const lineTotalCents = isMenu + ? computeMenuLineCents(item) + : item.prix_cents * item.quantite; const row = document.createElement('li'); row.className = 'cart-line'; @@ -60,7 +68,8 @@ function renderCart() { >