feat: staff apps show the menu in the reader's language (plan 6R.L)

The waiters' phones and the counter show categories, products and every
choice (quick options, extras and sub-choices, preferences, shared sets,
ingredients, groups) in the signed-in person's language, falling back to
the stored text. Display only: carts, lines, tickets and the kitchen keep
the venue's text (ids, sub-choices by stored name). In the venue's own
language nothing changes.

- @xenia/access: menuText / useMenuText (mt, mt.choice, mt.line, mt.matches)
- /api/pos/menu carries translations for products, categories and choices
- shared ProductDialog takes a text() prop (the counter passes useMenuText)
- search finds a product by its name in any language (counter, waiter)
- waiter: useMenuNames for sent lines; picker, drawer, cart, summary,
  table lines, quantity / price history, favourites setup
- counter: categories, cards, dialog, cart lines, table lines, payment rows
- tests: access menuText, ordering search, test_pos per-language,
  e2e waiter.mjs and terminal.mjs 6R.L blocks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 20:18:10 +02:00
co-authored by Claude Opus 5.5
parent f107deca8c
commit 0840247768
29 changed files with 518 additions and 123 deletions
+29 -1
View File
@@ -59,12 +59,40 @@ def test_menu_lists_what_a_cashier_sells(client, till, menu):
burger = next(p for p in data["products"] if p["name"] == "Burger")
assert burger["price"] == 10.0 and burger["description"] == "Beef, brioche" and burger["tags"] == ["spicy"]
assert "cost_simple" not in burger and "cost_breakdown" not in burger
assert burger["options"][0]["subs"][0] == {"name": "BBQ", "price": 0.2, "is_default": True}
assert burger["options"][0]["subs"][0] == {"name": "BBQ", "price": 0.2, "is_default": True, "translations": {}}
assert burger["prefs"][0]["shared"]["name"] == "Side" and burger["prefs"][0]["choices"][1]["disables_shared"] is True
assert {c["name"] for c in data["categories"]} >= {"Food", "Drinks"}
assert data["settings"]["default_order_type"] == "takeaway"
def test_menu_carries_every_name_per_language_lines_keep_the_venues(client, db, till, menu, on_shift):
"""6R.L: the counter gets each text per language to show in the cashier's language; what it
sends is ids (and sub-choices by their stored name), so the order keeps the venue's text."""
from models.order import OrderItem
m = menu
m["burger"].translations = json.dumps({"el": {"name": "Μπέργκερ", "description": "Μοσχάρι"}, "en": {"name": "Burger"}})
m["food"].translations = json.dumps({"el": {"name": "Φαγητό"}})
m["rare"].translations = json.dumps({"el": "Λίγο ψημένο"})
m["cook"].translations = json.dumps({"el": "Ψήσιμο"})
m["cook"].shared_subset = json.dumps({"name": "Side", "translations": {"el": "Συνοδευτικό"},
"choices": [{"name": "Fries", "is_default": True, "translations": {"el": "Πατάτες"}},
{"name": "Salad", "extra_cost": 1.0}]})
db.commit()
data = client.get("/api/pos/menu", headers=till["h"]).json()
burger = next(p for p in data["products"] if p["id"] == m["burger"].id)
assert burger["translations"]["el"] == {"name": "Μπέργκερ", "description": "Μοσχάρι"}
pref = burger["prefs"][0]
assert pref["translations"] == {"el": "Ψήσιμο"} and pref["shared"]["translations"] == {"el": "Συνοδευτικό"}
assert pref["shared"]["subs"][0]["translations"] == {"el": "Πατάτες"} and pref["shared"]["subs"][1]["translations"] == {}
assert next(c for c in pref["choices"] if c["id"] == m["rare"].id)["translations"] == {"el": "Λίγο ψημένο"}
assert next(c for c in data["categories"] if c["id"] == m["food"].id)["translations"] == {"el": {"name": "Φαγητό"}}
assert burger["quick"][0]["translations"] == {} and burger["ingredients"][0]["translations"] == {}
r = sale(client, till, [burger_line(m)], [{"method": "cash"}], cash_given=20)
assert r.status_code == 201, r.text
item = db.query(OrderItem).filter(OrderItem.order_id == r.json()["order_id"]).one()
assert [o["name"] for o in json.loads(item.selected_options)] == ["Rare", "Fries"] # the stored names, not a translation
def test_quote_prices_on_the_server(client, till, menu):
m = menu
line = burger_line(m, quick=[{"id": m["burger"].quick_options[0].id, "qty": 2}],