feat(waiter): English-first texts, part a: shell, sign-in, tables, settings, venues (platform-v2 step 4.5a)
- @xenia/i18n: new `waiter` namespace (en + el); the waiter's Greek texts become keys with English written fresh (Greek kept as the translation). - App gates, side drawer / nav bars / notifications, user menu, login, table list and cards, settings, venues + pairing errors, install dialog, lock screen, update banners, QR scanner, favourites setup. - Money and times through useFormat() (venue time, the language's number format): table cards, quick table view, user menu, notifications. - waiter i18n.js: tw() for code outside components (pairing errors). - The table-list's FavoritesSetupPage `.map(t => …)` renamed so it doesn't shadow t. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'
|
||||
import { useProductCache } from '../hooks/useProductCache'
|
||||
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
|
||||
import { assetUrl } from '../config/server'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
|
||||
// ── Heart icon ────────────────────────────────────────────────────────────────
|
||||
function Heart({ filled, size = 22 }) {
|
||||
@@ -87,6 +88,7 @@ function AttrSection({ title, items, favIds, onToggle }) {
|
||||
}
|
||||
|
||||
function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
// Local state: { quick: id[], ingredients: id[], options: id[], prefs: id[] }
|
||||
// Start from waiter overrides if they exist, otherwise seed from manager's is_favorite flags
|
||||
function seedFromManager() {
|
||||
@@ -164,7 +166,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
{product.name}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)' }}>
|
||||
{waiterAttrFavs ? 'Προσωπικές ρυθμίσεις ενεργές' : 'Χρήση ρυθμίσεων διαχειριστή'}
|
||||
{waiterAttrFavs ? t('favSetup.personalOn') : t('favSetup.managerDefaults')}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@@ -179,22 +181,22 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
<div style={{ flex: 1, overflowY: 'auto', padding: '16px 16px 0' }}>
|
||||
{!hasAnything ? (
|
||||
<p style={{ color: 'var(--muted)', fontSize: 14, textAlign: 'center', padding: '32px 0' }}>
|
||||
Αυτό το προϊόν δεν έχει επιλογές, υλικά ή προτιμήσεις.
|
||||
{t('favSetup.noOptions')}
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<p style={{ fontSize: 13, color: 'var(--muted)', marginBottom: 16, lineHeight: 1.5 }}>
|
||||
Επίλεξε ποιες επιλογές θα εμφανίζονται στην καρτέλα <strong style={{ color: '#ef4444' }}>♥ Αγαπημένα</strong> για αυτό το προϊόν. Αν δεν επιλέξεις τίποτα, θα χρησιμοποιηθούν οι ρυθμίσεις του διαχειριστή.
|
||||
{t('favSetup.pickIntro')} <strong style={{ color: '#ef4444' }}>♥ {t('settings.tabs.favorites')}</strong>. {t('favSetup.pickOutro')}
|
||||
</p>
|
||||
|
||||
<AttrSection
|
||||
title="Γρήγορες Επιλογές"
|
||||
title={t('drawer.tabs.quick')}
|
||||
items={product.quick_options}
|
||||
favIds={local.quick || []}
|
||||
onToggle={id => toggle('quick', id)}
|
||||
/>
|
||||
<AttrSection
|
||||
title="Υλικά"
|
||||
title={t('drawer.tabs.ingredients')}
|
||||
items={product.ingredients}
|
||||
favIds={local.ingredients || []}
|
||||
onToggle={id => toggle('ingredients', id)}
|
||||
@@ -206,7 +208,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
onToggle={id => toggle('options', id)}
|
||||
/>
|
||||
<AttrSection
|
||||
title="Προτιμήσεις"
|
||||
title={t('drawer.tabs.prefs')}
|
||||
items={product.preference_sets}
|
||||
favIds={local.prefs || []}
|
||||
onToggle={id => toggle('prefs', id)}
|
||||
@@ -231,7 +233,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
fontSize: 13, fontWeight: 600, cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
Επαναφορά
|
||||
{t('settings.reset.title')}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
@@ -243,7 +245,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
fontSize: 15, fontWeight: 700, cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
{totalSelected > 0 ? `Αποθήκευση (${totalSelected} επιλογές)` : 'Αποθήκευση'}
|
||||
{totalSelected > 0 ? t('favSetup.saveCount', { count: totalSelected }) : t('common.save')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -253,6 +255,8 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
|
||||
|
||||
// ── Product row (ALL tab) ─────────────────────────────────────────────────────
|
||||
function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const { formatMoney } = useFormat()
|
||||
const hasAttrs = (
|
||||
(product.quick_options || []).length > 0 ||
|
||||
(product.ingredients || []).length > 0 ||
|
||||
@@ -281,7 +285,7 @@ function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs
|
||||
)}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: hasAttrs ? 'var(--accent)' : 'var(--muted)' }}>
|
||||
{hasAttrs ? 'Επιλογές αγαπημένων →' : `${Number(product.base_price).toFixed(2)} €`}
|
||||
{hasAttrs ? `${t('favSetup.options')} →` : formatMoney(Number(product.base_price))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -298,6 +302,7 @@ function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs
|
||||
|
||||
// ── Draggable favorites list (pointer-events — works on touch + mouse) ─────────
|
||||
function FavoritesList({ items, products, onReorder }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const [dragging, setDragging] = useState(null)
|
||||
const [dropIndex, setDropIndex] = useState(null)
|
||||
const containerRef = useRef(null)
|
||||
@@ -355,7 +360,7 @@ function FavoritesList({ items, products, onReorder }) {
|
||||
<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={{ fontSize: 14, color: 'var(--muted)', textAlign: 'center', lineHeight: 1.6 }}>
|
||||
Δεν έχεις προσθέσει αγαπημένα ακόμα.<br />Πήγαινε στην καρτέλα ΌΛΑ και πάτα την καρδιά δίπλα στα προϊόντα.
|
||||
{t('favSetup.none')}<br />{t('favSetup.noneHow')}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
@@ -417,6 +422,7 @@ function FavoritesList({ items, products, onReorder }) {
|
||||
|
||||
// ── Main page ─────────────────────────────────────────────────────────────────
|
||||
export default function FavoritesSetupPage() {
|
||||
const { t } = useTranslation('waiter')
|
||||
const navigate = useNavigate()
|
||||
const { products, categories } = useProductCache()
|
||||
const { favorites, toggleFavorite, reorderFavorites, itemFavorites, setItemFavorites } = useWaiterFavoritesStore()
|
||||
@@ -430,19 +436,19 @@ export default function FavoritesSetupPage() {
|
||||
{/* Header */}
|
||||
<header className="top-bar">
|
||||
<button className="icon-btn" onClick={() => navigate(-1)}>←</button>
|
||||
<span className="top-bar__title">Ρύθμιση Αγαπημένων</span>
|
||||
<span className="top-bar__title">{t('settings.fav.setup')}</span>
|
||||
<div style={{ width: 40 }} />
|
||||
</header>
|
||||
|
||||
{/* Tabs */}
|
||||
<div style={{ display: 'flex', borderBottom: '1px solid var(--border)', flexShrink: 0, background: 'var(--bg)' }}>
|
||||
{[
|
||||
{ key: 'all', label: 'ΌΛΑ' },
|
||||
{ key: 'favorites', label: `ΑΓΑΠΗΜΈΝΑ (${favorites.length})` },
|
||||
].map(t => (
|
||||
{ key: 'all', label: t('favSetup.all') },
|
||||
{ key: 'favorites', label: t('favSetup.favorites', { count: favorites.length }) },
|
||||
].map(tb => (
|
||||
<button
|
||||
key={t.key}
|
||||
onClick={() => setTab(t.key)}
|
||||
key={tb.key}
|
||||
onClick={() => setTab(tb.key)}
|
||||
style={{
|
||||
flex: 1, padding: '12px 8px',
|
||||
background: 'none', border: 'none', cursor: 'pointer',
|
||||
|
||||
Reference in New Issue
Block a user