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:
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import { useCan } from '@xenia/access'
|
||||
import { useCan, useMenuText } from '@xenia/access'
|
||||
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
|
||||
import { assetUrl } from '../config/server'
|
||||
import { money } from '../i18n'
|
||||
@@ -155,6 +155,7 @@ function Row({ selected, onClick, children, right, left, style = {} }) {
|
||||
|
||||
function QuickOptionRow({ opt, quickState, setQuickState, compact }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const qty = quickState[opt.id] || 0
|
||||
const selected = qty > 0
|
||||
const toggleSingle = () => setQuickState(s => ({ ...s, [opt.id]: selected ? 0 : 1 }))
|
||||
@@ -176,7 +177,7 @@ function QuickOptionRow({ opt, quickState, setQuickState, compact }) {
|
||||
</div>
|
||||
) : null}
|
||||
>
|
||||
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{opt.name}</div>
|
||||
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(opt)}</div>
|
||||
{opt.price > 0 && <div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>+{money(opt.price)}{opt.allow_multiple ? ` ${t('drawer.each')}` : ''}</div>}
|
||||
</Row>
|
||||
)
|
||||
@@ -186,6 +187,7 @@ function QuickOptionRow({ opt, quickState, setQuickState, compact }) {
|
||||
|
||||
function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setExpandedExtra, compact }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const sel = extrasState[opt.id]
|
||||
const selected = !!sel
|
||||
const open = expandedExtra === opt.id
|
||||
@@ -249,7 +251,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
|
||||
}
|
||||
style={compact ? { minHeight: 48 } : {}}
|
||||
>
|
||||
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{opt.name}</div>
|
||||
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(opt)}</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>
|
||||
{(opt.extra_cost ?? 0) !== 0 ? `+${money(opt.extra_cost)}` : t('drawer.included')}
|
||||
{subLabel && <span style={{ color: 'var(--x-warning)', fontWeight: 600 }}> · {subLabel}</span>}
|
||||
@@ -272,7 +274,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
|
||||
left={<RadioDot selected={isSel} />}
|
||||
style={sub.is_compact ? { minHeight: 44 } : {}}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{sub.name}</div>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(sub)}</div>
|
||||
{(sub.extra_cost ?? 0) !== 0 && <div style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0, marginLeft: 6 }}>+{money(sub.extra_cost)}</div>}
|
||||
</div>
|
||||
</Row>
|
||||
@@ -309,7 +311,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
|
||||
style={sub.is_compact ? { minHeight: 44 } : {}}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', minWidth: 0 }}>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{sub.name}
|
||||
{mt(sub)}
|
||||
{subQty > 1 && <span style={{ color: 'var(--muted)', marginLeft: 6, fontSize: 12, fontVariantNumeric: 'tabular-nums' }}>×{subQty}</span>}
|
||||
</div>
|
||||
{(sub.extra_cost ?? 0) !== 0 && <div style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0, marginLeft: 6 }}>+{money(sub.extra_cost)}{sub.allow_multiple ? ` ${t('drawer.each')}` : ''}</div>}
|
||||
@@ -328,6 +330,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
|
||||
|
||||
function IngredientRow({ ing, removedState, setRemovedState, compact }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const removed = !!removedState[ing.id]
|
||||
return (
|
||||
<Row selected={false}
|
||||
@@ -346,7 +349,7 @@ function IngredientRow({ ing, removedState, setRemovedState, compact }) {
|
||||
{removed ? t('drawer.removed') : t('drawer.remove')}
|
||||
</div>
|
||||
}>
|
||||
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: removed ? 'var(--muted)' : 'var(--text)', textDecoration: removed ? 'line-through' : 'none', transition: 'all 120ms', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{ing.name}</div>
|
||||
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: removed ? 'var(--muted)' : 'var(--text)', textDecoration: removed ? 'line-through' : 'none', transition: 'all 120ms', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(ing)}</div>
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
@@ -355,6 +358,7 @@ function IngredientRow({ ing, removedState, setRemovedState, compact }) {
|
||||
|
||||
function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSubs, setSharedSubs }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const selChoice = prefs[ps.id] ?? null
|
||||
const complete = selChoice != null
|
||||
&& !(selChoice.sub_choices?.length > 0 && subChoices[selChoice.id] == null)
|
||||
@@ -374,7 +378,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
|
||||
return (
|
||||
<div>
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 8, padding: '0 2px 10px' }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: complete ? 'var(--text)' : 'var(--x-danger)' }}>{ps.name}</div>
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: complete ? 'var(--text)' : 'var(--x-danger)' }}>{mt(ps)}</div>
|
||||
{!complete && <div style={{ fontSize: 11, fontWeight: 700, color: 'var(--x-danger)', textTransform: 'uppercase', letterSpacing: 0.6 }}>{t('drawer.required')}</div>}
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
||||
@@ -388,7 +392,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
|
||||
<Row selected={isSel} onClick={() => selectPref(ch)} left={<RadioDot selected={isSel} />}
|
||||
style={ch.is_compact ? { minHeight: 48 } : {}}
|
||||
right={(ch.extra_cost ?? 0) !== 0 ? <div style={{ fontSize: ch.is_compact ? 12 : 14, fontWeight: 500, color: 'var(--muted)', flexShrink: 0 }}>{ch.extra_cost > 0 ? '+' : ''}{money(ch.extra_cost)}</div> : null}>
|
||||
<div style={{ fontSize: ch.is_compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{ch.name}</div>
|
||||
<div style={{ fontSize: ch.is_compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(ch)}</div>
|
||||
</Row>
|
||||
|
||||
{isSel && hasSubs && (
|
||||
@@ -401,7 +405,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
|
||||
<Row selected={subSel} onClick={() => setSubChoices(s => ({ ...s, [ch.id]: sub }))} left={<RadioDot selected={subSel} />}
|
||||
style={sub.is_compact ? { minHeight: 44 } : {}}
|
||||
right={(sub.extra_cost ?? 0) !== 0 ? <div style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0 }}>+{money(sub.extra_cost)}</div> : null}>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{sub.name}</div>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(sub)}</div>
|
||||
</Row>
|
||||
</div>
|
||||
)
|
||||
@@ -414,7 +418,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
|
||||
|
||||
{showShared && (
|
||||
<div style={{ marginTop: 4, marginLeft: 8, paddingLeft: 14, borderLeft: '2px solid rgb(var(--x-warning-rgb) / 0.3)', width: '100%' }}>
|
||||
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, padding: '4px 2px 6px' }}>{ps.shared_subset.name}</div>
|
||||
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, padding: '4px 2px 6px' }}>{mt(ps.shared_subset)}</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>
|
||||
{ps.shared_subset.choices.map((sub, si) => {
|
||||
const subSel = sharedSubs[ps.id]?.name === sub.name
|
||||
@@ -423,7 +427,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
|
||||
<Row selected={subSel} onClick={() => setSharedSubs(s => ({ ...s, [ps.id]: sub }))} left={<RadioDot selected={subSel} />}
|
||||
style={sub.is_compact ? { minHeight: 44 } : {}}
|
||||
right={(sub.extra_cost ?? 0) !== 0 ? <div style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0 }}>+{money(sub.extra_cost)}</div> : null}>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{sub.name}</div>
|
||||
<div style={{ fontSize: sub.is_compact ? 12 : 14, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{mt(sub)}</div>
|
||||
</Row>
|
||||
</div>
|
||||
)
|
||||
@@ -549,6 +553,7 @@ function partitionByGroup(items, modifierGroups) {
|
||||
|
||||
function ExtrasTab({ product, extrasState, setExtrasState, expandedExtra, setExpandedExtra }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const extraGroups = (product.modifier_groups || []).filter(g => g.modifier_type === 'option')
|
||||
const [collapsedGroups, setCollapsedGroups] = useState(() => Object.fromEntries(extraGroups.map(g => [g.id, true])))
|
||||
const options = product.options || []
|
||||
@@ -579,7 +584,7 @@ function ExtrasTab({ product, extrasState, setExtrasState, expandedExtra, setExp
|
||||
const isCollapsed = collapsedGroups[group.id] ?? true
|
||||
return (
|
||||
<div key={group.id} style={{ marginBottom: 12 }}>
|
||||
<PWAGroupHeader name={group.name} collapsed={isCollapsed} onToggle={() => toggleGroup(group.id)} colorIdx={gi} />
|
||||
<PWAGroupHeader name={mt(group)} collapsed={isCollapsed} onToggle={() => toggleGroup(group.id)} colorIdx={gi} />
|
||||
{!isCollapsed && (
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
||||
{items.map(renderOption)}
|
||||
@@ -596,6 +601,7 @@ function ExtrasTab({ product, extrasState, setExtrasState, expandedExtra, setExp
|
||||
|
||||
function IngredientsTab({ product, removedState, setRemovedState }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const ingGroups = (product.modifier_groups || []).filter(g => g.modifier_type === 'ingredient')
|
||||
const [collapsedGroups, setCollapsedGroups] = useState(() => Object.fromEntries(ingGroups.map(g => [g.id, true])))
|
||||
const ingredients = product.ingredients || []
|
||||
@@ -626,7 +632,7 @@ function IngredientsTab({ product, removedState, setRemovedState }) {
|
||||
const isCollapsed = collapsedGroups[group.id] ?? true
|
||||
return (
|
||||
<div key={group.id} style={{ marginBottom: 12 }}>
|
||||
<PWAGroupHeader name={group.name} collapsed={isCollapsed} onToggle={() => toggleGroup(group.id)} colorIdx={gi} />
|
||||
<PWAGroupHeader name={mt(group)} collapsed={isCollapsed} onToggle={() => toggleGroup(group.id)} colorIdx={gi} />
|
||||
{!isCollapsed && (
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
||||
{items.map(renderIng)}
|
||||
@@ -643,6 +649,7 @@ function IngredientsTab({ product, removedState, setRemovedState }) {
|
||||
|
||||
function PrefsTab({ product, prefs, setPrefs, subChoices, setSubChoices, sharedSubs, setSharedSubs }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const prefGroups = (product.modifier_groups || []).filter(g => g.modifier_type === 'preference')
|
||||
const [collapsedGroups, setCollapsedGroups] = useState(() => Object.fromEntries(prefGroups.map(g => [g.id, true])))
|
||||
const preferenceSets = product.preference_sets || []
|
||||
@@ -675,7 +682,7 @@ function PrefsTab({ product, prefs, setPrefs, subChoices, setSubChoices, sharedS
|
||||
const isCollapsed = collapsedGroups[group.id] ?? true
|
||||
return (
|
||||
<div key={group.id} style={{ marginBottom: 16 }}>
|
||||
<PWAGroupHeader name={group.name} collapsed={isCollapsed} onToggle={() => toggleGroup(group.id)} colorIdx={gi} />
|
||||
<PWAGroupHeader name={mt(group)} collapsed={isCollapsed} onToggle={() => toggleGroup(group.id)} colorIdx={gi} />
|
||||
{!isCollapsed && (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
|
||||
{items.map(renderPrefSet)}
|
||||
@@ -1071,6 +1078,7 @@ const FALLBACK_QUICK_NOTES = ['drawer.notes.noSalt', 'drawer.notes.quick', 'draw
|
||||
|
||||
export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialState, courses, quickNotes }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; state and lines keep ids / stored names
|
||||
const itemFavorites = useWaiterFavoritesStore(s => s.itemFavorites)
|
||||
// A price set before sending needs the key itself (plan 4.3); the manager-approval path for
|
||||
// it comes with server-priced orders (4.4). After sending, the item's actions offer it.
|
||||
@@ -1208,8 +1216,8 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
|
||||
&& (!sharedSub || sharedSub.name === defaultSharedSub?.name)
|
||||
if (isFullyDefault) { price += delta; return }
|
||||
|
||||
const value = `${choice.name}${inlineSub ? ` · ${inlineSub.name}` : ''}${sharedSub ? ` · ${sharedSub.name}` : ''}`
|
||||
lines.push({ group: 'prefs', label: ps.name, value, qty: 1, price: delta, detail: null })
|
||||
const value = `${mt(choice)}${inlineSub ? ` · ${mt(inlineSub)}` : ''}${sharedSub ? ` · ${mt(sharedSub)}` : ''}`
|
||||
lines.push({ group: 'prefs', label: mt(ps), value, qty: 1, price: delta, detail: null })
|
||||
price += delta
|
||||
})
|
||||
|
||||
@@ -1217,7 +1225,7 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
|
||||
const q = quickState[opt.id] || 0
|
||||
if (q === 0) return
|
||||
const linePrice = opt.price * q
|
||||
lines.push({ group: 'quick', label: opt.name, qty: q, price: linePrice, detail: null })
|
||||
lines.push({ group: 'quick', label: mt(opt), qty: q, price: linePrice, detail: null })
|
||||
price += linePrice
|
||||
})
|
||||
|
||||
@@ -1231,19 +1239,19 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
|
||||
if (!subQty || subQty < 1) return
|
||||
const sub = opt.sub_choices.find(s => s.name === subName)
|
||||
const linePrice = ((opt.extra_cost ?? 0) + (sub?.extra_cost ?? 0)) * subQty
|
||||
lines.push({ group: 'extras', label: opt.name, qty: subQty, price: linePrice, subName, detail: null })
|
||||
lines.push({ group: 'extras', label: mt(opt), qty: subQty, price: linePrice, subName: sub ? mt(sub) : subName, detail: null })
|
||||
price += linePrice
|
||||
})
|
||||
} else {
|
||||
const sub = opt.sub_choices?.find(s => s.name === sel.subName)
|
||||
const linePrice = ((opt.extra_cost ?? 0) + (sub?.extra_cost ?? 0)) * sel.qty
|
||||
lines.push({ group: 'extras', label: opt.name, qty: sel.qty, price: linePrice, subName: sub?.name ?? null, detail: null })
|
||||
lines.push({ group: 'extras', label: mt(opt), qty: sel.qty, price: linePrice, subName: sub ? mt(sub) : null, detail: null })
|
||||
price += linePrice
|
||||
}
|
||||
})
|
||||
|
||||
ingredients.forEach(ing => {
|
||||
if (removedState[ing.id]) lines.push({ group: 'removed', label: ing.name, qty: 1, price: 0, detail: null })
|
||||
if (removedState[ing.id]) lines.push({ group: 'removed', label: mt(ing), qty: 1, price: 0, detail: null })
|
||||
})
|
||||
|
||||
return { summaryLines: lines, totalPrice: (price + priceAdj) * qty }
|
||||
@@ -1449,7 +1457,7 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
|
||||
style={{ width: 48, height: 48, borderRadius: 12, objectFit: 'cover', flexShrink: 0 }} />
|
||||
)}
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', lineHeight: 1.2 }}>{product.name}</div>
|
||||
<div style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', lineHeight: 1.2 }}>{mt(product)}</div>
|
||||
<div style={{ fontSize: 13, color: priceAdj !== 0 ? 'var(--x-warning)' : 'var(--muted)', marginTop: 2 }}>
|
||||
{priceAdj !== 0
|
||||
? <><span style={{ textDecoration: 'line-through', opacity: 0.5 }}>{money(product.base_price)}</span> → {money(product.base_price + priceAdj)}</>
|
||||
@@ -1471,7 +1479,7 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
|
||||
const isAlert = (tb.id === 'prefs' && prefsTabAlert) || (tb.id === 'favorites' && favTabAlert)
|
||||
const tabColor = isAlert ? 'var(--x-danger)' : active ? 'var(--x-warning)' : 'var(--muted)'
|
||||
return (
|
||||
<button key={tb.id} ref={el => { tabButtonRefs.current[tb.id] = el }} onClick={() => setActiveTab(tb.id)} style={{
|
||||
<button key={tb.id} ref={el => { tabButtonRefs.current[tb.id] = el }} onClick={() => setActiveTab(tb.id)} data-testid={`drawer-tab-${tb.id}`} style={{
|
||||
padding: '12px 6px',
|
||||
background: 'none', border: 'none',
|
||||
borderBottom: `2px solid ${active ? 'var(--x-warning)' : isAlert ? 'var(--x-danger)' : 'transparent'}`,
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useRef, useState } from 'react'
|
||||
import useTableViewStore from '../store/tableViewStore'
|
||||
import { money } from '../i18n'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { useMenuNames } from '../hooks/useMenuNames'
|
||||
import { fade } from '../logic/colour'
|
||||
import OneMore from './OneMore'
|
||||
import { canOneMore } from '../logic/lines'
|
||||
@@ -57,7 +58,8 @@ function ExpandArrow({ expanded, onClick }) {
|
||||
|
||||
// ── Parse selected_options into grouped sections ──────────────────────────────
|
||||
|
||||
function buildSections(item) {
|
||||
// `c(name)`: a choice's name as shown (6R.L: the waiter's language; the stored name by default)
|
||||
function buildSections(item, c = name => name) {
|
||||
const sections = []
|
||||
const opts = (() => {
|
||||
try { return item.selected_options ? JSON.parse(item.selected_options) : [] } catch { return [] }
|
||||
@@ -80,25 +82,25 @@ function buildSections(item) {
|
||||
if (consumedAsSubAtIndex.has(i)) { i++; continue }
|
||||
|
||||
if (o.id == null) {
|
||||
const existing = quickLines.find(x => x.name === o.name)
|
||||
const existing = quickLines.find(x => x.name === c(o.name))
|
||||
if (existing) existing._qty = (existing._qty || 1) + 1
|
||||
else quickLines.push({ name: o.name, _qty: 1 })
|
||||
else quickLines.push({ name: c(o.name), _qty: 1 })
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
let subName = null
|
||||
if (i + 1 < opts.length && opts[i + 1].id == null) {
|
||||
subName = opts[i + 1].name
|
||||
subName = c(opts[i + 1].name)
|
||||
consumedAsSubAtIndex.add(i + 1)
|
||||
}
|
||||
|
||||
if (idCount[o.id] > 1) {
|
||||
const existing = extraGroups.find(g => g.id === o.id && g.subName === subName)
|
||||
if (existing) existing.qty++
|
||||
else extraGroups.push({ id: o.id, name: o.name, subName, qty: 1 })
|
||||
else extraGroups.push({ id: o.id, name: c(o.name), subName, qty: 1 })
|
||||
} else {
|
||||
const value = subName ? `${o.name} · ${subName}` : o.name
|
||||
const value = subName ? `${c(o.name)} · ${subName}` : c(o.name)
|
||||
prefGroups.push({ setName: null, values: [value] })
|
||||
}
|
||||
i++
|
||||
@@ -107,7 +109,7 @@ function buildSections(item) {
|
||||
if (prefGroups.length > 0) sections.push({ type: 'prefs', lines: prefGroups })
|
||||
if (quickLines.length > 0) sections.push({ type: 'quick', lines: quickLines })
|
||||
if (extraGroups.length > 0) sections.push({ type: 'extras', lines: extraGroups })
|
||||
if (removed.length > 0) sections.push({ type: 'removed', lines: removed.map(n => ({ name: n })) })
|
||||
if (removed.length > 0) sections.push({ type: 'removed', lines: removed.map(n => ({ name: c(n) })) })
|
||||
if (item.notes) sections.push({ type: 'note', lines: [{ name: item.notes }] })
|
||||
|
||||
return sections
|
||||
@@ -331,7 +333,8 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
const isServed = effectiveKds === 'served'
|
||||
const kdsColor = !isCancelled && !isServed ? KDS_COLORS[effectiveKds] : null
|
||||
|
||||
const sections = buildSections(item)
|
||||
const names = useMenuNames() // 6R.L: the waiter's language, display only
|
||||
const sections = buildSections(item, n => names.choiceName(item, n))
|
||||
const hasDetails = sections.length > 0
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
|
||||
@@ -404,7 +407,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
].filter(Boolean).join(' ')}
|
||||
style={nameColor ? { color: nameColor } : undefined}
|
||||
>
|
||||
{(isPart(item) ? item.product_name : item.product?.name) || `#${item.product_id}`}
|
||||
{(isPart(item) ? item.product_name : names.lineName(item, item.product?.name)) || `#${item.product_id}`}
|
||||
{isSettled(item) && (
|
||||
<span data-testid="item-settled" title={t('split.settledHint')}
|
||||
style={{ marginLeft: 6, fontSize: 10, fontWeight: 800, padding: '1px 5px', borderRadius: 4, verticalAlign: 'middle',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react'
|
||||
import { money } from '../i18n'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { useMenuText } from '@xenia/access'
|
||||
|
||||
const _UNIT_LABELS = { kg: 'kg', liter: 'L', gram: 'g', ml: 'mL' }
|
||||
function fmtQty(qty, unitType) {
|
||||
@@ -12,10 +13,10 @@ function fmtQty(qty, unitType) {
|
||||
const fmtEUR = money
|
||||
|
||||
// Flatten selected_options into readable lines
|
||||
function describeOptions(selected_options) {
|
||||
function describeOptions(selected_options, c = name => name) { // c: the name as shown (6R.L)
|
||||
if (!selected_options?.length) return []
|
||||
return selected_options.map(o => {
|
||||
let s = o.name || ''
|
||||
let s = o.name ? c(o.name) : ''
|
||||
if (o.price_delta && Math.abs(o.price_delta) > 0.001) {
|
||||
s += ` (${o.price_delta > 0 ? '+' : ''}${money(o.price_delta)})`
|
||||
}
|
||||
@@ -25,8 +26,9 @@ function describeOptions(selected_options) {
|
||||
|
||||
function CartItemSummaryRow({ item, product, price, estimated, onEdit }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const opts = describeOptions(item.selected_options)
|
||||
const removed = item.removed_ingredients || []
|
||||
const mt = useMenuText() // 6R.L: the waiter's language, display only
|
||||
const opts = describeOptions(item.selected_options, n => mt.choice(product, n))
|
||||
const removed = (item.removed_ingredients || []).map(n => mt.choice(product, n))
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
@@ -36,7 +38,7 @@ function CartItemSummaryRow({ item, product, price, estimated, onEdit }) {
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 8 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 7 }}>
|
||||
<span style={{ fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{product?.name ?? `#${item.product_id}`}</span>
|
||||
<span style={{ fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{product ? mt(product) : `#${item.product_id}`}</span>
|
||||
<span style={{ fontSize: 13, color: 'var(--muted)', fontWeight: 500 }}>{fmtQty(item.quantity, item.unit_type)}</span>
|
||||
</div>
|
||||
{opts.length > 0 && (
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
// manager who approved it, why. GET /api/orders/{id}/price-changes.
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { useMenuNames } from '../hooks/useMenuNames'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
|
||||
export default function PriceHistory({ orderId, item, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L
|
||||
const { formatDateTime, formatMoney } = useFormat()
|
||||
const [rows, setRows] = useState(null)
|
||||
const [error, setError] = useState('')
|
||||
@@ -23,7 +25,7 @@ export default function PriceHistory({ orderId, item, onClose }) {
|
||||
<div className="modal-sheet" onClick={e => e.stopPropagation()} data-testid="price-history">
|
||||
<div className="modal-handle" />
|
||||
<h2 className="modal-title">{t('price.history')}</h2>
|
||||
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 14px' }}>{item.product_name || item.product?.name}</p>
|
||||
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 14px' }}>{names.lineName(item, item.product_name || item.product?.name)}</p>
|
||||
{error && <p role="alert" style={{ color: 'var(--x-danger)', fontSize: 13, textAlign: 'center' }}>{error}</p>}
|
||||
{!error && rows === null && <p style={{ textAlign: 'center', color: 'var(--muted)' }}>…</p>}
|
||||
{rows?.length === 0 && <p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13 }}>{t('price.historyNone')}</p>}
|
||||
|
||||
@@ -5,7 +5,7 @@ import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
|
||||
import { assetUrl } from '../config/server'
|
||||
import { money } from '../i18n'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { Allergens } from '@xenia/access'
|
||||
import { Allergens, useMenuText } from '@xenia/access'
|
||||
|
||||
const FAV_CAT_ID = '__favorites__'
|
||||
const SVC_CAT_ID = '__service__'
|
||||
@@ -76,7 +76,8 @@ function ProductDetailModal({ product, onClose }) {
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const initials = product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language (display only)
|
||||
const initials = mt(product).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -132,7 +133,7 @@ function ProductDetailModal({ product, onClose }) {
|
||||
{/* Info */}
|
||||
<div style={{ padding: '18px 20px 24px' }}>
|
||||
<div style={{ fontSize: 20, fontWeight: 800, color: 'var(--text)', lineHeight: 1.2, marginBottom: 6 }}>
|
||||
{product.name}
|
||||
{mt(product)}
|
||||
</div>
|
||||
<div style={{ fontSize: 18, fontWeight: 700, color: 'var(--accent, var(--x-warning))', marginBottom: product.description ? 14 : 0 }}>
|
||||
{money(product.base_price)}
|
||||
@@ -142,7 +143,7 @@ function ProductDetailModal({ product, onClose }) {
|
||||
fontSize: 14, color: 'var(--muted)', lineHeight: 1.6,
|
||||
borderTop: '1px solid var(--border)', paddingTop: 12,
|
||||
}}>
|
||||
{product.description}
|
||||
{mt(product, 'description')}
|
||||
</div>
|
||||
)}
|
||||
<Allergens allergens={product.allergens} style={{ borderTop: '1px solid var(--border)', paddingTop: 12, marginTop: 12 }} />
|
||||
@@ -189,6 +190,7 @@ function useLongPress(callback, delay = 2000) {
|
||||
|
||||
// ── Product card ──────────────────────────────────────────────────────────────
|
||||
function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
|
||||
const mt = useMenuText()
|
||||
const canQuickAdd = productAllowsQuickAdd(product)
|
||||
|
||||
const onDetail = useCallback(() => onShowDetail(product), [onShowDetail, product])
|
||||
@@ -214,13 +216,13 @@ function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
|
||||
{product.image_url
|
||||
? <img src={assetUrl(product.image_url)} alt="" className="product-btn__img" />
|
||||
: <span className="product-btn__initials">
|
||||
{product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()}
|
||||
{mt(product).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div className="product-btn__info">
|
||||
<span className="product-btn__name">{product.name}</span>
|
||||
<span className="product-btn__name">{mt(product)}</span>
|
||||
{product.tags?.length > 0 && (
|
||||
<div className="product-btn__tags">
|
||||
{product.tags.map(tag => (
|
||||
@@ -263,6 +265,7 @@ function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
|
||||
// ── Service Item Card ─────────────────────────────────────────────────────────
|
||||
function ServiceItemCard({ product, customerCount, onAdd }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText()
|
||||
const [qty, setQty] = useState(0)
|
||||
|
||||
function dec() { setQty(q => Math.max(0, q - 1)) }
|
||||
@@ -290,7 +293,7 @@ function ServiceItemCard({ product, customerCount, onAdd }) {
|
||||
{/* Top row: name + price */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
|
||||
<span style={{ fontSize: 15, fontWeight: 700, color: 'var(--text)', lineHeight: 1.2, flex: 1, minWidth: 0 }}>
|
||||
{product.name}
|
||||
{mt(product)}
|
||||
</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 600, color: hasPrice ? 'var(--x-warning)' : 'var(--muted)', flexShrink: 0 }}>
|
||||
{hasPrice ? money(product.base_price) : t('picker.noCharge')}
|
||||
@@ -438,6 +441,7 @@ function buildSections(parent, subcategories, directProducts) {
|
||||
|
||||
export default function ProductPicker({ categories, products, onAdd, onQuickAdd: onQuickAddProp, viewAllOpen, setViewAllOpen, customerCount, courses = [], globalCourseId = null, quickNotes }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: categories and products in the waiter's language
|
||||
const navigate = useNavigate()
|
||||
const favorites = useWaiterFavoritesStore(s => s.favorites)
|
||||
|
||||
@@ -575,7 +579,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
|
||||
style={{ background: bg, color, border: isActive && cat.color ? `2px solid ${cat.color}` : undefined }}
|
||||
onClick={() => selectCategory(cat.id)}
|
||||
>
|
||||
{cat.name}
|
||||
{mt(cat)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
@@ -670,7 +674,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
|
||||
onClick={() => toggleSub(key)}
|
||||
>
|
||||
{accentColor && <span className="subcat-header__pill" style={{ background: accentColor }} />}
|
||||
<span className="subcat-header__name">{section.name}</span>
|
||||
<span className="subcat-header__name">{mt(section)}</span>
|
||||
<span className="subcat-header__count">{sectionProducts.length}</span>
|
||||
<svg
|
||||
className="subcat-header__chevron"
|
||||
@@ -761,7 +765,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
|
||||
onClick={() => selectCategory(cat.id)}
|
||||
>
|
||||
<span className="cat-all-tile__overlay" style={{ background: overlay }} />
|
||||
<span className="cat-all-tile__name">{cat.name}</span>
|
||||
<span className="cat-all-tile__name">{mt(cat)}</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
@@ -773,7 +777,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
|
||||
const taggedProducts = activeTag ? products.filter(p => (p.tags || []).includes(activeTag)) : []
|
||||
const byCategory = taggedProducts.reduce((acc, p) => {
|
||||
const cat = categories.find(c => c.id === p.category_id)
|
||||
const key = cat?.name || t('picker.noCategory')
|
||||
const key = (cat && mt(cat)) || t('picker.noCategory')
|
||||
if (!acc[key]) acc[key] = []
|
||||
acc[key].push(p)
|
||||
return acc
|
||||
@@ -826,7 +830,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
|
||||
cursor: 'pointer', textAlign: 'left',
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{p.name}</span>
|
||||
<span style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{mt(p)}</span>
|
||||
<span style={{ fontSize: 13, color: 'var(--muted)' }}>{money(p.base_price)}</span>
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
// asks whether to send a cancellation (yes while the kitchen hasn't finished it).
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { useMenuNames } from '../hooks/useMenuNames'
|
||||
import { cancelByDefault, lowestQuantity } from '../logic/lines'
|
||||
|
||||
export default function QuantityModal({ item, mode, error, busy, onSave, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L
|
||||
const now = item.quantity
|
||||
const [qty, setQty] = useState(now)
|
||||
const [ticket, setTicket] = useState(() => cancelByDefault(item))
|
||||
@@ -19,7 +21,7 @@ export default function QuantityModal({ item, mode, error, busy, onSave, onClose
|
||||
<div className="modal-sheet" onClick={e => e.stopPropagation()} data-testid="quantity-sheet">
|
||||
<div className="modal-handle" />
|
||||
<h2 className="modal-title">{t('quantity.title')}</h2>
|
||||
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 14px' }}>{item.product_name || item.product?.name}</p>
|
||||
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 14px' }}>{names.lineName(item, item.product_name || item.product?.name)}</p>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 18, marginBottom: 6 }}>
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)', fontWeight: 700 }}>{t('quantity.now')}</div>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Menu names in the waiter's language (plan 6R.L) for what is already ordered: the sent lines of
|
||||
// a table, the move / quantity dialogs. `mt` is @xenia/access's useMenuText(); `productOf(id)`
|
||||
// finds the menu's product (the products the app already keeps, never fetched here), so a line
|
||||
// shows its product's and its choices' text in the waiter's language. Display only: the lines,
|
||||
// the tickets and the kitchen keep the venue's text. In the venue's own language nothing changes.
|
||||
import { useMemo } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useMenuText } from '@xenia/access'
|
||||
import { PRODUCTS_KEY, fetchAndCacheProducts } from './useProductCache'
|
||||
|
||||
export function useMenuNames() {
|
||||
const mt = useMenuText()
|
||||
// reads the cache the menu snapshot fills (LiveContext, AddItemsPage); never fetches itself
|
||||
const { data } = useQuery({ queryKey: PRODUCTS_KEY, queryFn: fetchAndCacheProducts, enabled: false })
|
||||
const byId = useMemo(() => new Map((data?.products ?? []).map(p => [p.id, p])), [data])
|
||||
return useMemo(() => {
|
||||
const productOf = id => byId.get(id)
|
||||
/** A sent order line's product name: the menu's text in the waiter's language, else `stored`. */
|
||||
const lineName = (item, stored) => mt.line(productOf(item?.product_id), stored)
|
||||
/** A sent line's choice (kept by its stored name) in the waiter's language. */
|
||||
const choiceName = (item, name) => mt.choice(productOf(item?.product_id), name)
|
||||
return { mt, productOf, lineName, choiceName }
|
||||
}, [mt, byId])
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import { warmPhotos } from '../services/photoCache'
|
||||
|
||||
export const PRODUCTS_KEY = ['products']
|
||||
|
||||
async function fetchAndCacheProducts() {
|
||||
export async function fetchAndCacheProducts() {
|
||||
const [prodRes, catRes] = await Promise.all([
|
||||
client.get('/api/products/', { params: { sold_at: 'in_store,in_store_takeaway' } }), // phase 3S
|
||||
client.get('/api/products/categories'),
|
||||
|
||||
@@ -16,6 +16,7 @@ import { assetUrl } from '../config/server'
|
||||
import { money } from '../i18n'
|
||||
import { LineError, estimate, wireLine } from '@xenia/api'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { useMenuText } from '@xenia/access'
|
||||
import { fade } from '../logic/colour'
|
||||
import SeatsHint from '../components/SeatsHint'
|
||||
|
||||
@@ -156,6 +157,7 @@ function fmtDraftQty(qty, unitType) {
|
||||
|
||||
export default function AddItemsPage() {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language; the cart keeps ids and stored names
|
||||
const { tableId, orderType } = useParams()
|
||||
const isStandalone = !!orderType // true when on /standalone/:orderType/add
|
||||
const [searchParams] = useSearchParams()
|
||||
@@ -434,6 +436,7 @@ export default function AddItemsPage() {
|
||||
// Returns structured sections for the expanded cart view
|
||||
function buildItemSections(item, product) {
|
||||
const sections = []
|
||||
const c = name => mt.choice(product, name) // 6R.L: shown in the waiter's language
|
||||
|
||||
if (item.selected_options?.length) {
|
||||
const prefIds = new Set(
|
||||
@@ -442,7 +445,7 @@ export default function AddItemsPage() {
|
||||
// Build a map: prefChoiceId → preference set name
|
||||
const prefSetByChoiceId = {}
|
||||
;(product?.preference_sets || []).forEach(ps => {
|
||||
ps.choices.forEach(c => { prefSetByChoiceId[c.id] = ps.name })
|
||||
ps.choices.forEach(ch => { prefSetByChoiceId[ch.id] = mt(ps) })
|
||||
})
|
||||
const quickNames = new Set((product?.quick_options || []).map(o => o.name))
|
||||
const extraIds = new Set((product?.options || []).map(o => o.id))
|
||||
@@ -462,7 +465,7 @@ export default function AddItemsPage() {
|
||||
const setName = prefSetByChoiceId[o.id] ?? ''
|
||||
let subName = null
|
||||
if (i + 1 < opts.length && opts[i + 1].id == null) {
|
||||
subName = opts[i + 1].name
|
||||
subName = c(opts[i + 1].name)
|
||||
i += 2
|
||||
} else {
|
||||
i++
|
||||
@@ -471,15 +474,15 @@ export default function AddItemsPage() {
|
||||
const existing = prefGroups.find(g => g.setName === setName)
|
||||
if (existing) {
|
||||
// multiple choices from same set (shouldn't normally happen, but handle gracefully)
|
||||
existing.values.push(subName ? `${o.name} · ${subName}` : o.name)
|
||||
existing.values.push(subName ? `${c(o.name)} · ${subName}` : c(o.name))
|
||||
} else {
|
||||
prefGroups.push({ setName, values: [subName ? `${o.name} · ${subName}` : o.name] })
|
||||
prefGroups.push({ setName, values: [subName ? `${c(o.name)} · ${subName}` : c(o.name)] })
|
||||
}
|
||||
} else if (o.id != null && extraIds.has(o.id)) {
|
||||
// Collect sub immediately following
|
||||
let subName = null
|
||||
if (i + 1 < opts.length && opts[i + 1].id == null) {
|
||||
subName = opts[i + 1].name
|
||||
subName = c(opts[i + 1].name)
|
||||
i += 2
|
||||
} else {
|
||||
i++
|
||||
@@ -487,9 +490,9 @@ export default function AddItemsPage() {
|
||||
// Merge duplicates
|
||||
const existing = extraGroups.find(g => g.id === o.id && g.subName === subName)
|
||||
if (existing) existing.qty++
|
||||
else extraGroups.push({ id: o.id, name: o.name, subName, qty: 1 })
|
||||
else extraGroups.push({ id: o.id, name: c(o.name), subName, qty: 1 })
|
||||
} else if (quickNames.has(o.name)) {
|
||||
quickLines.push(o)
|
||||
quickLines.push({ ...o, name: c(o.name) })
|
||||
i++
|
||||
} else {
|
||||
i++
|
||||
@@ -510,7 +513,7 @@ export default function AddItemsPage() {
|
||||
}
|
||||
|
||||
if (item.removed_ingredients?.length) {
|
||||
sections.push({ type: 'removed', lines: item.removed_ingredients.map(n => ({ name: n })) })
|
||||
sections.push({ type: 'removed', lines: item.removed_ingredients.map(n => ({ name: c(n) })) })
|
||||
}
|
||||
|
||||
if (item.notes) {
|
||||
@@ -523,14 +526,15 @@ export default function AddItemsPage() {
|
||||
// Simple flat summary for the collapsed one-liner
|
||||
function buildItemSummary(item) {
|
||||
const lines = []
|
||||
const c = name => mt.choice(getProduct(item.product_id), name) // 6R.L
|
||||
if (item.selected_options?.length) {
|
||||
item.selected_options.forEach(o => {
|
||||
if (o.price_delta && o.price_delta !== 0)
|
||||
lines.push(`${o.name} (${o.price_delta > 0 ? '+' : ''}${money(o.price_delta)})`)
|
||||
else lines.push(o.name)
|
||||
lines.push(`${c(o.name)} (${o.price_delta > 0 ? '+' : ''}${money(o.price_delta)})`)
|
||||
else lines.push(c(o.name))
|
||||
})
|
||||
}
|
||||
if (item.removed_ingredients?.length) lines.push(t('add.withoutList', { names: item.removed_ingredients.join(', ') }))
|
||||
if (item.removed_ingredients?.length) lines.push(t('add.withoutList', { names: item.removed_ingredients.map(c).join(', ') }))
|
||||
if (item.notes) lines.push(item.notes)
|
||||
return lines
|
||||
}
|
||||
@@ -682,7 +686,7 @@ export default function AddItemsPage() {
|
||||
const p = getProduct(item.product_id)
|
||||
return (
|
||||
<div key={item._key} style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
<span style={{ fontSize: 12, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 }}>{p?.name ?? `#${item.product_id}`}</span>
|
||||
<span style={{ fontSize: 12, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 }}>{p ? mt(p) : `#${item.product_id}`}</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 700, color: 'var(--x-warning)', fontVariantNumeric: 'tabular-nums', flexShrink: 0 }}>{fmtDraftQty(item.quantity, p?.unit_type)}</span>
|
||||
</div>
|
||||
)
|
||||
@@ -1167,7 +1171,8 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
|
||||
|
||||
function QuickAddToast({ product, count }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const initials = product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
|
||||
const mt = useMenuText()
|
||||
const initials = mt(product).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
|
||||
return (
|
||||
<div style={{
|
||||
position: 'fixed', top: 62, left: '50%',
|
||||
@@ -1199,7 +1204,7 @@ function QuickAddToast({ product, count }) {
|
||||
<div style={{
|
||||
fontSize: 13, fontWeight: 600, color: 'var(--text)',
|
||||
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
|
||||
}}>{product.name}</div>
|
||||
}}>{mt(product)}</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 1 }}>{t('add.inCart')}</div>
|
||||
</div>
|
||||
{/* Count badge */}
|
||||
@@ -1243,6 +1248,7 @@ function SectionIcon({ type }) {
|
||||
|
||||
function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onChangeQty }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText()
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const hasDetails = sections.length > 0
|
||||
|
||||
@@ -1261,7 +1267,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
|
||||
{/* Name */}
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{product?.name ?? `#${item.product_id}`}
|
||||
{product ? mt(product) : `#${item.product_id}`}
|
||||
</div>
|
||||
{!expanded && hasDetails && (
|
||||
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
@@ -1380,14 +1386,13 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
|
||||
|
||||
function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [], quickNotes }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: shown in the waiter's language, found by either
|
||||
const [drawerProduct, setDrawerProduct] = useState(null)
|
||||
const activeProducts = products.filter(p => p.lifecycle_status !== 'archived')
|
||||
|
||||
const results = query.trim().length === 0
|
||||
? []
|
||||
: activeProducts.filter(p =>
|
||||
p.name.toLowerCase().includes(query.trim().toLowerCase())
|
||||
)
|
||||
: activeProducts.filter(p => mt.matches(p, query.trim().toLowerCase()))
|
||||
|
||||
function openProduct(p) {
|
||||
// Blur the input first so the keyboard dismisses, then open the drawer
|
||||
@@ -1425,7 +1430,7 @@ function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [],
|
||||
{t('add.search.none', { query })}
|
||||
</p>
|
||||
) : results.map(p => {
|
||||
const initials = p.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
|
||||
const initials = mt(p).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
|
||||
return (
|
||||
<button
|
||||
key={p.id}
|
||||
@@ -1450,7 +1455,7 @@ function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [],
|
||||
</div>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{p.name}
|
||||
{mt(p)}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>
|
||||
{money(p.base_price)}
|
||||
|
||||
@@ -5,6 +5,7 @@ import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
|
||||
import { assetUrl } from '../config/server'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { money } from '../i18n'
|
||||
import { useMenuText } from '@xenia/access'
|
||||
|
||||
// ── Heart icon ────────────────────────────────────────────────────────────────
|
||||
function Heart({ filled, size = 22 }) {
|
||||
@@ -17,6 +18,7 @@ function Heart({ filled, size = 22 }) {
|
||||
|
||||
// ── Thumb (product image or initials) ─────────────────────────────────────────
|
||||
function Thumb({ product, size = 42, radius = 10 }) {
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language
|
||||
return (
|
||||
<div style={{
|
||||
width: size, height: size, borderRadius: radius, flexShrink: 0,
|
||||
@@ -26,7 +28,7 @@ function Thumb({ product, size = 42, radius = 10 }) {
|
||||
{product.image_url
|
||||
? <img src={assetUrl(product.image_url)} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
|
||||
: <span style={{ fontSize: Math.round(size * 0.33), fontWeight: 700, color: 'var(--muted)' }}>
|
||||
{product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()}
|
||||
{mt(product).trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
@@ -38,6 +40,7 @@ function Thumb({ product, size = 42, radius = 10 }) {
|
||||
// The waiter picks which items appear in that product's Favorites tab.
|
||||
|
||||
function AttrSection({ title, items, favIds, onToggle }) {
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language
|
||||
if (!items || items.length === 0) return null
|
||||
return (
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
@@ -65,7 +68,7 @@ function AttrSection({ title, items, favIds, onToggle }) {
|
||||
>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{item.name}
|
||||
{mt(item)}
|
||||
</div>
|
||||
{item.extra_cost != null && item.extra_cost !== 0 && (
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)' }}>+{money(item.extra_cost)}</div>
|
||||
@@ -90,6 +93,7 @@ function AttrSection({ title, items, favIds, onToggle }) {
|
||||
|
||||
function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language
|
||||
// Local state: { quick: id[], ingredients: id[], options: id[], prefs: id[] }
|
||||
// Start from waiter overrides if they exist, otherwise seed from manager's is_favorite flags
|
||||
function seedFromManager() {
|
||||
@@ -164,7 +168,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
<Thumb product={product} size={38} radius={9} />
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 15, fontWeight: 700, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{product.name}
|
||||
{mt(product)}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)' }}>
|
||||
{waiterAttrFavs ? t('favSetup.personalOn') : t('favSetup.managerDefaults')}
|
||||
@@ -257,6 +261,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
// ── Product row (ALL tab) ─────────────────────────────────────────────────────
|
||||
function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language
|
||||
const { formatMoney } = useFormat()
|
||||
const hasAttrs = (
|
||||
(product.quick_options || []).length > 0 ||
|
||||
@@ -279,7 +284,7 @@ function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
<div style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{product.name}
|
||||
{mt(product)}
|
||||
</div>
|
||||
{hasAttrOverride && (
|
||||
<Heart filled size={12} />
|
||||
@@ -304,6 +309,7 @@ function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs
|
||||
// ── Draggable favorites list (pointer-events — works on touch + mouse) ─────────
|
||||
function FavoritesList({ items, products, onReorder }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language
|
||||
const [dragging, setDragging] = useState(null)
|
||||
const [dropIndex, setDropIndex] = useState(null)
|
||||
const containerRef = useRef(null)
|
||||
@@ -405,7 +411,7 @@ function FavoritesList({ items, products, onReorder }) {
|
||||
<Thumb product={product} size={38} radius={9} />
|
||||
|
||||
<span style={{ flex: 1, fontSize: 14, fontWeight: 600, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{product.name}
|
||||
{mt(product)}
|
||||
</span>
|
||||
|
||||
<span style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0 }}>{money(product.base_price)}</span>
|
||||
@@ -424,6 +430,7 @@ function FavoritesList({ items, products, onReorder }) {
|
||||
// ── Main page ─────────────────────────────────────────────────────────────────
|
||||
export default function FavoritesSetupPage() {
|
||||
const { t } = useTranslation('waiter')
|
||||
const mt = useMenuText() // 6R.L: names in the waiter's language
|
||||
const navigate = useNavigate()
|
||||
const { products, categories } = useProductCache()
|
||||
const { favorites, toggleFavorite, reorderFavorites, itemFavorites, setItemFavorites } = useWaiterFavoritesStore()
|
||||
@@ -482,7 +489,7 @@ export default function FavoritesSetupPage() {
|
||||
background: 'var(--bg2)', borderBottom: '1px solid var(--border)',
|
||||
position: 'sticky', top: 0, zIndex: 1,
|
||||
}}>
|
||||
{cat.name}
|
||||
{mt(cat)}
|
||||
</div>
|
||||
{allProds.map(p => (
|
||||
<ProductRow
|
||||
|
||||
@@ -16,6 +16,7 @@ import { TransferIcon, MergeIcon, FlagsIcon, WaiterIcon, PrintIcon } from '../co
|
||||
import usePaymentSettingsStore from '../store/paymentSettingsStore'
|
||||
import useTableViewStore from '../store/tableViewStore'
|
||||
import { parseNumber, useTranslation } from '@xenia/i18n'
|
||||
import { useMenuNames } from '../hooks/useMenuNames'
|
||||
import PriceReason from '../components/PriceReason'
|
||||
import { priceReasonText } from '../logic/priceRules'
|
||||
import PriceHistory from '../components/PriceHistory'
|
||||
@@ -93,6 +94,7 @@ function mergeItems(items, mode) {
|
||||
|
||||
function SplitModal({ item, onConfirm, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L: the waiter's language, display only
|
||||
const [splitQty, setSplitQty] = useState(1)
|
||||
const max = item.quantity - 1
|
||||
|
||||
@@ -102,7 +104,7 @@ function SplitModal({ item, onConfirm, onClose }) {
|
||||
<div className="modal-handle" />
|
||||
<h2 className="modal-title">{t('detail.split.title')}</h2>
|
||||
<p style={{ textAlign: 'center', color: 'var(--x-ink-2)', fontSize: 14, marginBottom: 4 }}>
|
||||
{item.product?.name} ×{item.quantity}
|
||||
{names.lineName(item, item.product?.name)} ×{item.quantity}
|
||||
</p>
|
||||
<p style={{ textAlign: 'center', color: 'var(--x-ink-2)', fontSize: 13, marginBottom: 16 }}>
|
||||
{t('detail.split.howMany')}
|
||||
@@ -134,6 +136,7 @@ function SplitModal({ item, onConfirm, onClose }) {
|
||||
|
||||
function PriceAdjustModal({ item, rules, error, onConfirm, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L: the waiter's language, display only
|
||||
const [reason, setReason] = useState({ choice: '', other: '' }) // 6F.3
|
||||
const [tried, setTried] = useState(false)
|
||||
const basePrice = item.unit_price ?? 0
|
||||
@@ -173,7 +176,7 @@ function PriceAdjustModal({ item, rules, error, onConfirm, onClose }) {
|
||||
<div className="modal-handle" />
|
||||
<h2 className="modal-title">{t('detail.price.title')}</h2>
|
||||
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 16px' }}>
|
||||
{item.product?.name}
|
||||
{names.lineName(item, item.product?.name)}
|
||||
</p>
|
||||
|
||||
{/* Current effective price — tap to type */}
|
||||
@@ -276,10 +279,11 @@ function PriceAdjustModal({ item, rules, error, onConfirm, onClose }) {
|
||||
|
||||
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, onCombine, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, canSeePriceHistory, onPriceHistory, movedLine, onMoveHistory, canChangeQty, onChangeQty, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L: the waiter's language, display only
|
||||
const { items, singleStacked, multiSelect } = target
|
||||
const label = multiSelect
|
||||
? t('detail.selected', { count: items.length })
|
||||
: items[0]?.product?.name || `#${items[0]?.product_id}`
|
||||
: names.lineName(items[0], items[0]?.product?.name) || `#${items[0]?.product_id}`
|
||||
|
||||
const actionRows = [
|
||||
// 6F.5: correct how many there are, without sending it to the kitchen again
|
||||
@@ -464,6 +468,7 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
|
||||
|
||||
function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L: the waiter's language, display only
|
||||
const activeItems = (order?.items ?? []).filter(i => i.status === 'active')
|
||||
const [selectedIds, setSelectedIds] = useState(activeItems.map(i => i.id))
|
||||
const [pct, setPct] = useState(10)
|
||||
@@ -544,7 +549,7 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
|
||||
</div>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 13, fontWeight: 600, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{item.product?.name ?? `#${item.product_id}`}
|
||||
{names.lineName(item, item.product?.name) ?? `#${item.product_id}`}
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--muted)' }}>×{item.quantity} · {fmtPrice(eff)}</div>
|
||||
</div>
|
||||
@@ -1154,6 +1159,7 @@ function CustomerCountModal({ value, seats, onChange, onClose }) {
|
||||
|
||||
export default function TableDetailPage() {
|
||||
const { t } = useTranslation('waiter')
|
||||
const names = useMenuNames() // 6R.L: the waiter's language, display only
|
||||
const { tableId, orderId: standaloneOrderId } = useParams()
|
||||
const isStandalone = !!standaloneOrderId
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
@@ -2338,7 +2344,7 @@ export default function TableDetailPage() {
|
||||
onMoveHistory={() => {
|
||||
const item = itemActionTarget.items[0]
|
||||
setItemActionTarget(null)
|
||||
setMoveSheet({ title: t('moves.lineTitle'), subtitle: item.product_name || item.product?.name, moves: moves.items[item.id] ?? [], itemId: item.id })
|
||||
setMoveSheet({ title: t('moves.lineTitle'), subtitle: names.lineName(item, item.product_name || item.product?.name), moves: moves.items[item.id] ?? [], itemId: item.id })
|
||||
}}
|
||||
onPriceHistory={() => {
|
||||
const item = itemActionTarget.items[0]
|
||||
|
||||
Reference in New Issue
Block a user