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