Files
smartmenu-collina/prisma/migrations/0005_order_note
Jorem Juárez 79cee9ebde Add public cart feeding the existing orders/SSE system
Builds on the existing Order model + SSE dashboard (no parallel system).

Model: extend Order.items JSON to {productId,name,qty,note?,price?} and add
Order.note (general note) — migration 0005.

Public menu (only when orders are enabled):
- Add button on every dish in BOTH card and list views
- Dedicated floating cart FAB with an item-count badge
- Cart sheet: per-line qty +/- (0 removes), per-item note, per-line subtotal +
  total, a general order note, and required table number; confirm posts to the
  existing POST /order, shows a confirmation toast and clears the cart
- Cart lives in client state only (no localStorage)

Admin Orders tab:
- Shows per-item notes and the general note
- Edit mode: adjust quantities, edit per-item and general notes, and ADD dishes
  via a searchable dropdown over the restaurant's menu; saves through an extended
  PATCH /orders/[id] that updates items/note and broadcasts a new 'order-edit' SSE
  event so the dashboard updates live. Table number and timer (createdAt) preserved

order POST and PATCH sanitize/clamp incoming items (public + admin input).
i18n: cart/notes/total/confirm/search labels in es/en at parity. Glassmorphism,
mobile-first and safe areas preserved.

Endpoints/models: no new routes — POST /api/[slug]/order and PATCH
/api/[slug]/orders/[id] extended; Order model extended (items shape + note column,
migration 0005); new SSE event type 'order-edit'.

Verified: build passes; 5 migrations apply; order create persists qty/notes/price;
admin edit adds dishes + notes keeping table/timer; unauth edit 401.
2026-06-15 16:15:45 -06:00
..