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:
@@ -2,6 +2,7 @@ import { createContext, useContext, useEffect, useState, useCallback } from 'rea
|
||||
import useAuthStore from '../store/authStore'
|
||||
import useNotificationSettingsStore from '../store/notificationSettingsStore'
|
||||
import client from '../api/client'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
|
||||
const NotificationContext = createContext(null)
|
||||
|
||||
@@ -51,22 +52,26 @@ function isManagerMessage(msg) {
|
||||
|
||||
const HIGHLIGHT = { color: '#7dd3fc', fontWeight: 800 } // light blue bold
|
||||
|
||||
// the word before a table name in staff messages, English or Greek (\u escapes keep the source ASCII)
|
||||
const TABLE_WORDS = 'table|\u03c4\u03c1\u03b1\u03c0\u03ad\u03b6\u03b9'
|
||||
|
||||
function RichBody({ text }) {
|
||||
if (!text) return null
|
||||
// Highlighted tokens:
|
||||
// #digits → order number
|
||||
// τραπέζι <word> → keep "τραπέζι " plain, highlight the word after it
|
||||
// table <word> → keep the word "table" (English or Greek) plain, highlight the word after it
|
||||
// " - " <rest> → keep " - " plain, highlight everything after
|
||||
const parts = []
|
||||
const re = /(#\d+|τραπέζι \S+| - .+$)/g
|
||||
const re = new RegExp(`(#\\d+|(?:${TABLE_WORDS}) \\S+| - .+$)`, 'gi')
|
||||
let last = 0
|
||||
let m
|
||||
while ((m = re.exec(text)) !== null) {
|
||||
if (m.index > last) parts.push({ t: 'plain', v: text.slice(last, m.index) })
|
||||
const v = m[0]
|
||||
if (v.startsWith('τραπέζι ')) {
|
||||
parts.push({ t: 'plain', v: 'τραπέζι ' })
|
||||
parts.push({ t: 'hi', v: v.slice(8) })
|
||||
const word = new RegExp(`^(?:${TABLE_WORDS}) `, 'i').exec(v)
|
||||
if (word) {
|
||||
parts.push({ t: 'plain', v: word[0] })
|
||||
parts.push({ t: 'hi', v: v.slice(word[0].length) })
|
||||
} else if (v.startsWith(' - ')) {
|
||||
parts.push({ t: 'plain', v: ' - ' })
|
||||
parts.push({ t: 'hi', v: v.slice(3) })
|
||||
@@ -91,6 +96,7 @@ function RichBody({ text }) {
|
||||
// ─── Persistent banner (one message at a time, stacked) ─────────────────────
|
||||
|
||||
function NotificationBanner({ message, onAck, autoDismiss }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const tableIds = (() => { try { return JSON.parse(message.table_ids || '[]') } catch { return [] } })()
|
||||
const theme = getTheme(message.message_type)
|
||||
|
||||
@@ -120,7 +126,7 @@ function NotificationBanner({ message, onAck, autoDismiss }) {
|
||||
</div>
|
||||
{tableIds.length > 0 && (
|
||||
<div style={{ fontSize: 12, color: '#94a3b8', marginTop: 4 }}>
|
||||
Τραπέζι{tableIds.length > 1 ? 'α' : ''}: {tableIds.join(', ')}
|
||||
{t('notify.tables', { count: tableIds.length, tables: tableIds.join(', ') })}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -138,6 +144,7 @@ function NotificationBanner({ message, onAck, autoDismiss }) {
|
||||
}
|
||||
|
||||
export function NotificationProvider({ children }) {
|
||||
const { t } = useTranslation('waiter')
|
||||
const { token, user } = useAuthStore()
|
||||
const { popupMode, persistentPopup } = useNotificationSettingsStore()
|
||||
|
||||
@@ -275,7 +282,7 @@ export function NotificationProvider({ children }) {
|
||||
textAlign: 'center', fontSize: 12, color: '#94a3b8',
|
||||
pointerEvents: 'all',
|
||||
}}>
|
||||
+{popupMessages.length - 3} ακόμα μηνύματα
|
||||
{t('notify.more', { count: popupMessages.length - 3 })}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user