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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user