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,6 +1,7 @@
|
||||
import db from '../db/posdb'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
import { tw } from '../i18n'
|
||||
|
||||
// Orders taken offline (plan step 4.4): the cart lines are queued by id (`_wire`, built when
|
||||
// the order was taken: @xenia/api wireLine) and priced by the server when they reach it; the
|
||||
@@ -248,7 +249,7 @@ async function _flushLegacyOfflineOrders() {
|
||||
}
|
||||
// True legacy record (before v0.6.4): it can't be priced by the server (no lines by id)
|
||||
if (!entry.items.some(i => i._wire)) {
|
||||
await keepRefused(entry.items.map(i => refusedEntry(i, entry.tableId, entry.uuid, OLD_FORMAT)))
|
||||
await keepRefused(entry.items.map(i => refusedEntry(i, entry.tableId, entry.uuid, OLD_FORMAT())))
|
||||
await db.offline_orders.update(entry.localId, { synced: 1 })
|
||||
await db.pos_orders.delete(`offline_${entry.uuid}`)
|
||||
continue
|
||||
@@ -296,7 +297,7 @@ async function _flushCreateOrder(op, idMap) {
|
||||
const synthetic = await db.pos_orders.get(op.localOrderId)
|
||||
// queued before 4.4: nothing the server can price → all refused, no empty order opened
|
||||
if (!op.items.some(i => i._wire)) {
|
||||
await keepRefused(op.items.map(i => refusedEntry(i, op.tableId, op.uuid, OLD_FORMAT)))
|
||||
await keepRefused(op.items.map(i => refusedEntry(i, op.tableId, op.uuid, OLD_FORMAT())))
|
||||
for (const it of synthetic?.items ?? []) idMap[it.id] = REFUSED
|
||||
await db.offline_orders.where('uuid').equals(op.uuid).modify({ synced: 1 })
|
||||
await db.offline_ops.update(op.localId, { synced: 1 })
|
||||
@@ -412,7 +413,7 @@ async function _flushPay(op, idMap) {
|
||||
|
||||
const REFUSED_KEY = 'refused_lines'
|
||||
const REFUSED = 'refused'
|
||||
const OLD_FORMAT = 'Παλιά μορφή παραγγελίας: προσθέστε το ξανά'
|
||||
const OLD_FORMAT = () => tw('refused.oldFormat')
|
||||
|
||||
/** Lines the server refused when an offline order was sent: [{ at, tableId, product, quantity, reason }]. */
|
||||
export async function refusedLines() {
|
||||
@@ -449,7 +450,7 @@ async function postLines(pending, refused, ctx, post) {
|
||||
const n = refusedLine(err, pending.length)
|
||||
if (n == null) throw err
|
||||
const [{ item }] = pending.splice(n - 1, 1)
|
||||
refused.push(refusedEntry(item, ctx.tableId, ctx.uuid, apiError(err, 'Ο server δεν το δέχτηκε')))
|
||||
refused.push(refusedEntry(item, ctx.tableId, ctx.uuid, apiError(err, tw('refused.notAccepted'))))
|
||||
}
|
||||
}
|
||||
return pending
|
||||
@@ -463,7 +464,7 @@ async function postLines(pending, refused, ctx, post) {
|
||||
* refusals are found again next time). Returns { orderId (null: all refused), sent: [indexes] }.
|
||||
*/
|
||||
async function sendLines(items, ctx, getOrderId) {
|
||||
const refused = items.filter(item => !item._wire).map(item => refusedEntry(item, ctx.tableId, ctx.uuid, OLD_FORMAT))
|
||||
const refused = items.filter(item => !item._wire).map(item => refusedEntry(item, ctx.tableId, ctx.uuid, OLD_FORMAT()))
|
||||
const opts = { noOverride: true }
|
||||
let pending = items.map((item, index) => ({ item, index })).filter(({ item }) => item._wire)
|
||||
pending = await postLines(pending, refused, ctx, lines => client.post('/api/orders/quote', { lines }, opts))
|
||||
|
||||
Reference in New Issue
Block a user