feat(menu-app): the QR menu and the order app in the guest's language (contract C-2 names, platform-v2 step 6.4)

The site now sends names / descriptions {el, en} per product, quick option and category
(falling back to the text as typed). The menu app maps them onto its en / gr switch (byLang);
the order app localises its menu by the guest's language (localizeMenu, tested). The menu app
also reads 6.3's allergens object (what a product contains).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 10:46:59 +02:00
co-authored by Claude Opus 5.5
parent e0158b2c72
commit 9f9b882806
4 changed files with 48 additions and 5 deletions
@@ -2,6 +2,7 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
import {
localizeMenu, productName,
addToCart, cartCount, cartLines, checkoutProblems, menuFor, orderBody, priceFor, refusal, setQty, slotDays, trackSteps,
} from '../src/logic.js'
@@ -81,3 +82,17 @@ test('booking a table, with or without food (S.6)', async () => {
assert.equal(trackSteps('preorder', 'cancelled').at, -1)
assert.equal(priceFor({ sold_at: ['online_preorder'], prices: { online_preorder: 2.6 } }, 'preorder'), 2.6)
})
test('the menu in the guest’s language (6.4): names, descriptions, extras; old menus untouched', () => {
const cats = [{ id: 1, name: 'Ψητά', names: { el: 'Ψητά', en: 'Grill' }, products: [
{ id: 5, name: 'Σουβλάκι', digital_name: 'Σουβλάκι χοιρινό', names: { el: 'Σουβλάκι χοιρινό', en: 'Pork skewer' }, descriptions: { el: 'Με πίτα', en: 'With pitta' },
quick_options: [{ id: 9, name: 'Πίτα', names: { el: 'Πίτα', en: 'Pitta' } }] },
{ id: 6, name: 'Old', digital_name: 'Old one' }] }]
const en = localizeMenu(cats, 'en')
assert.equal(en[0].name, 'Grill')
assert.equal(productName(en[0].products[0]), 'Pork skewer')
assert.equal(en[0].products[0].digital_description, 'With pitta')
assert.equal(en[0].products[0].quick_options[0].name, 'Pitta')
assert.equal(productName(en[0].products[1]), 'Old one')
assert.equal(productName(localizeMenu(cats, 'el')[0].products[0]), 'Σουβλάκι χοιρινό')
})