feat(waiter): English-first texts, part c: shift, log, chat, offline, notifications; language switch; guard (platform-v2 step 4.5c)
- Shift overview, order log, chat list / thread, offline + server search + rediscovery screens, notifications, the refused-lines sheet and the offline queue's reasons become keys; times and dates through useFormat() in the venue's clock. - User menu: the other language(s) (data-testid menu-language-<lng>), saved to the person's profile (PATCH /api/auth/me) and the bootstrap reloaded (D-12). - tests/no-greek.test.mjs: no Greek letter in waiter_pwa/src (the one Greek word the app recognises in staff messages is a \u escape). - e2e: the test venue is English: waiter / browser / android use the English texts; waiter.mjs +3 (English by default, switch to Greek at once and saved, after reload); android bundle checks print what they saw when they fail. - Pack README: the waiter texts rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,27 +1,22 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import AppShell from '../components/AppShell'
|
||||
import client from '../api/client'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { money as fmtEuro, tw } from '../i18n'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
|
||||
// ── helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
function fmtTime(iso) {
|
||||
if (!iso) return '—'
|
||||
return new Date(iso).toLocaleTimeString('el-GR', { hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
|
||||
function fmtDuration(seconds) {
|
||||
if (seconds == null || seconds < 0) return '—'
|
||||
const h = Math.floor(seconds / 3600)
|
||||
const m = Math.floor((seconds % 3600) / 60)
|
||||
if (h === 0) return `${m}λ`
|
||||
if (m === 0) return `${h}ω`
|
||||
return `${h}ω ${m}λ`
|
||||
if (h === 0) return tw('common.minutesShort', { m })
|
||||
if (m === 0) return tw('common.hoursShort', { h })
|
||||
return tw('common.hoursMinutesShort', { h, m })
|
||||
}
|
||||
|
||||
function fmtEuro(n) {
|
||||
return '€' + parseFloat(n || 0).toFixed(2)
|
||||
}
|
||||
|
||||
function sinceSeconds(isoStart) {
|
||||
if (!isoStart) return 0
|
||||
@@ -101,6 +96,8 @@ function PerHourChart({ title, data, accent = 'var(--accent)' }) {
|
||||
// ── breaks timeline ───────────────────────────────────────────────────────────
|
||||
|
||||
function BreakRow({ brk, index }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const { formatTime: fmtTime } = useFormat()
|
||||
const dur = breakDurationSeconds(brk)
|
||||
const active = !brk.ended_at
|
||||
return (
|
||||
@@ -118,7 +115,7 @@ function BreakRow({ brk, index }) {
|
||||
}}>{index + 1}</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ fontSize: 13, fontWeight: 600, color: 'var(--text)' }}>
|
||||
{fmtTime(brk.started_at)} – {active ? 'Τώρα' : fmtTime(brk.ended_at)}
|
||||
{fmtTime(brk.started_at)} – {active ? t('shiftPage.now') : fmtTime(brk.ended_at)}
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 1 }}>
|
||||
{fmtDuration(dur)}
|
||||
@@ -128,7 +125,7 @@ function BreakRow({ brk, index }) {
|
||||
<span style={{
|
||||
fontSize: 10, fontWeight: 700, padding: '3px 8px', borderRadius: 999,
|
||||
background: '#f97316', color: 'white',
|
||||
}}>ΕΝΕΡΓΟ</span>
|
||||
}}>{t('venues.active')}</span>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
@@ -137,6 +134,8 @@ function BreakRow({ brk, index }) {
|
||||
// ── main page ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export default function ShiftOverviewPage() {
|
||||
const { t } = useTranslation('waiter')
|
||||
const { formatTime: fmtTime } = useFormat()
|
||||
const { data: shift, isLoading: shiftLoading } = useQuery({
|
||||
queryKey: ['my-shift'],
|
||||
queryFn: () => client.get('/api/shifts/my').then(r => r.data),
|
||||
@@ -164,7 +163,7 @@ export default function ShiftOverviewPage() {
|
||||
return (
|
||||
<AppShell title="Shift Overview">
|
||||
<div style={{ flex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'var(--muted)', fontSize: 14 }}>
|
||||
Φόρτωση…
|
||||
{t('common.loading')}
|
||||
</div>
|
||||
</AppShell>
|
||||
)
|
||||
@@ -175,8 +174,8 @@ export default function ShiftOverviewPage() {
|
||||
<AppShell title="Shift Overview">
|
||||
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 12, padding: 24, textAlign: 'center' }}>
|
||||
<div style={{ fontSize: 40 }}>⏸</div>
|
||||
<div style={{ fontSize: 16, fontWeight: 700, color: 'var(--text)' }}>Δεν υπάρχει ενεργή βάρδια</div>
|
||||
<div style={{ fontSize: 13, color: 'var(--muted)' }}>Ξεκινήστε βάρδια για να δείτε στατιστικά.</div>
|
||||
<div style={{ fontSize: 16, fontWeight: 700, color: 'var(--text)' }}>{t('shiftPage.none')}</div>
|
||||
<div style={{ fontSize: 13, color: 'var(--muted)' }}>{t('shiftPage.noneSub')}</div>
|
||||
</div>
|
||||
</AppShell>
|
||||
)
|
||||
@@ -219,9 +218,9 @@ export default function ShiftOverviewPage() {
|
||||
}}>
|
||||
<span style={{ fontSize: 20 }}>☕</span>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: '#f97316' }}>Σε διάλειμμα</div>
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: '#f97316' }}>{t('shiftPage.onBreak')}</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 1 }}>
|
||||
από {fmtTime(activeBreak.started_at)} · {fmtDuration(breakDurationSeconds(activeBreak))} μέχρι τώρα
|
||||
{t('shiftPage.breakSince', { time: fmtTime(activeBreak.started_at), duration: fmtDuration(breakDurationSeconds(activeBreak)) })}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -229,18 +228,18 @@ export default function ShiftOverviewPage() {
|
||||
|
||||
{/* Hero stats grid */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 10, marginBottom: 20 }}>
|
||||
<StatCard label="Έναρξη" value={fmtTime(shift.started_at)} />
|
||||
<StatCard label="Ώρες Εργασίας" value={fmtDuration(workedSec)} sub={`${fmtDuration(totalBreakSec)} διαλείμματα`} />
|
||||
<StatCard label="Αρχ. Μετρητά" value={fmtEuro(shift.starting_cash)} />
|
||||
<StatCard label={t('shiftPage.start')} value={fmtTime(shift.started_at)} />
|
||||
<StatCard label={t('shiftPage.worked')} value={fmtDuration(workedSec)} sub={t('shiftPage.breaksSub', { duration: fmtDuration(totalBreakSec) })} />
|
||||
<StatCard label={t('shiftPage.startCash')} value={fmtEuro(shift.starting_cash)} />
|
||||
{!hideRevenue && (
|
||||
<StatCard label="Είσπραξη" value={fmtEuro(shift.total_collected)} accent="var(--success, #22c55e)" />
|
||||
<StatCard label={t('shiftPage.collected')} value={fmtEuro(shift.total_collected)} accent="var(--success, #22c55e)" />
|
||||
)}
|
||||
{!hideRevenue && (
|
||||
<StatCard label="Παραδ. Ποσό" value={fmtEuro(shift.net_to_deliver)} sub="Αρχ. + Είσπραξη" accent="var(--accent)" />
|
||||
<StatCard label={t('shiftPage.toHandIn')} value={fmtEuro(shift.net_to_deliver)} sub={t('shiftPage.toHandInSub')} accent="var(--accent)" />
|
||||
)}
|
||||
<StatCard label="Ανοιχτά Τραπέζια" value={String(openOrders.length)} sub="τρέχουσες παραγγελίες" />
|
||||
<StatCard label="Είδη (ανοιχτά)" value={String(totalItems)} />
|
||||
<StatCard label="Διαλείμματα" value={String((shift.breaks || []).length)} sub={`${fmtDuration(totalBreakSec)} σύνολο`} />
|
||||
<StatCard label={t('shiftPage.openTables')} value={String(openOrders.length)} sub={t('shiftPage.openTablesSub')} />
|
||||
<StatCard label={t('shiftPage.items')} value={String(totalItems)} />
|
||||
<StatCard label={t('shiftPage.breaks')} value={String((shift.breaks || []).length)} sub={t('shiftPage.totalSub', { duration: fmtDuration(totalBreakSec) })} />
|
||||
</div>
|
||||
|
||||
{/* Per-hour charts */}
|
||||
@@ -249,9 +248,9 @@ export default function ShiftOverviewPage() {
|
||||
background: 'var(--bg2)', border: '1px solid var(--border)',
|
||||
borderRadius: 16, padding: '16px 18px', marginBottom: 20,
|
||||
}}>
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)', marginBottom: 16 }}>Ανά Ώρα</div>
|
||||
<PerHourChart title="Παραγγελίες" data={ordersByHour} />
|
||||
<PerHourChart title="Είδη" data={itemsByHour} />
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)', marginBottom: 16 }}>{t('shiftPage.perHour')}</div>
|
||||
<PerHourChart title={t('nav.orders')} data={ordersByHour} />
|
||||
<PerHourChart title={t('shiftPage.itemsShort')} data={itemsByHour} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -259,7 +258,7 @@ export default function ShiftOverviewPage() {
|
||||
{(shift.breaks || []).length > 0 && (
|
||||
<div>
|
||||
<div style={{ fontSize: 12, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.5, marginBottom: 10 }}>
|
||||
Διαλείμματα ({shift.breaks.length})
|
||||
{t('shiftPage.breaksCount', { count: shift.breaks.length })}
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{shift.breaks.map((b, i) => <BreakRow key={b.id} brk={b} index={i} />)}
|
||||
|
||||
Reference in New Issue
Block a user