feat(waiter): English-first texts, part b: table detail, ordering, options, payment (platform-v2 step 4.5b)

- Table detail (actions, item actions, split, price, discount, pay / revert / close,
  move / merge / transfer, guests, flags, assign, print), the order drawer (tabs,
  options, quick notes, price change, summary), add items (cart, totals, deals,
  search), the order summary and the summary before sending, the product picker.
- Money everywhere here in the language's format (`money()` in waiter i18n.js for
  helpers shared by several components, useFormat() elsewhere).
- The default quick notes are keys (the venue's own quick notes still win).
- Variables named `t` (tables, tabs, timers) renamed so they don't shadow t().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 03:59:12 +02:00
co-authored by Claude Opus 5.5
parent 37155c0457
commit 2c4f78af47
10 changed files with 939 additions and 337 deletions
+81 -63
View File
@@ -2,6 +2,8 @@ import { useState, useEffect, useRef } from 'react'
import { useCan } from '@xenia/access'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { assetUrl } from '../config/server'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
// ── Helpers ──────────────────────────────────────────────────────────────────
@@ -78,7 +80,6 @@ function buildFavorites(product, waiterOverride) {
return items.sort((a, b) => a.sortOrder - b.sortOrder)
}
const QUICK_NOTES = ['Χωρίς αλάτι', 'Βγάλτε γρήγορα', 'Αλλεργία!', 'Κόψτε σε μικρά κομμάτια', 'Έξτρα χαρτοπετσέτες']
// ── Primitives ────────────────────────────────────────────────────────────────
@@ -150,6 +151,7 @@ function Row({ selected, onClick, children, right, left, style = {} }) {
// ── Shared: single quick option row ──────────────────────────────────────────
function QuickOptionRow({ opt, quickState, setQuickState, compact }) {
const { t } = useTranslation('waiter')
const qty = quickState[opt.id] || 0
const selected = qty > 0
const toggleSingle = () => setQuickState(s => ({ ...s, [opt.id]: selected ? 0 : 1 }))
@@ -172,7 +174,7 @@ function QuickOptionRow({ opt, quickState, setQuickState, compact }) {
) : null}
>
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{opt.name}</div>
{opt.price > 0 && <div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>+{opt.price.toFixed(2)} €{opt.allow_multiple ? ' each' : ''}</div>}
{opt.price > 0 && <div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>+{money(opt.price)}{opt.allow_multiple ? ` ${t('drawer.each')}` : ''}</div>}
</Row>
)
}
@@ -180,6 +182,7 @@ function QuickOptionRow({ opt, quickState, setQuickState, compact }) {
// ── Shared: single extra/option row ──────────────────────────────────────────
function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setExpandedExtra, compact }) {
const { t } = useTranslation('waiter')
const sel = extrasState[opt.id]
const selected = !!sel
const open = expandedExtra === opt.id
@@ -245,10 +248,10 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
>
<div style={{ fontSize: compact ? 13 : 15, fontWeight: 500, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{opt.name}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>
{(opt.extra_cost ?? 0) !== 0 ? `+${opt.extra_cost.toFixed(2)} €` : 'Included'}
{(opt.extra_cost ?? 0) !== 0 ? `+${money(opt.extra_cost)}` : t('drawer.included')}
{subLabel && <span style={{ color: '#f59e0b', fontWeight: 600 }}> · {subLabel}</span>}
{isMultiSelect && selectedSubCount > 0 && (
<span style={{ color: '#f59e0b', fontWeight: 600 }}> · {selectedSubCount} επιλεγμένα</span>
<span style={{ color: '#f59e0b', fontWeight: 600 }}> · {t('drawer.selectedCount', { count: selectedSubCount })}</span>
)}
</div>
</Row>
@@ -256,7 +259,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
{/* Single-select sub-choices (radio) */}
{selected && open && hasSubs && !isMultiSelect && (
<div style={{ margin: '6px 0 2px 16px', paddingLeft: 14, borderLeft: '2px solid rgba(245,158,11,0.3)', display: 'flex', flexWrap: 'wrap', gap: 6 }}>
<div style={{ width: '100%', fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, padding: '6px 2px 2px' }}>Επιλογή</div>
<div style={{ width: '100%', fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, padding: '6px 2px 2px' }}>{t('drawer.choose')}</div>
{opt.sub_choices.map((sub, si) => {
const isSel = sel.subName === sub.name
return (
@@ -267,7 +270,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
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>
{(sub.extra_cost ?? 0) !== 0 && <div style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0, marginLeft: 6 }}>+{sub.extra_cost.toFixed(2)} €</div>}
{(sub.extra_cost ?? 0) !== 0 && <div style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0, marginLeft: 6 }}>+{money(sub.extra_cost)}</div>}
</div>
</Row>
</div>
@@ -279,7 +282,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
{/* Multi-select sub-choices (checkboxes, optional qty stepper per sub) */}
{selected && open && hasSubs && isMultiSelect && (
<div style={{ margin: '6px 0 2px 16px', paddingLeft: 14, borderLeft: '2px solid rgba(245,158,11,0.3)', display: 'flex', flexWrap: 'wrap', gap: 6 }}>
<div style={{ width: '100%', fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, padding: '6px 2px 2px' }}>Επιλογή (πολλαπλή)</div>
<div style={{ width: '100%', fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, padding: '6px 2px 2px' }}>{t('drawer.chooseMany')}</div>
{opt.sub_choices.map((sub, si) => {
const subQty = subs[sub.name] || 0
const subSel = subQty > 0
@@ -306,7 +309,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
{sub.name}
{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 }}>+{sub.extra_cost.toFixed(2)} €{sub.allow_multiple ? ' each' : ''}</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>}
</div>
</Row>
</div>
@@ -321,6 +324,7 @@ function ExtraOptionRow({ opt, extrasState, setExtrasState, expandedExtra, setEx
// ── Shared: single ingredient row ─────────────────────────────────────────────
function IngredientRow({ ing, removedState, setRemovedState, compact }) {
const { t } = useTranslation('waiter')
const removed = !!removedState[ing.id]
return (
<Row selected={false}
@@ -336,7 +340,7 @@ function IngredientRow({ ing, removedState, setRemovedState, compact }) {
display: 'inline-flex', alignItems: 'center',
transition: 'all 120ms ease', whiteSpace: 'nowrap',
}}>
{removed ? 'Αφαιρέθηκε' : 'Αφαίρεση'}
{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>
@@ -347,6 +351,7 @@ function IngredientRow({ ing, removedState, setRemovedState, compact }) {
// ── Shared: single preference set ─────────────────────────────────────────────
function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSubs, setSharedSubs }) {
const { t } = useTranslation('waiter')
const selChoice = prefs[ps.id] ?? null
const complete = selChoice != null
&& !(selChoice.sub_choices?.length > 0 && subChoices[selChoice.id] == null)
@@ -367,7 +372,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
<div>
<div style={{ display: 'flex', alignItems: 'baseline', gap: 8, padding: '0 2px 10px' }}>
<div style={{ fontSize: 14, fontWeight: 700, color: complete ? 'var(--text)' : '#ef4444' }}>{ps.name}</div>
{!complete && <div style={{ fontSize: 11, fontWeight: 700, color: '#ef4444', textTransform: 'uppercase', letterSpacing: 0.6 }}>Απαιτείται</div>}
{!complete && <div style={{ fontSize: 11, fontWeight: 700, color: '#ef4444', textTransform: 'uppercase', letterSpacing: 0.6 }}>{t('drawer.required')}</div>}
</div>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
{ps.choices.map(ch => {
@@ -379,20 +384,20 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
<div key={ch.id} style={{ width: ch.is_compact ? 'calc(50% - 4px)' : '100%', minWidth: 0 }}>
<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 ? '+' : ''}{ch.extra_cost.toFixed(2)} €</div> : null}>
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>
</Row>
{isSel && hasSubs && (
<div style={{ margin: '6px 0 2px 16px', paddingLeft: 14, borderLeft: `2px solid ${subMissing ? '#ef4444' : 'rgba(245,158,11,0.3)'}`, display: 'flex', flexWrap: 'wrap', gap: 6 }}>
{subMissing && <p style={{ width: '100%', fontSize: 12, color: '#ef4444', margin: '4px 2px 2px' }}>— απαιτείται επιλογή</p>}
{subMissing && <p style={{ width: '100%', fontSize: 12, color: '#ef4444', margin: '4px 2px 2px' }}>{t('drawer.choiceRequired')}</p>}
{ch.sub_choices.map((sub, si) => {
const subSel = subChoices[ch.id]?.name === sub.name
return (
<div key={si} style={{ width: sub.is_compact ? 'calc(50% - 3px)' : '100%', minWidth: 0 }}>
<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 }}>+{sub.extra_cost.toFixed(2)} €</div> : null}>
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>
</Row>
</div>
@@ -414,7 +419,7 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
<div key={si} style={{ width: sub.is_compact ? 'calc(50% - 3px)' : '100%', minWidth: 0 }}>
<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 }}>+{sub.extra_cost.toFixed(2)} €</div> : null}>
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>
</Row>
</div>
@@ -431,10 +436,11 @@ function PrefSetBlock({ ps, prefs, setPrefs, subChoices, setSubChoices, sharedSu
// ── Tab: Favorites ────────────────────────────────────────────────────────────
function FavoritesTab({ product, waiterOverride, quickState, setQuickState, extrasState, setExtrasState, expandedExtra, setExpandedExtra, removedState, setRemovedState, prefs, setPrefs, subChoices, setSubChoices, sharedSubs, setSharedSubs }) {
const { t } = useTranslation('waiter')
const favorites = buildFavorites(product, waiterOverride)
if (favorites.length === 0) return (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>Δεν υπάρχουν αγαπημένα για αυτό το προϊόν.</p>
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>{t('drawer.empty.favorites')}</p>
)
return (
@@ -467,9 +473,10 @@ function FavoritesTab({ product, waiterOverride, quickState, setQuickState, extr
// ── Tab: Quick Options ────────────────────────────────────────────────────────
function QuickTab({ product, quickState, setQuickState }) {
const { t } = useTranslation('waiter')
const quickOptions = product.quick_options || []
if (quickOptions.length === 0) return (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>Δεν υπάρχουν γρήγορες επιλογές.</p>
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>{t('drawer.empty.quick')}</p>
)
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
@@ -538,11 +545,12 @@ function partitionByGroup(items, modifierGroups) {
// ── Tab: Extras ───────────────────────────────────────────────────────────────
function ExtrasTab({ product, extrasState, setExtrasState, expandedExtra, setExpandedExtra }) {
const { t } = useTranslation('waiter')
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 || []
if (options.length === 0) return (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>Δεν υπάρχουν extras.</p>
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>{t('drawer.empty.extras')}</p>
)
function toggleGroup(id) { setCollapsedGroups(s => ({ ...s, [id]: !s[id] })) }
@@ -581,14 +589,15 @@ function ExtrasTab({ product, extrasState, setExtrasState, expandedExtra, setExp
)
}
// ── Tab: Υλικά (Ingredients) ─────────────────────────────────────────────────
// ── Tab: Ingredients ─────────────────────────────────────────────────
function IngredientsTab({ product, removedState, setRemovedState }) {
const { t } = useTranslation('waiter')
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 || []
if (ingredients.length === 0) return (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>Δεν υπάρχουν υλικά.</p>
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>{t('drawer.empty.ingredients')}</p>
)
function toggleGroup(id) { setCollapsedGroups(s => ({ ...s, [id]: !s[id] })) }
@@ -627,14 +636,15 @@ function IngredientsTab({ product, removedState, setRemovedState }) {
)
}
// ── Tab: Προτιμήσεις ─────────────────────────────────────────────────────────
// ── Tab: Preferences ─────────────────────────────────────────────────────────
function PrefsTab({ product, prefs, setPrefs, subChoices, setSubChoices, sharedSubs, setSharedSubs }) {
const { t } = useTranslation('waiter')
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 || []
if (preferenceSets.length === 0) return (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>Δεν υπάρχουν προτιμήσεις.</p>
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '32px 0', fontSize: 14 }}>{t('drawer.empty.prefs')}</p>
)
function toggleGroup(id) { setCollapsedGroups(s => ({ ...s, [id]: !s[id] })) }
@@ -694,6 +704,7 @@ function fmtDecimalQty(qty, cfg) {
}
function QuantityTab({ unitCfg, qty, setQty }) {
const { t } = useTranslation('waiter')
const [editingQty, setEditingQty] = useState(false)
const [qtyInput, setQtyInput] = useState('')
const inputRef = useRef(null)
@@ -747,7 +758,7 @@ function QuantityTab({ unitCfg, qty, setQty }) {
{/* Quick presets — 3 rows of 4 */}
<div>
<p style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', letterSpacing: 0.8, marginBottom: 8, textAlign: 'center' }}>ΓΡΗΓΟΡΗ ΕΠΙΛΟΓΗ</p>
<p style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', letterSpacing: 0.8, marginBottom: 8, textAlign: 'center' }}>{t('drawer.qty.quickPick')}</p>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 8 }}>
{unitCfg.presets.map(v => (
<button
@@ -769,7 +780,7 @@ function QuantityTab({ unitCfg, qty, setQty }) {
{/* Quick ± offset buttons — 2×2 grid */}
<div>
<p style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', letterSpacing: 0.8, marginBottom: 8, textAlign: 'center' }}>ΓΡΗΓΟΡΗ ΠΡΟΣΘΗΚΗ</p>
<p style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', letterSpacing: 0.8, marginBottom: 8, textAlign: 'center' }}>{t('drawer.qty.quickAdd')}</p>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 8 }}>
{unitCfg.offsets.map(off => (
<button
@@ -804,6 +815,7 @@ function QuantityTab({ unitCfg, qty, setQty }) {
const PRICE_DELTAS = [-5, -3, -2, -1, -0.5, -0.2, +0.2, +0.5, +1, +2, +3, +5]
function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
const { t } = useTranslation('waiter')
const [editing, setEditing] = useState(false)
const [rawInput, setRawInput] = useState('')
const inputRef = useRef(null)
@@ -832,7 +844,7 @@ function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
<div style={{ padding: '10px 14px', background: 'rgba(245,158,11,0.08)', border: '1px solid rgba(245,158,11,0.2)', borderRadius: 10, fontSize: 13, color: '#f59e0b' }}>
Αλλαγή τιμής μόνο για αυτό το αντικείμενο. Δεν επηρεάζει άλλες παραγγελίες.
{t('drawer.price.intro')}
</div>
{/* Price display / input */}
@@ -857,7 +869,7 @@ function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
color: priceAdj !== 0 ? '#f59e0b' : 'var(--text)',
fontSize: 22, fontWeight: 800, cursor: 'pointer', fontFamily: 'inherit',
}}>
{effectivePrice.toFixed(2)} €
{money(effectivePrice)}
</button>
)}
<button onClick={() => applyDelta(+0.1)} style={{ width: 44, height: 44, borderRadius: '50%', border: '1.5px solid var(--border)', background: 'var(--bg3)', fontSize: 20, fontWeight: 700, color: 'var(--text)', cursor: 'pointer' }}>+</button>
@@ -865,11 +877,11 @@ function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
{priceAdj !== 0 && (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 10 }}>
<span style={{ fontSize: 13, color: 'var(--muted)' }}>Βάση: {basePrice.toFixed(2)} €</span>
<span style={{ fontSize: 13, color: 'var(--muted)' }}>{t('drawer.price.base', { price: money(basePrice) })}</span>
<span style={{ fontSize: 13, fontWeight: 700, color: priceAdj > 0 ? '#4ade80' : '#f87171' }}>
{priceAdj > 0 ? '+' : ''}{priceAdj.toFixed(2)} €
{priceAdj > 0 ? '+' : ''}{money(priceAdj)}
</span>
<button onClick={() => setPriceAdj(0)} style={{ padding: '3px 10px', borderRadius: 8, border: '1px solid var(--border)', background: 'var(--bg3)', color: 'var(--muted)', fontSize: 12, cursor: 'pointer' }}>Επαναφορά</button>
<button onClick={() => setPriceAdj(0)} style={{ padding: '3px 10px', borderRadius: 8, border: '1px solid var(--border)', background: 'var(--bg3)', color: 'var(--muted)', fontSize: 12, cursor: 'pointer' }}>{t('settings.reset.title')}</button>
</div>
)}
@@ -896,19 +908,21 @@ function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
// ── Tab: Notes ────────────────────────────────────────────────────────────────
function NotesTab({ note, setNote, quickNotes = FALLBACK_QUICK_NOTES }) {
function NotesTab({ note, setNote, quickNotes }) {
const { t } = useTranslation('waiter')
quickNotes = quickNotes ?? FALLBACK_QUICK_NOTES.map(k => t(k))
return (
<div>
<textarea
value={note}
onChange={e => setNote(e.target.value)}
placeholder="π.χ. Χωρίς αλάτι, κόψτε στη μέση..."
placeholder={t('drawer.notes.placeholder')}
rows={5}
style={{ width: '100%', padding: 14, fontSize: 15, fontFamily: 'inherit', color: 'var(--text)', background: 'var(--bg2)', border: '1px solid var(--border)', borderRadius: 12, resize: 'none', outline: 'none', boxSizing: 'border-box' }}
/>
{quickNotes.length > 0 && (
<>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, marginTop: 20, marginBottom: 8 }}>Γρήγορες σημειώσεις</div>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, marginTop: 20, marginBottom: 8 }}>{t('drawer.notes.quickTitle')}</div>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
{quickNotes.map(q => (
<button key={q} onClick={() => setNote(n => n ? `${n}\n${q}` : q)}
@@ -927,12 +941,13 @@ function NotesTab({ note, setNote, quickNotes = FALLBACK_QUICK_NOTES }) {
/** One group of the summary (prefs, quick options, extras, removed) with its "change" link. */
function Section({ title, tab, lines, onJumpTab }) {
const { t } = useTranslation('waiter')
if (lines.length === 0) return null
return (
<div style={{ marginBottom: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '0 2px 8px' }}>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6 }}>{title}</div>
<button onClick={() => onJumpTab(tab)} style={{ background: 'none', border: 'none', fontSize: 12, fontWeight: 700, color: '#f59e0b', cursor: 'pointer', textTransform: 'uppercase', letterSpacing: 0.6 }}>Αλλαγή</button>
<button onClick={() => onJumpTab(tab)} style={{ background: 'none', border: 'none', fontSize: 12, fontWeight: 700, color: '#f59e0b', cursor: 'pointer', textTransform: 'uppercase', letterSpacing: 0.6 }}>{t('common.change')}</button>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{lines.map((l, i) => (
@@ -945,7 +960,7 @@ function Section({ title, tab, lines, onJumpTab }) {
</>
) : l.group === 'removed' ? (
<div style={{ fontSize: 14, fontWeight: 500, color: 'var(--text)' }}>
Χωρίς {l.label}
{t('drawer.without', { name: l.label })}
</div>
) : l.group === 'extras' ? (
<div style={{ fontSize: 14, fontWeight: 500, color: 'var(--text)' }}>
@@ -960,7 +975,7 @@ function Section({ title, tab, lines, onJumpTab }) {
</div>
)}
</div>
{l.price !== 0 && <div style={{ fontSize: 13, fontWeight: 600, color: l.price < 0 ? 'var(--danger)' : 'var(--text)', fontVariantNumeric: 'tabular-nums' }}>{l.price > 0 ? '+' : ''}{l.price.toFixed(2)} €</div>}
{l.price !== 0 && <div style={{ fontSize: 13, fontWeight: 600, color: l.price < 0 ? 'var(--danger)' : 'var(--text)', fontVariantNumeric: 'tabular-nums' }}>{l.price > 0 ? '+' : ''}{money(l.price)}</div>}
</div>
))}
</div>
@@ -969,6 +984,7 @@ function Section({ title, tab, lines, onJumpTab }) {
}
function SummaryTab({ _product, summaryLines, note, onJumpTab }) {
const { t } = useTranslation('waiter')
const isEmpty = summaryLines.length === 0 && !note
const byGroup = { quick: [], extras: [], removed: [], prefs: [] }
summaryLines.forEach(l => byGroup[l.group]?.push(l))
@@ -978,19 +994,19 @@ function SummaryTab({ _product, summaryLines, note, onJumpTab }) {
<div>
{isEmpty ? (
<div style={{ padding: '40px 16px', textAlign: 'center', color: 'var(--muted)', fontSize: 14 }}>
Δεν έχει γίνει καμία προσαρμογή. Χρησιμοποιήστε τις καρτέλες για να διαμορφώσετε το προϊόν.
{t('drawer.summary.empty')}
</div>
) : (
<>
<Section title="Προτιμήσεις" tab="prefs" lines={byGroup.prefs} onJumpTab={onJumpTab} />
<Section title="Γρήγορες Επιλογές" tab="quick" lines={byGroup.quick} onJumpTab={onJumpTab} />
<Section title="Extras" tab="extras" lines={byGroup.extras} onJumpTab={onJumpTab} />
<Section title="Αφαιρέθηκαν" tab="ingredients" lines={byGroup.removed} onJumpTab={onJumpTab} />
<Section title={t('drawer.tabs.prefs')} tab="prefs" lines={byGroup.prefs} onJumpTab={onJumpTab} />
<Section title={t('drawer.tabs.quick')} tab="quick" lines={byGroup.quick} onJumpTab={onJumpTab} />
<Section title={t('drawer.tabs.extrasTitle')} tab="extras" lines={byGroup.extras} onJumpTab={onJumpTab} />
<Section title={t('drawer.summary.removed')} tab="ingredients" lines={byGroup.removed} onJumpTab={onJumpTab} />
{note && (
<div style={{ marginBottom: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '0 2px 8px' }}>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6 }}>Σημείωση</div>
<button onClick={() => onJumpTab('notes')} style={{ background: 'none', border: 'none', fontSize: 12, fontWeight: 700, color: '#f59e0b', cursor: 'pointer', textTransform: 'uppercase', letterSpacing: 0.6 }}>Αλλαγή</button>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6 }}>{t('drawer.tabs.note')}</div>
<button onClick={() => onJumpTab('notes')} style={{ background: 'none', border: 'none', fontSize: 12, fontWeight: 700, color: '#f59e0b', cursor: 'pointer', textTransform: 'uppercase', letterSpacing: 0.6 }}>{t('common.change')}</button>
</div>
<div style={{ padding: '12px 14px', background: 'rgba(245,158,11,0.08)', border: '1px solid rgba(245,158,11,0.2)', borderRadius: 10, fontSize: 14, color: 'var(--text)', lineHeight: 1.4, whiteSpace: 'pre-wrap' }}>{note}</div>
</div>
@@ -1043,9 +1059,11 @@ function CoursesTab({ courses, courseId, setCourseId }) {
)
}
const FALLBACK_QUICK_NOTES = ['Χωρίς αλάτι', 'Βγάλτε γρήγορα', 'Αλλεργία!', 'Κόψτε σε μικρά κομμάτια', 'Έξτρα χαρτοπετσέτες']
// the venue's own quick notes (Settings) win; these are the defaults, in the waiter's language
const FALLBACK_QUICK_NOTES = ['drawer.notes.noSalt', 'drawer.notes.quick', 'drawer.notes.allergy', 'drawer.notes.smallPieces', 'drawer.notes.napkins']
export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialState, courses, quickNotes }) {
const { t } = useTranslation('waiter')
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.
@@ -1341,16 +1359,16 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
summary: <svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2M9 12h6M9 16h4" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/></svg>,
}
const tabs = [
hasTabs.favorites && { id: 'favorites', label: 'Αγαπημένα' },
hasTabs.quick && { id: 'quick', label: 'Γρήγορες' },
hasTabs.extras && { id: 'extras', label: 'Έξτρα' },
hasTabs.ingredients && { id: 'ingredients', label: 'Υλικά' },
hasTabs.prefs && { id: 'prefs', label: 'Επιλογές' },
hasTabs.quantity && { id: 'quantity', label: `Ποσότητα (${unitCfg?.label})` },
hasTabs.favorites && { id: 'favorites', label: t('settings.tabs.favorites') },
hasTabs.quick && { id: 'quick', label: t('drawer.tabs.quickShort') },
hasTabs.extras && { id: 'extras', label: t('drawer.tabs.extras') },
hasTabs.ingredients && { id: 'ingredients', label: t('drawer.tabs.ingredients') },
hasTabs.prefs && { id: 'prefs', label: t('drawer.tabs.options') },
hasTabs.quantity && { id: 'quantity', label: t('drawer.tabs.quantity', { unit: unitCfg?.label }) },
(courses?.length > 0) && { id: 'courses', label: 'Courses' },
{ id: 'notes', label: 'Σημείωση' },
priceAdjAllowed && { id: 'price_adjust', label: 'Τιμή' },
{ id: 'summary', label: 'Σύνοψη' },
{ id: 'notes', label: t('drawer.tabs.note') },
priceAdjAllowed && { id: 'price_adjust', label: t('drawer.tabs.price') },
{ id: 'summary', label: t('drawer.tabs.summary') },
].filter(Boolean)
const badgeFor = id => {
@@ -1415,8 +1433,8 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
<div style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', lineHeight: 1.2 }}>{product.name}</div>
<div style={{ fontSize: 13, color: priceAdj !== 0 ? '#f59e0b' : 'var(--muted)', marginTop: 2 }}>
{priceAdj !== 0
? <><span style={{ textDecoration: 'line-through', opacity: 0.5 }}>{product.base_price.toFixed(2)}</span> → {(product.base_price + priceAdj).toFixed(2)} €</>
: <>{product.base_price.toFixed(2)} €</>
? <><span style={{ textDecoration: 'line-through', opacity: 0.5 }}>{money(product.base_price)}</span> → {money(product.base_price + priceAdj)}</>
: <>{money(product.base_price)}</>
}
</div>
</div>
@@ -1428,13 +1446,13 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
{/* Tabs bar */}
<div ref={tabsScrollRef} style={{ marginTop: 12, borderBottom: '1px solid var(--border)', overflowX: 'auto', scrollbarWidth: 'none', flexShrink: 0 }}>
<div style={{ display: 'flex', padding: '0 12px', gap: 2, minWidth: 'max-content' }}>
{tabs.map(t => {
const active = activeTab === t.id
const badge = badgeFor(t.id)
const isAlert = (t.id === 'prefs' && prefsTabAlert) || (t.id === 'favorites' && favTabAlert)
{tabs.map(tb => {
const active = activeTab === tb.id
const badge = badgeFor(tb.id)
const isAlert = (tb.id === 'prefs' && prefsTabAlert) || (tb.id === 'favorites' && favTabAlert)
const tabColor = isAlert ? '#f87171' : active ? '#f59e0b' : 'var(--muted)'
return (
<button key={t.id} ref={el => { tabButtonRefs.current[t.id] = el }} onClick={() => setActiveTab(t.id)} style={{
<button key={tb.id} ref={el => { tabButtonRefs.current[tb.id] = el }} onClick={() => setActiveTab(tb.id)} style={{
padding: '12px 6px',
background: 'none', border: 'none',
borderBottom: `2px solid ${active ? '#f59e0b' : isAlert ? '#f87171' : 'transparent'}`,
@@ -1446,8 +1464,8 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
transition: isAlert ? 'none' : 'color 120ms ease, border-color 120ms ease',
animation: isAlert ? 'tab-alert 1.2s ease-in-out infinite' : 'none',
}}>
{TAB_ICON[t.id] && <span style={{ display: 'inline-flex', alignItems: 'center', opacity: active || isAlert ? 1 : 0.7 }}>{TAB_ICON[t.id]}</span>}
{t.label}
{TAB_ICON[tb.id] && <span style={{ display: 'inline-flex', alignItems: 'center', opacity: active || isAlert ? 1 : 0.7 }}>{TAB_ICON[tb.id]}</span>}
{tb.label}
{badge > 0 && !isAlert && (
<span style={{
minWidth: 18, height: 18, padding: '0 5px',
@@ -1486,12 +1504,12 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
{activeTab === 'prefs' && <PrefsTab product={product} prefs={prefs} setPrefs={setPrefs} subChoices={subChoices} setSubChoices={setSubChoices} sharedSubs={sharedSubs} setSharedSubs={setSharedSubs} />}
{activeTab === 'quantity' && isDecimal && <QuantityTab unitCfg={unitCfg} qty={qty} setQty={setQty} />}
{activeTab === 'courses' && courses?.length > 0 && <CoursesTab courses={courses} courseId={courseId} setCourseId={setCourseId} />}
{activeTab === 'notes' && <NotesTab note={note} setNote={setNote} quickNotes={quickNotes ?? FALLBACK_QUICK_NOTES} />}
{activeTab === 'notes' && <NotesTab note={note} setNote={setNote} quickNotes={quickNotes ?? undefined} />}
{activeTab === 'price_adjust' && <PriceAdjustTab basePrice={product.base_price} priceAdj={priceAdj} setPriceAdj={setPriceAdj} />}
{activeTab === 'summary' && <SummaryTab product={product} summaryLines={summaryLines} note={note} onJumpTab={setActiveTab} />}
</div>
{/* Footer: qty stepper + ΠΡΟΣΘΗΚΗ */}
{/* Footer: qty stepper + ADD */}
<div style={{ padding: '12px 16px 20px', background: 'var(--bg2)', borderTop: '1px solid var(--border)', display: 'flex', alignItems: 'center', gap: 12, flexShrink: 0, boxShadow: '0 -4px 16px rgba(0,0,0,0.3)' }}>
{isDecimal ? (
<div
@@ -1519,7 +1537,7 @@ export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialSt
transition: 'background 150ms ease',
}}>
<span>ADD</span>
<span style={{ fontVariantNumeric: 'tabular-nums' }}>{totalPrice.toFixed(2)} €</span>
<span style={{ fontVariantNumeric: 'tabular-nums' }}>{money(totalPrice)}</span>
</button>
</div>
</div>
+34 -27
View File
@@ -1,9 +1,9 @@
import { useRef, useState } from 'react'
import useTableViewStore from '../store/tableViewStore'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
function fmtPrice(v) {
return Number(v).toFixed(2) + ' €'
}
const fmtPrice = money
const UNIT_LABELS = { kg: 'kg', liter: 'L', gram: 'g', ml: 'mL' }
function fmtQty(qty, unitType) {
@@ -112,15 +112,16 @@ function buildSections(item) {
// ── KDS colour strip ──────────────────────────────────────────────────────────
const KDS_COLORS = {
pending: { textColor: '#f59e0b', label: 'ΕΚΚΡΕΜΕΙ', icon: '⏳', dot: '#f59e0b' },
preparing: { textColor: '#60a5fa', label: 'ΕΤΟΙΜΑΖΕΤΑΙ', icon: '🔥', dot: '#60a5fa' },
done: { textColor: '#4ade80', label: 'READY', icon: '✓', dot: '#4ade80' },
pending: { textColor: '#f59e0b', label: 'kds.pending', icon: '⏳', dot: '#f59e0b' },
preparing: { textColor: '#60a5fa', label: 'kds.preparing', icon: '🔥', dot: '#60a5fa' },
done: { textColor: '#4ade80', label: 'kds.ready', icon: '✓', dot: '#4ade80' },
served: { textColor: null, label: null, icon: null, dot: null },
}
// ── Shared expanded details panel ─────────────────────────────────────────────
function OptionsPanel({ sections }) {
const { t } = useTranslation('waiter')
return (
<div style={{ paddingBottom: 8 }}>
{sections.map((sec, si) => (
@@ -160,7 +161,7 @@ function OptionsPanel({ sections }) {
{sec.type === 'removed' && sec.lines.map((line, li) => (
<div key={li} style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
<SectionIcon type="removed" />
<span style={{ fontSize: 12, color: 'var(--text)', flex: 1 }}>Χωρίς {line.name}</span>
<span style={{ fontSize: 12, color: 'var(--text)', flex: 1 }}>{t('drawer.without', { name: line.name })}</span>
</div>
))}
{sec.type === 'note' && sec.lines.map((line, li) => (
@@ -179,13 +180,14 @@ function OptionsPanel({ sections }) {
// ── KDS badge/icon renderer ───────────────────────────────────────────────────
function KdsBadge({ kdsColor, kdsDisplayStyle }) {
const { t } = useTranslation('waiter')
if (!kdsColor?.label) return null
if (kdsDisplayStyle === 'icon' && kdsColor.dot) {
return (
<span style={{
width: 8, height: 8, borderRadius: '50%',
background: kdsColor.dot, flexShrink: 0, display: 'inline-block',
}} title={kdsColor.label} />
}} title={t(kdsColor.label)} />
)
}
return (
@@ -195,7 +197,7 @@ function KdsBadge({ kdsColor, kdsDisplayStyle }) {
borderRadius: 3, padding: '1px 5px',
border: `1px solid ${kdsColor.textColor}60`,
flexShrink: 0,
}}>{kdsColor.label}</span>
}}>{t(kdsColor.label)}</span>
)
}
@@ -203,12 +205,13 @@ function KdsBadge({ kdsColor, kdsDisplayStyle }) {
const PRICING_EVENT_STYLE = {
modifier_applied: { color: '#60a5fa', label: null }, // label comes from modifier_name
waiter_discount: { color: '#c084fc', label: 'Έκπτωση' },
free_item_added: { color: '#4ade80', label: 'Δωρεάν' },
waiter_discount: { color: '#c084fc', label: 'summary.discount' },
free_item_added: { color: '#4ade80', label: 'summary.free' },
deal_offer_accepted: { color: '#4ade80', label: null }, // label from deal_name
}
function PricingRows({ events, _layout, nameIndent = 12 }) {
const { t } = useTranslation('waiter')
const rows = events.filter(ev =>
ev.event_type === 'modifier_applied' ||
ev.event_type === 'waiter_discount' ||
@@ -223,7 +226,7 @@ function PricingRows({ events, _layout, nameIndent = 12 }) {
<div style={{ padding: `4px 12px 4px ${nameIndent}px`, display: 'flex', flexDirection: 'column', gap: 3 }}>
{rows.map((ev, i) => {
const evStyle = PRICING_EVENT_STYLE[ev.event_type] || { color: '#94a3b8', label: ev.event_type }
const label = ev.modifier_name || ev.deal_name || evStyle.label || ev.event_type
const label = ev.modifier_name || ev.deal_name || (evStyle.label && t(evStyle.label)) || ev.event_type
const delta = ev.delta_amount
return (
@@ -238,7 +241,7 @@ function PricingRows({ events, _layout, nameIndent = 12 }) {
</span>
{delta != null && (
<span style={{ fontSize: 12, color: evStyle.color, fontWeight: 700, flexShrink: 0, marginLeft: 8 }}>
{delta > 0 ? '+' : ''}{delta.toFixed(2)} €
{delta > 0 ? '+' : ''}{money(delta)}
</span>
)}
</div>
@@ -251,6 +254,7 @@ function PricingRows({ events, _layout, nameIndent = 12 }) {
// Small badge shown on the main item row to hint that pricing changes exist
function PricingBadge({ events }) {
const { t } = useTranslation('waiter')
if (!events || events.length === 0) return null
const hasDiscount = events.some(ev => ev.event_type === 'waiter_discount')
const hasModifier = events.some(ev => ev.event_type === 'modifier_applied')
@@ -258,19 +262,19 @@ function PricingBadge({ events }) {
const icons = []
if (hasModifier) icons.push(
<svg key="mod" width="10" height="10" viewBox="0 0 24 24" fill="none" title="Τροποποιητής">
<svg key="mod" width="10" height="10" viewBox="0 0 24 24" fill="none" title={t('summary.modifier')}>
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" stroke="#60a5fa" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)
if (hasDiscount) icons.push(
<svg key="disc" width="10" height="10" viewBox="0 0 24 24" fill="none" title="Έκπτωση">
<svg key="disc" width="10" height="10" viewBox="0 0 24 24" fill="none" title={t('summary.discount')}>
<circle cx="9" cy="9" r="2" stroke="#c084fc" strokeWidth="2"/>
<circle cx="15" cy="15" r="2" stroke="#c084fc" strokeWidth="2"/>
<path d="M5 19L19 5" stroke="#c084fc" strokeWidth="2" strokeLinecap="round"/>
</svg>
)
if (hasFree) icons.push(
<svg key="free" width="10" height="10" viewBox="0 0 24 24" fill="none" title="Δωρεάν">
<svg key="free" width="10" height="10" viewBox="0 0 24 24" fill="none" title={t('summary.free')}>
<path d="M20 12v10H4V12M22 7H2v5h20V7z" stroke="#4ade80" strokeWidth="2" strokeLinecap="round"/>
</svg>
)
@@ -285,6 +289,7 @@ function PricingBadge({ events }) {
// Deal badge on items that triggered or were added by a deal
function DealBadge({ item }) {
const { t } = useTranslation('waiter')
if (item.deal_id) {
return (
<span style={{
@@ -292,7 +297,7 @@ function DealBadge({ item }) {
background: 'rgba(167,139,250,0.15)', color: '#a78bfa',
border: '1px solid rgba(167,139,250,0.4)', flexShrink: 0, letterSpacing: 0.3,
}}>
ΔΩΡΕΑΝ
{t('summary.freeCaps')}
</span>
)
}
@@ -315,6 +320,7 @@ function MergedBadge({ item }) {
// ── ItemRow ───────────────────────────────────────────────────────────────────
function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kdsDisplayStyle, orderItemLayout, waiterMap, courses, priceEvents }) {
const { t } = useTranslation('waiter')
const isPaid = item.status === 'paid'
const isCancelled = item.status === 'cancelled'
const effectiveKds = item.kds_status || 'pending'
@@ -390,10 +396,10 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
</span>
)
const paidBadge = isPaid && !isServed ? <span className="badge badge--paid">Paid</span> : null
const cancelledBadge = isCancelled ? <span className="badge badge--cancelled">Cancelled</span> : null
const paidBadge = isPaid && !isServed ? <span className="badge badge--paid">{t('summary.paidBadge')}</span> : null
const cancelledBadge = isCancelled ? <span className="badge badge--cancelled">{t('summary.cancelledBadge')}</span> : null
const draftBadge = !isPaid && !isCancelled && !item.printed
? <span className="badge badge--draft" title="Δεν εκτυπώθηκε ακόμα">⏳</span>
? <span className="badge badge--draft" title={t('summary.notPrinted')}>⏳</span>
: null
// Whole-card click+touch handlers on the outer wrapper
@@ -592,7 +598,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
{/* Ordered by */}
<div style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ fontSize: 11, color: 'var(--muted)', minWidth: 90 }}>Παραγγέλθηκε</span>
<span style={{ fontSize: 11, color: 'var(--muted)', minWidth: 90 }}>{t('summary.ordered')}</span>
<span style={{ flex: 1 }} />
<span style={{ fontSize: 11, color: 'var(--muted)', textAlign: 'right' }}>
{addedByName && addedAtFmt ? `${addedByName} · ${addedAtFmt}` : addedByName || addedAtFmt || '—'}
@@ -602,7 +608,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
{/* Paid by — only if paid */}
{isPaid && (
<div style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ fontSize: 11, color: 'var(--muted)', minWidth: 90 }}>Πληρώθηκε</span>
<span style={{ fontSize: 11, color: 'var(--muted)', minWidth: 90 }}>{t('summary.paidAt')}</span>
<span style={{ flex: 1 }} />
<span style={{ fontSize: 11, color: 'var(--muted)', textAlign: 'right' }}>
{paidByName && paidAtFmt ? `${paidByName} · ${paidAtFmt}` : paidByName || paidAtFmt || '—'}
@@ -646,7 +652,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
{sec.type === 'removed' && sec.lines.map((line, li) => (
<div key={li} style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<SectionIcon type="removed" />
<span style={{ fontSize: 11, color: 'var(--text)', flex: 1 }}>Χωρίς {line.name}</span>
<span style={{ fontSize: 11, color: 'var(--text)', flex: 1 }}>{t('drawer.without', { name: line.name })}</span>
</div>
))}
{sec.type === 'note' && sec.lines.map((line, li) => (
@@ -665,6 +671,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
}
export default function OrderSummary({ order, selectable = false, selectedIds = [], onToggle, onLongPressItem, waiterMap, courses = [], priceEventsMap = {} }) {
const { t } = useTranslation('waiter')
const kdsDisplayStyle = useTableViewStore(s => s.kdsDisplayStyle || 'badge')
const orderItemLayout = useTableViewStore(s => s.orderItemLayout || 'compact')
const activeItems = order.items?.filter(i => i.status !== 'cancelled') || []
@@ -677,7 +684,7 @@ export default function OrderSummary({ order, selectable = false, selectedIds =
return (
<div className="order-summary">
{activeItems.length === 0 && <p style={{ color: '#64748b', textAlign: 'center' }}>Δεν υπάρχουν αντικείμενα</p>}
{activeItems.length === 0 && <p style={{ color: '#64748b', textAlign: 'center' }}>{t('summary.noItems')}</p>}
{activeItems.map((item, idx) => (
<ItemRow
key={item.id}
@@ -695,18 +702,18 @@ export default function OrderSummary({ order, selectable = false, selectedIds =
/>
))}
<div className="order-summary__total">
<span>Σύνολο</span>
<span>{t('common.total')}</span>
<span>{fmtPrice(total)}</span>
</div>
{paidTotal > 0 && paidTotal < total && (
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 12px 8px', fontSize: 13, color: '#64748b' }}>
<span>Πληρωμένο</span>
<span>{t('tables.quick.paid')}</span>
<span style={{ color: '#22c55e' }}>{fmtPrice(paidTotal)}</span>
</div>
)}
{paidTotal > 0 && paidTotal < total && (
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 12px 8px', fontSize: 13, color: '#94a3b8' }}>
<span>Εκκρεμεί</span>
<span>{t('summary.due')}</span>
<span style={{ color: '#f59e0b', fontWeight: 700 }}>{fmtPrice(total - paidTotal)}</span>
</div>
)}
+15 -11
View File
@@ -1,4 +1,6 @@
import { useState } from 'react'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
const _UNIT_LABELS = { kg: 'kg', liter: 'L', gram: 'g', ml: 'mL' }
function fmtQty(qty, unitType) {
@@ -7,7 +9,7 @@ function fmtQty(qty, unitType) {
if (unitType === 'kg' || unitType === 'liter') return `${Number(qty).toFixed(1)}${label}`
return `${qty}${label}`
}
function fmtEUR(v) { return Number(v || 0).toFixed(2) + ' €' }
const fmtEUR = money
// Flatten selected_options into readable lines
function describeOptions(selected_options) {
@@ -15,13 +17,14 @@ function describeOptions(selected_options) {
return selected_options.map(o => {
let s = o.name || ''
if (o.price_delta && Math.abs(o.price_delta) > 0.001) {
s += ` (${o.price_delta > 0 ? '+' : ''}${o.price_delta.toFixed(2)} €)`
s += ` (${o.price_delta > 0 ? '+' : ''}${money(o.price_delta)})`
}
return s
}).filter(Boolean)
}
function CartItemSummaryRow({ item, product, price, estimated, onEdit }) {
const { t } = useTranslation('waiter')
const opts = describeOptions(item.selected_options)
const removed = item.removed_ingredients || []
@@ -63,7 +66,7 @@ function CartItemSummaryRow({ item, product, price, estimated, onEdit }) {
onClick={onEdit}
style={{ background: 'var(--bg3)', border: '1px solid var(--border)', borderRadius: 7, padding: '3px 10px', fontSize: 12, color: 'var(--muted)', cursor: 'pointer', fontWeight: 600 }}
>
Επεξεργασία
{t('summaryModal.edit')}
</button>
)}
</div>
@@ -75,6 +78,7 @@ function CartItemSummaryRow({ item, product, price, estimated, onEdit }) {
// prices / total: the server's (POST /api/orders/quote, plan step 4.4) or, offline, the menu's
// estimate (`estimated`); priceError: a line the server would refuse.
export default function OrderSummaryModal({ cart, products, prices, total, estimated, priceError, orderNote, setOrderNote, onSend, onClose, sending }) {
const { t } = useTranslation('waiter')
const [noteEditing, setNoteEditing] = useState(false)
function getProduct(id) { return products.find(p => p.id === id) }
@@ -101,8 +105,8 @@ export default function OrderSummaryModal({ cart, products, prices, total, estim
padding: '14px 16px', borderBottom: '1px solid var(--border)', flexShrink: 0,
}}>
<div>
<div style={{ fontSize: 17, fontWeight: 800, color: 'var(--text)' }}>Επισκόπηση Παραγγελίας</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 1 }}>{cart.length} {cart.length === 1 ? 'προϊόν' : 'προϊόντα'} · {estimated ? '≈ ' : ''}{fmtEUR(total)}</div>
<div style={{ fontSize: 17, fontWeight: 800, color: 'var(--text)' }}>{t('summaryModal.title')}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 1 }}>{t('add.products', { count: cart.length })} · {estimated ? '≈ ' : ''}{fmtEUR(total)}</div>
</div>
<button
onClick={onClose}
@@ -129,7 +133,7 @@ export default function OrderSummaryModal({ cart, products, prices, total, estim
{/* Order note section */}
<div style={{ marginTop: 16, marginBottom: 8 }}>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.7, marginBottom: 8 }}>
Σημείωση Παραγγελίας
{t('add.note.title')}
</div>
{noteEditing ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
@@ -137,7 +141,7 @@ export default function OrderSummaryModal({ cart, products, prices, total, estim
autoFocus
value={orderNote}
onChange={e => setOrderNote(e.target.value)}
placeholder="Σημείωση για ολόκληρη την παραγγελία…"
placeholder={t('add.note.placeholder')}
rows={3}
style={{
width: '100%', resize: 'none', padding: '10px 12px',
@@ -150,7 +154,7 @@ export default function OrderSummaryModal({ cart, products, prices, total, estim
onClick={() => setNoteEditing(false)}
style={{ alignSelf: 'flex-end', background: 'none', border: 'none', fontSize: 12, fontWeight: 700, color: 'var(--accent)', cursor: 'pointer' }}
>
Αποθήκευση
{t('common.save')}
</button>
</div>
) : orderNote ? (
@@ -172,14 +176,14 @@ export default function OrderSummaryModal({ cart, products, prices, total, estim
}}
>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>
Προσθήκη σημείωσης παραγγελίας
{t('add.note.add')}
</button>
)}
</div>
{/* Total */}
<div style={{ marginTop: 12, marginBottom: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 4px', borderTop: '1px solid var(--border)' }}>
<span style={{ fontSize: 14, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6 }}>{estimated ? 'Σύνολο (εκτίμηση)' : 'Σύνολο'}</span>
<span style={{ fontSize: 14, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6 }}>{estimated ? t('add.totalEstimate') : t('common.total')}</span>
<span data-testid="summary-total" data-estimated={estimated ? 'true' : 'false'} style={{ fontSize: 20, fontWeight: 800, color: 'var(--text)', fontVariantNumeric: 'tabular-nums' }}>{estimated ? '≈ ' : ''}{fmtEUR(total)}</span>
</div>
{priceError && <div style={{ fontSize: 12, color: 'var(--danger)', padding: '0 4px 8px' }}>{priceError}</div>}
@@ -193,7 +197,7 @@ export default function OrderSummaryModal({ cart, products, prices, total, estim
onClick={onSend}
disabled={sending}
>
{sending ? 'Αποστολή…' : `ΑΠΟΣΤΟΛΗ (${cart.length})`}
{sending ? t('add.sending') : t('add.sendCount', { count: cart.length })}
</button>
</div>
+22 -17
View File
@@ -3,6 +3,8 @@ import { useNavigate } from 'react-router-dom'
import OrderDrawer from './OrderDrawer'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { assetUrl } from '../config/server'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
const FAV_CAT_ID = '__favorites__'
const SVC_CAT_ID = '__service__'
@@ -132,7 +134,7 @@ function ProductDetailModal({ product, onClose }) {
{product.name}
</div>
<div style={{ fontSize: 18, fontWeight: 700, color: 'var(--accent, #f59e0b)', marginBottom: product.description ? 14 : 0 }}>
{Number(product.base_price).toFixed(2)} €
{money(product.base_price)}
</div>
{product.description && (
<div style={{
@@ -215,7 +217,7 @@ function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
))}
</div>
)}
<span className="product-btn__price">{Number(product.base_price).toFixed(2)} €</span>
<span className="product-btn__price">{money(product.base_price)}</span>
</div>
{canQuickAdd && (
@@ -249,6 +251,7 @@ function ProductCard({ product, onOpen, onQuickAdd, onShowDetail }) {
// ── Service Item Card ─────────────────────────────────────────────────────────
function ServiceItemCard({ product, customerCount, onAdd }) {
const { t } = useTranslation('waiter')
const [qty, setQty] = useState(0)
function dec() { setQty(q => Math.max(0, q - 1)) }
@@ -279,7 +282,7 @@ function ServiceItemCard({ product, customerCount, onAdd }) {
{product.name}
</span>
<span style={{ fontSize: 13, fontWeight: 600, color: hasPrice ? '#f59e0b' : 'var(--muted)', flexShrink: 0 }}>
{hasPrice ? `${Number(product.base_price).toFixed(2)} €` : 'no charge'}
{hasPrice ? money(product.base_price) : t('picker.noCharge')}
</span>
</div>
@@ -300,7 +303,7 @@ function ServiceItemCard({ product, customerCount, onAdd }) {
<button
onPointerDown={e => e.stopPropagation()}
onClick={setToCustomerCount}
title={`Ορισμός σε ${customerCount ?? 1} άτομα`}
title={t('picker.setToGuests', { count: customerCount ?? 1 })}
style={{
...btnBase,
background: 'rgba(245,158,11,0.12)',
@@ -369,11 +372,12 @@ function ServiceItemCard({ product, customerCount, onAdd }) {
}
function ServiceItemView({ products, customerCount, onAdd }) {
const { t } = useTranslation('waiter')
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, padding: '12px 14px' }}>
{products.length === 0 ? (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: 32 }}>
Δεν υπάρχουν service αντικείμενα
{t('picker.noService')}
</p>
) : products.map(p => (
<ServiceItemCard
@@ -422,6 +426,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 navigate = useNavigate()
const favorites = useWaiterFavoritesStore(s => s.favorites)
@@ -541,7 +546,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round">
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
</svg>
Αγαπημένα
{t('settings.tabs.favorites')}
</button>
)}
{topLevel.map(cat => {
@@ -591,7 +596,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
</svg>
<p style={{ color: 'var(--muted)', fontSize: 14, textAlign: 'center', lineHeight: 1.6 }}>
Δεν έχεις αγαπημένα ακόμα.
{t('picker.noFavorites')}
</p>
<button
onClick={() => navigate('/settings/favorites')}
@@ -601,7 +606,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
border: 'none', fontSize: 14, fontWeight: 700, cursor: 'pointer',
}}
>
Ρύθμιση Αγαπημένων
{t('settings.fav.setup')}
</button>
</div>
)
@@ -616,7 +621,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
/>
{flatProducts.length === 0 && (
<p style={{ color: '#64748b', textAlign: 'center', padding: 32 }}>
Δεν υπάρχουν προϊόντα
{t('picker.noProducts')}
</p>
)}
</>
@@ -682,7 +687,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
)}
</div>
{/* View All modal — Κατηγορίες + Tags tabs */}
{/* View All modal — categories + tags tabs */}
{viewAllOpen && (
<div className="modal-overlay" onClick={() => setViewAllOpen(false)}>
<div
@@ -691,7 +696,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
style={{ display: 'flex', flexDirection: 'column' }}
>
<div className="cat-all-modal__header">
<span className="cat-all-modal__title">{modalTab === 'categories' ? 'Κατηγορίες' : 'Tags'}</span>
<span className="cat-all-modal__title">{modalTab === 'categories' ? t('picker.categories') : t('picker.tags')}</span>
<button className="icon-btn" onClick={() => setViewAllOpen(false)}>✕</button>
</div>
@@ -711,7 +716,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
transition: 'color 0.12s',
}}
>
{tab === 'categories' ? 'Κατηγορίες' : 'Tags'}
{tab === 'categories' ? t('picker.categories') : t('picker.tags')}
</button>
))}
</div>
@@ -729,7 +734,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
<svg width="13" height="13" viewBox="0 0 24 24" fill="white" stroke="white" strokeWidth="1" style={{ flexShrink: 0 }}>
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
</svg>
Αγαπημένα
{t('settings.tabs.favorites')}
</span>
</button>
)}
@@ -757,7 +762,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 || 'Χωρίς Κατηγορία'
const key = cat?.name || t('picker.noCategory')
if (!acc[key]) acc[key] = []
acc[key].push(p)
return acc
@@ -767,7 +772,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
<div style={{ flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column' }}>
{allTags.length === 0 && (
<div style={{ padding: '32px 16px', textAlign: 'center', color: 'var(--muted)', fontSize: 14 }}>
Δεν υπάρχουν tags ακόμα.
{t('picker.noTags')}
</div>
)}
{allTags.length > 0 && (
@@ -791,7 +796,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
)}
{activeTag && taggedProducts.length === 0 && (
<div style={{ padding: '24px 16px', textAlign: 'center', color: 'var(--muted)', fontSize: 14 }}>
Κανένα προϊόν με αυτό το tag.
{t('picker.noTagged')}
</div>
)}
{activeTag && Object.entries(byCategory).map(([catName, prods]) => (
@@ -811,7 +816,7 @@ export default function ProductPicker({ categories, products, onAdd, onQuickAdd:
}}
>
<span style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{p.name}</span>
<span style={{ fontSize: 13, color: 'var(--muted)' }}>€{Number(p.base_price).toFixed(2)}</span>
<span style={{ fontSize: 13, color: 'var(--muted)' }}>{money(p.base_price)}</span>
</button>
))}
</div>