feat(manager): design pass 1 — every page on <Page>, shared toolbars, fees under Online orders, QR codes under Tables, day stats reworked

From the owner's page-by-page review (2026-11-20):
- every page root is <Page> (scrolls, fills 1080p, 16:9 centred on
  ultrawides); not yet: products, management/tables, stock (next pass)
- /dashboard: more padding in cards (p-card), quieter secondary text,
  11px uppercase labels everywhere (text-overline)
- day stats: xl dialog, "● Day running · Opened …" as text, the six
  figures in equal boxes, "On tabs" in the payments bar, shared Tabs
- /tables: Segmented List / Map / QR codes (?view=; /online/qr redirects),
  filter chips + zones multi-select at one height, the card itself opens
  the table (button removed), cards ~20% wider
- /online-orders: shared Tabs with Settings (= the old /online/fees page,
  which redirects to ?tab=settings); orders fill the width
- contacts, customers, expenses: PageHeader + Toolbar + SearchInput +
  multi-select Dropdowns (kinds; statuses, categories); table cells
  vertically centred; the Spent tip opens on hover
- filterCards / filterContacts / filterExpenses take several values
  (unit tests added)
- docs/DESIGN.md: the design language (CS-20 in the pack README)
- tests/e2e/manager_layout.mjs: the page rule at 1920x1080 and 3440x1440;
  manager.mjs and manager_look.mjs follow the moved pages

Verified: manager build + lint (0 errors), unit tests (manager 99, ui 24,
i18n 31, api 25, access 8), i18n guard, manager_layout.mjs all passed,
manager.mjs 228 checks all passed. Not checked: the waiter app and the
terminal by eye (they only get the muted ink-2 token).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 11:23:30 +02:00
co-authored by Claude Opus 5.5
parent 26ba19cba5
commit 6f4ab23582
67 changed files with 535 additions and 356 deletions
+77
View File
@@ -0,0 +1,77 @@
# Design language (on-site frontends)
> The rules every screen of the manager (and later the terminal and the waiter app) follows, so the product looks like one thing.
> **Read this before writing or changing any page, dialog or component.** Change a rule here first, then in `packages/ui`, never in one page.
> Started 2026-11-20 from the owner's UI review (modelled on the BellSystems control panel's `DESIGN.md`).
## 1. Principles
- **Global, never local.** Anything that two pages need is a component or a token in `@xenia/ui` (`packages/ui`). If a page needs a new look, add it to `@xenia/ui` and use it from there. Never rebuild a dropdown, a tab strip or a page frame inside a page.
- **Tokens only.** Colours, sizes, radii, paddings and heights come from `packages/ui/src/tokens.css` (Tailwind names from `tailwind-preset.js`). No hex or rgb values in app code (see also CS-16).
- **Same height in a row.** Controls that sit side by side (a search box, dropdowns, chips, buttons) share one height: `md` (44 px, `--x-control-md`) unless the whole row is `sm`.
- **Quiet secondary text.** `text-ink-2` / `text-ink-3` are muted on purpose. Don't make subtitles, hints or labels darker to make them stand out.
## 2. The page rule
Every page's root is `<Page>` from `@xenia/ui`. It provides:
- **its own scrolling** (the shell's `<main>` never scrolls),
- **the width:** it fills the content area up to the width of a 16:9 screen (`--x-page-max` = `max(1280px, 100vh × 16/9)`). On a 1080p monitor the page fills the screen; on an ultrawide it stays 16:9 wide and is **centred**,
- **the padding and gaps** (`--x-page-pad`, `--x-page-gap`), the same on every page.
```jsx
<Page testId="contacts-page">
<PageHeader title="…" subtitle="…" actions={<Button>New</Button>} />
<Toolbar>
<SearchInput value={q} onChange={setQ} placeholder="…" />
<Dropdown multiple value={kinds} onChange={setKinds} allLabel="All kinds" options={…} />
</Toolbar>
<Panel padded={false}><Table … /></Panel>
</Page>
```
- `top={<Tabs … />}` keeps a tab strip above the scrolling part (Online orders, Settings). The tab is kept in the address (`?tab=`).
- `width="form"` for settings and forms (centred at `--x-page-form-max`, 880 px). Lists, tables and dashboards use the default (full).
- **Never** put `p-*`, `max-w-*`, `mx-auto`, `h-full` or `overflow-*` on a page's root, and never nest a second width limit inside it.
- Checked by `tests/e2e/manager_layout.mjs` (1920×1080 and 3440×1440: every page fills / is centred, and scrolls). Add a new page to its `PAGES` list.
Pages not on `<Page>` yet (own layouts, next review pass): Management → Products (category tree + list), Management → Tables (list + floor editor), Inventory → Stock (placeholder).
## 3. Components (`@xenia/ui`)
| Need | Use | Notes |
|---|---|---|
| A page | `Page`, `PageHeader` | §2 |
| Filters / actions over a list | `Toolbar`, `ToolbarSpacer` | every control in it the same height; the search box grows |
| Search | `SearchInput` | icon, clear button; `onChange(text)` |
| Choose one / several | `Dropdown` (`multiple`) | **never a native `<select>` in a toolbar.** Multi: value is an array, `[]` = all (`allLabel`). Options can carry a `dot` (a zone's colour) and a `hint`. Search box from 9 options. Same heights as `Input`. Native `Select` stays only inside forms where the phone's own picker is better |
| A toggle filter (a state) | `FilterChip` (`tone`, `count`) | |
| Two or three views (List / Map / QR) | `Segmented` | the view in the address (`?view=`) |
| Sections of a page or a dialog | `Tabs` (`size="lg"` on pages) | scrolls sideways only, never up/down |
| A help tip | `InfoTip` | opens on hover (mouse) and on tap |
| Dialogs | `Dialog` `sm` 400 · `md` 520 · `lg` 720 · `xl` 920 | the day summary is `xl` |
The manager's own building blocks (until they move to `@xenia/ui`): `Panel`, `Table`, `Stat` in `pages/reports/kit/parts.jsx`; `Card`, `Figure`, `Pill`, `SplitBar` in `pages/overview/parts.jsx`.
## 4. Type and spacing tokens
| Token / class | Value | Use |
|---|---|---|
| `text-overline` + `font-semibold uppercase tracking-wide text-ink-3` | 11 px | the small labels over figures and sections ("REVENUE", "TOTAL"). Never `text-caption` for these |
| `text-caption` | 12 px | hints, sub-lines |
| `text-label` | 13 px | rows in summaries, table cells, chips |
| `text-body` | 14 px | body text |
| `p-card`, `px-card`, `py-card-y` | 20 px / 14 px | inside every card, panel and section: header rows (`px-card py-card-y`) and bodies (`p-card`) |
## 5. Tables
- `Table` cells are vertically **centred** (`align-middle`): a one-line cell sits in the middle of a two-line row.
- Row actions last, right-aligned, `IconButton size="sm" variant="ghost"`.
- A column's help is `tip` (an `InfoTip` in the header, opens on hover).
## 6. Before you finish a UI change
1. `npm run build:manager` and `npm run lint -w manager-dashboard` pass.
2. `npm test -w @xenia/ui` (contrast in every look) passes.
3. `node tests/e2e/manager_layout.mjs` passes; look at its screenshots in `tests/e2e/out/manager-layout/`.
4. Live preview while working: `npx vite --port 5184` in `manager_dashboard/` (hot reload, uses the running backend on :8000; touches nothing in Docker).
+4
View File
@@ -71,6 +71,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r
| `package.json`, `package-lock.json`, `packages/` | **npm workspace** for the frontends (D-15): `waiter_pwa`, `manager_dashboard`, `terminal` and the shared `packages/{ui,i18n,api,access}` (imported from source, no build step). One lockfile at this root; the apps have none of their own. |
| `terminal/` | The terminal app (phase 3): `src/device/DeviceProvider.jsx` (the device's `/me`, who is signed in, the live connection with credentials in the first frame, offline; apps listen with `useLiveEvent`), `src/device/flow.js` (which screen shows when: pairing → sign-in → app / blocked; pure, unit-tested), `src/screens/` (pairing, sign-in per mode, blocked, app + bar), `src/apps/registry.js` (which apps a screen runs, lazy chunks), `src/device/storage.js` (device + session tokens), `src/api/client.js` (`X-Xenia-Device` on every request; 401 / unreachable listeners). The screen follows the device, not the URL. Lint covers all of `src` |
| `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` |
| `docs/DESIGN.md` | **The design language** (2026-11-20): the page rule (`<Page>`: own scroll, fills 1080p, 16:9 and centred on ultrawides), toolbars, the one `Dropdown` (multi-select), tabs, type/spacing tokens, tables. Read before any UI work (CS-20) |
| `packages/api/` | Shared HTTP client (`createApiClient`: session/device headers, `err.xenia` codes, the manager-approval retry) and the live WebSocket client with cursor replay (`createLiveClient`, used by the waiter's `useWebSocket`) (CS-18) |
| `packages/signage/` | `@xenia/signage` (5.6a): signage slides as the TVs draw them (`SlideView`, `TextSlide`, `MenuSlide`, `Widgets`) and the player's pure logic (schedule pick, slide windows, menu pages; tests in `tests/`), shared by the terminal's player and the manager's previews. Sizes are container units (`cqmin`): a slide needs a parent with `container-type: size` (`frameStyle()`; the manager's `SlidePreview` lays it out at 1920 × 1080 and scales it down, so previews match a TV). Both apps' Tailwind `content` include it |
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (CS-18); the fixed lists every app shares with the backend: sales points (`salesPoints.js` = `core/sales_points.py`) the 14 EU allergens (`allergens.js` = `core/allergens.py`, 6.3) and the menu's languages (`menuLanguages.js` = `core/menu_languages.py`, 6.4: el + en; a product's own name is its base text, translations in `products.translations` / `categories.translations` are for customer screens only; tests compare the lists), and `<Allergens>` (a product's allergens, the same in every app). Plain-JS subpaths `@xenia/access/salesPoints`, `/allergens` for Node tests |
@@ -198,6 +199,9 @@ Manager override (D-10, `core/access/override.py`): mark a key `Perm(..., overri
**CS-16. Shared UI lives in `packages/ui` and never restyles an app** (branch `platform-v2`, D-15, §9).
Design tokens are CSS variables prefixed `--x-` (`packages/ui/src/tokens.css`), components use `.x-*` classes (`src/components.css`); neither file has element selectors, resets or anything that applies outside `.x-*` (the waiter keeps its own `--bg`/`--text`…; the manager's Tailwind classes keep their meaning). The look comes from attributes on `<html>` set by `applyLook` (`packages/ui/src/theme.js`, 6.15): `data-theme` (always `light`/`dark`; "system" is resolved and followed in JS), `data-palette` (the colours: `default`, `nord`…) and `data-style` (the components' shape: `rounded`, `sharp`…), plus `data-venue-theme` (the venue's accent on the staff apps). **A new palette or style is a token block** in `tokens.css` (sections "Palettes" / "Styles") plus its name in `PALETTES` / `STYLES` and its label; components never hard-code a radius, border width or colour, so they follow it. Tailwind apps use `@xenia/ui/tailwind-preset` (adds `bg-surface`, `text-ink-2`, `rounded-control`… only). A colour change must pass `npm test -w @xenia/ui` (WCAG AA for every pair the components use, every venue theme, light and dark). Components take their visible text as props with English defaults until `@xenia/i18n` (2.4). New components get a section in `packages/ui/gallery/Gallery.jsx` (dev-only `/ui-gallery` in the manager) and checks in `tests/e2e/ui.mjs`. **Board screens** (the kitchen display, and any later screen in the same style) use the board design language: `--x-board-*` tokens in the same file (Tailwind `bg-board-bg`, `text-board-ink-2`…; always dark, contrast-tested too) for the board itself, and the normal components in `data-theme="dark"` for their dialogs, toasts and forms (the terminal sets an app's theme from `apps/registry.js` `APP_THEMES`). No hard-coded colours in app code: a colour that isn't a token yet becomes one (values the user stores, like a KDS screen's age colours, are data, not styling).
**CS-20. Every screen follows [DESIGN.md](DESIGN.md)** (2026-11-20).
Pages are `<Page>` (never their own padding / width / scrolling), filters sit in a `<Toolbar>` with one control height, choices are `Dropdown` (never a native select in a toolbar), sections are `Tabs`. Anything a second page needs goes into `@xenia/ui` first. `tests/e2e/manager_layout.mjs` checks the page rule at 1080p and ultrawide.
**CS-17. Frontend text is a key; dates are venue time** (branch `platform-v2`, D-11, D-12, §7.2, §8).
New UI text goes into `packages/i18n/locales/en/<ns>.json` first, then `el` (same keys, same `{{placeholders}}`), and is shown with `t()` from `@xenia/i18n` (`useTranslation`, re-exported). Dates and times are shown only through `useFormat()` (`formatTime`, `formatDateTime`, `formatDate`, `formatRelative`), which use the venue zone from bootstrap; money with `formatMoney`, numbers with `formatNumber`; typed numbers are read with `parseNumber` (comma or dot). Business dates (`YYYY-MM-DD`) go to `formatDate` as they are. `npm test -w @xenia/i18n` runs `scripts/check-i18n.mjs`, which fails on keys missing in English, placeholder mismatches, and `toLocale…String()` / `new Intl.DateTimeFormat(` without `timeZone` in new code (`packages/*`, `terminal/`); it warns for missing Greek. Module names, their limits and **every permission key** have texts in `modules.json` (`modules:<module>.name`, `.limits.<key>`, `.permissions.<rest of the key, nested by its dots>`); `tests/test_module_texts.py` fails for a new module or key without them in both languages. The v1 apps' Greek strings convert in phases 4 and 6. The `@xenia/ui` components get their texts from `<UiLabelsProvider labels={useUiLabels()}>` at the app root.
+2 -4
View File
@@ -22,8 +22,6 @@ import OverviewPage from './pages/overview/OverviewPage'
import TablesPage from './pages/orders/TablesPage'
import OrderPage from './pages/orders/OrderPage'
import OnlineOrdersPage from './pages/online/OnlineOrdersPage'
import FeesPage from './pages/online/FeesPage'
import QrCodesPage from './pages/online/QrCodesPage'
// CRM
import ContactsPage from './pages/finance/ContactsPage'
@@ -134,8 +132,8 @@ export default function App() {
<Route path="dashboard" element={<OverviewPage />} />
<Route path="tables" element={<TablesPage />} />
<Route path="online-orders" element={<OnlineOrdersPage />} />
<Route path="online/fees" element={<FeesPage />} />
<Route path="online/qr" element={<QrCodesPage />} />
<Route path="online/fees" element={<Navigate to="/online-orders?tab=settings" replace />} />
<Route path="online/qr" element={<Navigate to="/tables?view=qr" replace />} />
<Route path="orders/:orderId" element={<OrderPage />} />
{/* ── CRM ── */}
@@ -75,7 +75,7 @@ export default function UserMenuButton({ displayName, onEditProfile, onSignOut }
</button>
<div className="my-1 border-t border-line" />
<div className="flex items-center gap-2.5 px-3.5 pt-1.5 pb-1 text-[11px] font-semibold uppercase tracking-wide text-ink-3">
<div className="flex items-center gap-2.5 px-3.5 pt-1.5 pb-1 text-overline font-semibold uppercase tracking-wide text-ink-3">
<Languages className="h-3.5 w-3.5" />
{t('profile.language')}
</div>
@@ -94,7 +94,7 @@ export default function UserMenuButton({ displayName, onEditProfile, onSignOut }
))}
<div className="my-1 border-t border-line" />
<div className="flex items-center gap-2.5 px-3.5 pt-1.5 pb-1 text-[11px] font-semibold uppercase tracking-wide text-ink-3">
<div className="flex items-center gap-2.5 px-3.5 pt-1.5 pb-1 text-overline font-semibold uppercase tracking-wide text-ink-3">
<Palette className="h-3.5 w-3.5" />
{t('profile.look')}
</div>
+3 -3
View File
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from 'react'
import { PhoneIncoming } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { EmptyState, Spinner } from '@xenia/ui'
import { EmptyState, Page, Spinner } from '@xenia/ui'
import client from '../api/client'
import { useLiveEvent } from '../live/useLiveEvent'
import usePhoneStore from '../store/phoneStore'
@@ -26,7 +26,7 @@ export default function PhonePage() {
const hook = `${window.location.protocol}//${window.location.hostname}/api/phone/call-event?caller=\${CALLERID}&ext=\${EXTEN}`
return (
<div className="p-4 md:p-6 grid gap-6 max-w-3xl" data-testid="phone-page">
<Page testId="phone-page">
<header className="grid gap-1">
<h1 className="text-heading font-semibold text-ink">{t('calls.title')}</h1>
<p className="text-body text-ink-2">{t('calls.intro')}</p>
@@ -62,6 +62,6 @@ export default function PhonePage() {
<code className="text-label text-ink break-all bg-surface p-2 rounded-control border border-line">{hook}</code>
<p className="text-caption text-ink-3">{t('calls.setupSecret')}</p>
</section>
</div>
</Page>
)
}
@@ -5,7 +5,7 @@
import { useSearchParams } from 'react-router-dom'
import { useCan, useModule } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import { Button } from '@xenia/ui'
import { Page, Tabs } from '@xenia/ui'
import PrintingSettings from '../printing/PrintingSettings'
import CustomerDisplaySettings from './sections/CustomerDisplaySettings'
import DevelopmentSettings from './sections/DevelopmentSettings'
@@ -19,9 +19,9 @@ import VenueSettings from './sections/VenueSettings'
const TABS = {
'app-info': () => <SystemSettings />,
venue: () => <div className="max-w-3xl"><VenueSettings /></div>,
'customer-display': () => <div className="max-w-4xl"><CustomerDisplaySettings /></div>,
'menu-tablets': () => <div className="max-w-3xl"><MenuTabletSettings /></div>,
venue: () => <VenueSettings />,
'customer-display': () => <CustomerDisplaySettings />,
'menu-tablets': () => <MenuTabletSettings />,
security: () => <SecuritySettings />,
operation: () => <OperationSettings />,
colours: () => <TableColours />,
@@ -47,16 +47,11 @@ export default function SettingsPage() {
const active = tabs.includes(params.get('tab')) ? params.get('tab') : tabs[0]
const Tab = TABS[active]
return (
<div className="h-full flex flex-col min-h-0" data-testid="settings-page">
<div className="shrink-0 border-b border-line bg-surface px-4 lg:px-6 overflow-x-auto">
<div className="flex gap-1 py-2" role="tablist" aria-label={t('settings.title')}>
{tabs.map(id => (
<Button key={id} size="sm" variant={active === id ? 'primary' : 'ghost'} role="tab" aria-selected={active === id}
onClick={() => setParams({ tab: id }, { replace: true })} data-testid={`settings-tab-${id}`}>{t(`settings.tabs.${id}`)}</Button>
))}
</div>
</div>
<div className="flex-1 overflow-y-auto p-4 lg:p-6"><Tab /></div>
</div>
// settings are forms: the page's form width, centred (the page rule, 2026-11-20)
<Page testId="settings-page" width="form" aria-label={t('settings.title')}
top={<Tabs size="lg" value={active} onChange={id => setParams({ tab: id }, { replace: true })}
tabs={tabs.map(id => ({ id, label: t(`settings.tabs.${id}`), testId: `settings-tab-${id}` }))} />}>
<Tab />
</Page>
)
}
@@ -11,7 +11,7 @@ export default function DevelopmentSettings() {
if (s.loading) return <div className="py-8 flex justify-center"><Spinner /></div>
const spoof = s.get('dev.spoof_printing', 'false') === 'true'
return (
<div className="grid gap-5 max-w-3xl" data-testid="settings-development">
<div className="grid gap-5" data-testid="settings-development">
<p className="rounded-card bg-danger-soft text-danger-ink p-3 text-label" role="note">{t('settings.dev.warning')}</p>
<SettingsCard title={t('settings.dev.title')}>
<SettingRow label={t('settings.dev.spoof')} hint={t('settings.dev.spoofHint')} warning={spoof ? t('settings.dev.spoofOn') : undefined}>
@@ -21,7 +21,7 @@ export default function FiscalSettings() {
if (s.loading) return <div className="py-8 flex justify-center"><Spinner /></div>
const on = s.get('fiscal.enabled', 'false') === 'true'
return (
<div className="grid gap-5 max-w-3xl" data-testid="settings-fiscal">
<div className="grid gap-5" data-testid="settings-fiscal">
<SettingsCard title={t('settings.fiscal.title')} description={t('settings.fiscal.intro')}>
<SettingRow label={t('settings.fiscal.enabled')} hint={t('settings.fiscal.enabledHint')}
warning={on ? t('settings.fiscal.onWarning') : undefined}>
@@ -26,7 +26,7 @@ export default function OperationSettings() {
const chat = useModule('chat')
const qrMenu = useModule('connect_menu')
return (
<div className="grid gap-5 max-w-3xl" data-testid="settings-operation">
<div className="grid gap-5" data-testid="settings-operation">
<RolePermissions />
{ordering && <OrderingSettings />}
{ordering && <TableFlags />}
@@ -19,7 +19,7 @@ import { useSettings } from './useSettings'
export default function SecuritySettings() {
return (
<div className="grid gap-5 max-w-3xl" data-testid="settings-security">
<div className="grid gap-5" data-testid="settings-security">
<SignInSettings />
<IdleSettings />
<RecoveryCodes />
@@ -43,7 +43,7 @@ export default function SystemSettings() {
const counts = ['categories', 'products', 'tables', 'table_groups', 'managers', 'waiters']
return (
<div className="grid gap-5 max-w-3xl" data-testid="settings-system">
<div className="grid gap-5" data-testid="settings-system">
<SettingsCard title={t('settings.system.title')}>
<SettingRow label={t('settings.system.version')}>
<span className="flex flex-wrap items-center gap-2 text-body font-semibold text-ink" data-testid="system-version">
@@ -79,7 +79,7 @@ export default function SystemSettings() {
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3 p-5">
{counts.map(k => (
<div key={k} className="rounded-card bg-surface-2 p-3 grid">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t(`settings.system.counts.${k}`)}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t(`settings.system.counts.${k}`)}</span>
<span className="text-title font-semibold tabular-nums text-ink">{stats?.[k] ?? '—'}</span>
</div>
))}
@@ -36,7 +36,7 @@ export default function CustomerCard({ customer: c, onClose, onEdit }) {
<div className="grid grid-cols-3 gap-2">
{[['visits', fmt.formatNumber(c.visit_count)], ['spent', fmt.formatMoney(c.total_spent)], ['perVisit', avg != null ? fmt.formatMoney(avg) : '—']].map(([k, v]) => (
<div key={k} className="rounded-card bg-surface-2 p-3 grid gap-0.5 text-center">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t(`customers.${k}`)}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t(`customers.${k}`)}</span>
<span className="text-body font-semibold tabular-nums text-ink">{v}</span>
</div>
))}
@@ -58,7 +58,7 @@ export default function CustomerCard({ customer: c, onClose, onEdit }) {
)}
{c.notes && <p className="rounded-card bg-warning-soft text-warning-ink p-3 text-label whitespace-pre-wrap">{c.notes}</p>}
<section>
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('customers.history')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('customers.history')}</h3>
{isPending ? <Spinner /> : !data?.length ? <p className="text-label text-ink-3">{t('customers.noVisits')}</p> : (
<ul className="divide-y divide-line">
{data.map(o => (
@@ -6,10 +6,10 @@
import { useDeferredValue, useState } from 'react'
import { useMutation } from '@tanstack/react-query'
import toast from 'react-hot-toast'
import { Pencil, Plus, Search, Trash2, Users } from 'lucide-react'
import { Pencil, Plus, Trash2, Users } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, IconButton, Input, Spinner } from '@xenia/ui'
import { Button, Dialog, EmptyState, IconButton, Page, PageHeader, SearchInput, Spinner, Toolbar } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Avatar } from '../overview/parts'
@@ -59,19 +59,12 @@ export default function CustomersPage() {
]
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="customers-page">
<div className="max-w-6xl mx-auto grid gap-4">
<header className="flex flex-wrap items-center gap-3">
<div className="flex-1 min-w-0">
<h1 className="text-title font-semibold text-ink">{t('customers.title')}</h1>
<p className="text-label text-ink-2">{t('customers.subtitle')}</p>
</div>
<Button icon={<Plus size={16} />} onClick={() => setDialog({ kind: 'new' })} data-testid="customer-new">{t('customers.new')}</Button>
</header>
<div className="relative">
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-ink-3" aria-hidden="true" />
<Input value={q} onChange={e => setQ(e.target.value)} placeholder={t('customers.search')} aria-label={t('customers.search')} className="pl-9" data-testid="customer-search" />
</div>
<Page testId="customers-page">
<PageHeader title={t('customers.title')} subtitle={t('customers.subtitle')}
actions={<Button icon={<Plus size={16} />} onClick={() => setDialog({ kind: 'new' })} data-testid="customer-new">{t('customers.new')}</Button>} />
<Toolbar>
<SearchInput value={q} onChange={setQ} placeholder={t('customers.search')} data-testid="customer-search" />
</Toolbar>
{isPending ? <div className="py-10 flex justify-center"><Spinner /></div>
: !rows.length && !search ? <EmptyState icon={<Users size={28} />} title={t('customers.none')} description={t('customers.noneHint')} />
: (
@@ -80,7 +73,6 @@ export default function CustomersPage() {
empty={t('customers.noMatch')} initialSort={{ key: 'name', dir: 'asc' }} />
</Panel>
)}
</div>
{(dialog?.kind === 'new' || dialog?.kind === 'edit') && <CustomerDialog customer={dialog.customer} onClose={close} onSaved={saved} />}
{dialog?.kind === 'card' && <CustomerCard customer={dialog.customer} onClose={close} onEdit={() => setDialog({ kind: 'edit', customer: dialog.customer })} />}
{dialog?.kind === 'remove' && (
@@ -90,6 +82,6 @@ export default function CustomersPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(dialog.customer)}>{t('customers.removeYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -5,10 +5,10 @@
import { useState } from 'react'
import { useMutation } from '@tanstack/react-query'
import toast from 'react-hot-toast'
import { BookUser, Pencil, Plus, Search, Trash2 } from 'lucide-react'
import { BookUser, Pencil, Plus, Trash2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, IconButton, Input, Select, Spinner } from '@xenia/ui'
import { Button, Dialog, Dropdown, EmptyState, IconButton, Page, PageHeader, SearchInput, Spinner, Toolbar } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Pill } from '../overview/parts'
@@ -21,7 +21,7 @@ const TYPE_TONE = { supplier: 'accent', staff: 'success', utility: 'warning', ot
export default function ContactsPage() {
const { t } = useTranslation('manager')
const fmt = useFormat()
const [filter, setFilter] = useState({ type: '', q: '' })
const [filter, setFilter] = useState({ type: [], q: '' })
const [dialog, setDialog] = useState(null) // { kind: 'new' | 'edit' | 'remove', contact }
const { data, isPending, refetch } = useLiveQuery({ queryKey: ['contacts'], queryFn: () => client.get('/api/contacts/').then(r => r.data), events: ['expenses.changed'] })
const { data: expenses = [] } = useLiveQuery({ queryKey: ['expenses'], queryFn: () => client.get('/api/expenses/').then(r => r.data), events: ['expenses.changed'] })
@@ -57,23 +57,14 @@ export default function ContactsPage() {
]
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="contacts-page">
<div className="max-w-6xl mx-auto grid gap-4">
<header className="flex flex-wrap items-center gap-3">
<div className="flex-1 min-w-0">
<h1 className="text-title font-semibold text-ink">{t('finance.contacts.title')}</h1>
<p className="text-label text-ink-2">{t('finance.contacts.subtitle', { count: all.length })}</p>
</div>
<Button icon={<Plus size={16} />} onClick={() => setDialog({ kind: 'new' })} data-testid="contact-new">{t('finance.contacts.new')}</Button>
</header>
<div className="flex flex-wrap items-center gap-2">
<div className="relative flex-1 min-w-56">
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-ink-3" aria-hidden="true" />
<Input value={filter.q} onChange={e => set('q', e.target.value)} placeholder={t('finance.contacts.search')} aria-label={t('finance.contacts.search')} className="pl-9" />
</div>
<Select size="sm" value={filter.type} onChange={e => set('type', e.target.value)} aria-label={t('finance.contacts.type')}
options={[{ value: '', label: t('finance.contacts.allTypes') }, ...CONTACT_TYPES.map(k => ({ value: k, label: t(`finance.contacts.types.${k}`) }))]} />
</div>
<Page testId="contacts-page">
<PageHeader title={t('finance.contacts.title')} subtitle={t('finance.contacts.subtitle', { count: all.length })}
actions={<Button icon={<Plus size={16} />} onClick={() => setDialog({ kind: 'new' })} data-testid="contact-new">{t('finance.contacts.new')}</Button>} />
<Toolbar>
<SearchInput value={filter.q} onChange={v => set('q', v)} placeholder={t('finance.contacts.search')} />
<Dropdown multiple value={filter.type} onChange={v => set('type', v)} aria-label={t('finance.contacts.type')} allLabel={t('finance.contacts.allTypes')}
options={CONTACT_TYPES.map(k => ({ value: k, label: t(`finance.contacts.types.${k}`) }))} />
</Toolbar>
{isPending ? <div className="py-10 flex justify-center"><Spinner /></div>
: !all.length ? <EmptyState icon={<BookUser size={28} />} title={t('finance.contacts.none')} description={t('finance.contacts.noneHint')} />
: (
@@ -82,7 +73,6 @@ export default function ContactsPage() {
empty={t('finance.contacts.noMatch')} initialSort={{ key: 'name', dir: 'asc' }} />
</Panel>
)}
</div>
{(dialog?.kind === 'new' || dialog?.kind === 'edit') && <ContactDialog contact={dialog.contact} onClose={close} onSaved={saved} />}
{dialog?.kind === 'remove' && (
<Dialog open size="sm" onClose={close} title={t('finance.contacts.removeTitle', { name: dialog.contact.name })} description={t('finance.contacts.removeBody')}
@@ -91,6 +81,6 @@ export default function ContactsPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(dialog.contact)}>{t('finance.contacts.removeYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -5,10 +5,10 @@
import { useState } from 'react'
import { useMutation } from '@tanstack/react-query'
import toast from 'react-hot-toast'
import { Banknote, Pencil, Plus, Receipt, Search, Trash2 } from 'lucide-react'
import { Banknote, Pencil, Plus, Receipt, Trash2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, IconButton, Input, Select, Spinner } from '@xenia/ui'
import { Button, Dialog, Dropdown, EmptyState, IconButton, Page, PageHeader, SearchInput, Spinner, Toolbar } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Pill } from '../overview/parts'
@@ -20,7 +20,8 @@ import { CATEGORIES, STATUS_TONE, expenseTotals, filterExpenses, isLate } from '
export default function ExpensesPage() {
const { t } = useTranslation('manager')
const fmt = useFormat()
const [filter, setFilter] = useState({ status: 'unpaid', category: '', q: '' })
// what's still to pay first: due + partly paid (= v1's "unpaid")
const [filter, setFilter] = useState({ status: ['due', 'partial'], category: [], q: '' })
const [dialog, setDialog] = useState(null) // { kind: 'new' | 'edit' | 'pay' | 'view' | 'delete', expense }
const { data, isPending, refetch } = useLiveQuery({ queryKey: ['expenses'], queryFn: () => client.get('/api/expenses/').then(r => r.data), events: ['expenses.changed'] })
const all = data ?? []
@@ -66,15 +67,9 @@ export default function ExpensesPage() {
]
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="expenses-page">
<div className="max-w-6xl mx-auto grid gap-4">
<header className="flex flex-wrap items-center gap-3">
<div className="flex-1 min-w-0">
<h1 className="text-title font-semibold text-ink">{t('finance.exp.title')}</h1>
<p className="text-label text-ink-2">{t('finance.exp.subtitle')}</p>
</div>
<Button icon={<Plus size={16} />} onClick={() => open('new')} data-testid="expense-new">{t('finance.exp.new')}</Button>
</header>
<Page testId="expenses-page">
<PageHeader title={t('finance.exp.title')} subtitle={t('finance.exp.subtitle')}
actions={<Button icon={<Plus size={16} />} onClick={() => open('new')} data-testid="expense-new">{t('finance.exp.new')}</Button>} />
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]">
<Stat label={t('finance.exp.owed')} tone={owed.due ? 'danger' : 'success'} value={fmt.formatMoney(owed.due)}
@@ -84,17 +79,13 @@ export default function ExpensesPage() {
sub={t('finance.exp.shownSub', { paid: fmt.formatMoney(shown.paid), count: rows.length })} />
</div>
<div className="flex flex-wrap items-center gap-2">
<div className="relative flex-1 min-w-56">
<Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-ink-3" aria-hidden="true" />
<Input value={filter.q} onChange={e => set('q', e.target.value)} placeholder={t('finance.exp.search')} aria-label={t('finance.exp.search')} className="pl-9" />
</div>
<Select size="sm" value={filter.status} onChange={e => set('status', e.target.value)} aria-label={t('finance.exp.status')} data-testid="expenses-status"
options={[{ value: '', label: t('finance.exp.all') }, { value: 'unpaid', label: t('finance.exp.unpaidOnly') },
...['due', 'partial', 'paid'].map(s => ({ value: s, label: t(`finance.status.${s}`) }))]} />
<Select size="sm" value={filter.category} onChange={e => set('category', e.target.value)} aria-label={t('finance.exp.category')}
options={[{ value: '', label: t('finance.exp.allCategories') }, ...CATEGORIES.map(c => ({ value: c, label: cat(c) }))]} />
</div>
<Toolbar>
<SearchInput value={filter.q} onChange={v => set('q', v)} placeholder={t('finance.exp.search')} />
<Dropdown multiple value={filter.status} onChange={v => set('status', v)} aria-label={t('finance.exp.status')} data-testid="expenses-status" allLabel={t('finance.exp.all')}
options={['due', 'partial', 'paid'].map(s => ({ value: s, label: t(`finance.status.${s}`) }))} />
<Dropdown multiple value={filter.category} onChange={v => set('category', v)} aria-label={t('finance.exp.category')} allLabel={t('finance.exp.allCategories')}
options={CATEGORIES.map(c => ({ value: c, label: cat(c) }))} />
</Toolbar>
{isPending ? <div className="py-10 flex justify-center"><Spinner /></div>
: !all.length ? <EmptyState icon={<Receipt size={28} />} title={t('finance.exp.none')} description={t('finance.exp.noneHint')} />
@@ -104,7 +95,6 @@ export default function ExpensesPage() {
initialSort={{ key: 'created_at', dir: 'desc' }} />
</Panel>
)}
</div>
{(dialog?.kind === 'new' || dialog?.kind === 'edit') && <ExpenseDialog expense={dialog.expense} onClose={close} onSaved={saved} />}
{dialog?.kind === 'pay' && <ExpensePayDialog expense={dialog.expense} onClose={close} onSaved={saved} />}
@@ -120,7 +110,7 @@ export default function ExpensesPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(dialog.expense)} data-testid="expense-delete-confirm">{t('finance.exp.deleteYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -144,7 +134,7 @@ function ExpenseView({ expense: e, cat, onClose, onPay, onEdit }) {
</div>
{e.due_date && <p className="text-label text-ink-2">{t('finance.exp.dueOn', { date: fmt.formatDate(e.due_date) })}</p>}
{e.notes && <p className="text-label text-ink-2 whitespace-pre-wrap">{e.notes}</p>}
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('finance.exp.payments')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('finance.exp.payments')}</h3>
{e.payments?.length ? (
<ul className="divide-y divide-line">
{e.payments.map(p => (
@@ -163,7 +153,7 @@ function ExpenseView({ expense: e, cat, onClose, onPay, onEdit }) {
function Figure({ label, value, tone }) {
return (
<div className="rounded-card bg-surface-2 p-3 grid gap-0.5 text-center">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{label}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{label}</span>
<span className={`text-body font-semibold tabular-nums ${tone ?? 'text-ink'}`}>{value}</span>
</div>
)
@@ -9,7 +9,7 @@ import toast from 'react-hot-toast'
import { Banknote, CheckCircle2, ChevronDown, CreditCard, HandHeart, Search } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, Input, Spinner, cx } from '@xenia/ui'
import { Button, EmptyState, Input, Page, Spinner, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Pill } from '../overview/parts'
@@ -40,8 +40,7 @@ export default function TabsPage() {
})
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="tabs-page">
<div className="max-w-4xl mx-auto grid gap-4">
<Page testId="tabs-page">
<header>
<h1 className="text-title font-semibold text-ink">{t('finance.tabs.title')}</h1>
<p className="text-label text-ink-2">{t('finance.tabs.subtitle')}</p>
@@ -75,9 +74,8 @@ export default function TabsPage() {
))}
</ul>
)}
</div>
<TabDialogs dialog={tabNow && !openQ.isFetching ? { kind: dialog.kind, tab: tabNow } : null} onClose={() => setDialog(null)} onSaved={() => { setDialog(null); refresh() }} />
</div>
</Page>
)
}
@@ -110,14 +108,14 @@ function TabCard({ tab, open, onToggle, onPay, onForgive, onClose, closing }) {
<div className="grid grid-cols-3 divide-x divide-line bg-surface-2 text-center">
{[['charged', tab.total_charged, 'text-ink'], ['paid', tab.total_paid, 'text-success-ink'], ['balance', tab.balance, tab.balance > 0.005 ? 'text-danger-ink' : 'text-ink']].map(([k, v, tone]) => (
<span key={k} className="p-2 grid">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t(`finance.tabs.${k}`)}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t(`finance.tabs.${k}`)}</span>
<span className={cx('text-body font-semibold tabular-nums', tone)}>{fmt.formatMoney(v)}</span>
</span>
))}
</div>
<div className="grid gap-3 p-4 sm:grid-cols-2">
<section>
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('finance.tabs.charges')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('finance.tabs.charges')}</h3>
{tab.entries.length ? (
<ul className="divide-y divide-line text-label">
{tab.entries.map(e => (
@@ -133,7 +131,7 @@ function TabCard({ tab, open, onToggle, onPay, onForgive, onClose, closing }) {
) : <p className="text-label text-ink-3">{t('finance.tabs.noCharges')}</p>}
</section>
<section>
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('finance.tabs.payments')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('finance.tabs.payments')}</h3>
{tab.payments.length ? (
<ul className="divide-y divide-line text-label">
{tab.payments.map(p => (
@@ -57,10 +57,15 @@ export function isLate(expense, today, dateKey) {
}
/** The page's list after its filters: status ('' | 'unpaid' | due | partial | paid), category, text. */
/** A filter's chosen values: a list (the toolbars' multi-selects, 2026-11-20), one value, or none = all. */
const picked = v => (Array.isArray(v) ? v : v ? [v] : [])
export function filterExpenses(list, { status = '', category = '', q = '' } = {}) {
const words = q.trim().toLowerCase().split(/\s+/).filter(Boolean)
return list.filter(e => (!status || (status === 'unpaid' ? e.status !== 'paid' : e.status === status))
&& (!category || e.category === category)
const statuses = picked(status)
const categories = picked(category)
return list.filter(e => (!statuses.length || statuses.some(s => (s === 'unpaid' ? e.status !== 'paid' : e.status === s)))
&& (!categories.length || categories.includes(e.category))
&& words.every(w => `${e.description} ${e.contact_name ?? ''} ${e.notes ?? ''}`.toLowerCase().includes(w)))
}
@@ -107,7 +112,8 @@ export function contactBody(form) {
export function filterContacts(list, { type = '', q = '' } = {}) {
const words = q.trim().toLowerCase().split(/\s+/).filter(Boolean)
return list.filter(c => (!type || c.type === type)
const types = picked(type)
return list.filter(c => (!types.length || types.includes(c.type))
&& words.every(w => `${c.name} ${c.phone ?? ''} ${c.email ?? ''} ${c.notes ?? ''}`.toLowerCase().includes(w)))
}
@@ -35,7 +35,7 @@ export default function FloorPlansTab() {
<div className="flex flex-wrap items-end gap-x-4 gap-y-2">
{byZone.map(z => (
<div key={z.id ?? 'none'} className="grid gap-1">
<span className="text-caption font-semibold text-ink-3 uppercase tracking-wide">{z.name}</span>
<span className="text-overline font-semibold text-ink-3 uppercase tracking-wide">{z.name}</span>
<div className="flex flex-wrap gap-1.5">
{z.plans.map(p => (
<button key={p.id} type="button" onClick={() => setChosen(p.id)} aria-current={plan?.id === p.id ? 'true' : undefined} data-testid="floor-plan-item" data-name={p.name}
@@ -8,7 +8,7 @@ import toast from 'react-hot-toast'
import { Plus, Trash2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, Field, IconButton, Input, Select, Spinner } from '@xenia/ui'
import { Button, Dialog, Field, IconButton, Input, Page, Select, Spinner } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Pill } from '../overview/parts'
@@ -65,8 +65,7 @@ export default function ThrowawaysPage() {
]
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="waste-page">
<div className="max-w-6xl mx-auto grid gap-4">
<Page testId="waste-page">
<header>
<h1 className="text-title font-semibold text-ink">{t('waste.title')}</h1>
<p className="text-label text-ink-2">{t('waste.subtitle')}</p>
@@ -100,7 +99,6 @@ export default function ThrowawaysPage() {
{history.isPending ? <div className="p-4"><Spinner /></div>
: <Table columns={columns(false)} rows={rows} rowTestId="waste-row" empty={t('waste.noneInPeriod')} initialSort={{ key: 'logged_at', dir: 'desc' }} />}
</Panel>
</div>
{removing && (
<Dialog open size="sm" onClose={() => setRemoving(null)} title={t('waste.deleteTitle', { name: removing.product_name })}
footer={<>
@@ -108,7 +106,7 @@ export default function ThrowawaysPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(removing)}>{t('waste.deleteYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Upload } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { Button, EmptyState, Input, Select, Spinner, cx } from '@xenia/ui'
import { Button, EmptyState, Input, Page, Select, Spinner, cx } from '@xenia/ui'
import { listMedia } from './mediaApi'
import { ACCEPT, preparing } from './mediaLogic'
import MediaDetails from './MediaDetails'
@@ -57,8 +57,8 @@ export default function MediaPage() {
const closeDetails = useCallback(() => setOpen(null), [])
return (
<div className={cx('p-4 md:p-6 grid gap-5 max-w-7xl min-h-full content-start', dragging && 'outline-2 outline-dashed outline-accent -outline-offset-8')}
data-testid="media-page"
<Page className={cx(dragging && 'outline-2 outline-dashed outline-accent -outline-offset-8')}
testId="media-page"
onDragOver={e => { if ([...(e.dataTransfer?.types || [])].includes('Files')) { e.preventDefault(); setDragging(true) } }}
onDragLeave={e => { if (e.currentTarget === e.target) setDragging(false) }}
onDrop={onDrop}>
@@ -95,6 +95,6 @@ export default function MediaPage() {
{open && <MediaDetails id={open} onClose={closeDetails}
onChanged={m => setPage(p => p && { ...p, items: p.items.map(x => (x.id === m.id ? { ...x, ...m } : x)) })}
onDeleted={id => setPage(p => p && { ...p, items: p.items.filter(x => x.id !== id), total: p.total - 1 })} />}
</div>
</Page>
)
}
@@ -8,7 +8,7 @@ import toast from 'react-hot-toast'
import { Check, ChevronDown, Pin, PinOff, Plus, Trash2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, IconButton, Input, Switch, Textarea, cx } from '@xenia/ui'
import { Button, Dialog, IconButton, Input, Page, Switch, Textarea, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Panel } from '../reports/kit/parts'
@@ -36,8 +36,7 @@ export default function NotesPage() {
const { pinned, rest } = splitNotes(notes)
const { open, done } = splitTodos(todos)
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="notes-page">
<div className="max-w-6xl mx-auto grid gap-4">
<Page testId="notes-page">
<header>
<h1 className="text-title font-semibold text-ink">{t('notes.title')}</h1>
<p className="text-label text-ink-2">{t('notes.subtitle', { notes: notes.length, todos: open.length })}</p>
@@ -62,7 +61,6 @@ export default function NotesPage() {
</div>
</Panel>
</div>
</div>
{removing && (
<Dialog open size="sm" onClose={() => setRemoving(null)} title={t(removing.kind === 'note' ? 'notes.deleteNote' : 'notes.deleteTodo')}
description={removing.item.body.length > 120 ? `${removing.item.body.slice(0, 120)}…` : removing.item.body}
@@ -71,12 +69,12 @@ export default function NotesPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(removing, { onSuccess: () => setRemoving(null) })} data-testid="notes-delete-confirm">{t('notes.deleteYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
function Label({ children }) {
return <span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{children}</span>
return <span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{children}</span>
}
function NewNote() {
@@ -1,3 +1,4 @@
// Online ordering settings: Online orders → Settings (2026-11-20; was its own page /online/fees).
// Online ordering (plan phase 3S, steps S.3–S.5): the ordering settings (OrderingSettings),
// delivery areas and fees, and the fee's line on the receipt (FeeProductCard). Backend: /api/connect/fees
// (connect_orders.fees). The venue lists the areas it delivers to and the fee rules, looked
@@ -49,14 +50,11 @@ export default function FeesPage() {
}
}
if (error) return <div className="p-6"><EmptyState title={error} /></div>
if (!data) return <div className="p-6 flex justify-center"><Spinner /></div>
if (error) return <EmptyState title={error} />
if (!data) return <div className="py-10 flex justify-center"><Spinner /></div>
return (
<div className="p-4 md:p-6 grid gap-6 max-w-6xl" data-testid="fees-page">
<header className="grid gap-1">
<h1 className="text-heading font-semibold text-ink">{t('ordering.pageTitle')}</h1>
</header>
<div className="grid gap-6" data-testid="fees-page">
{data.links?.order && <OrderingLink url={data.links.order} />}
@@ -4,17 +4,22 @@
// then ready (takeaway) or out for delivery, then delivered. Each card shows the customer, when
// they want it, the venue's own price check and the lines. The lists refresh on the live
// events (a new order, a status change), after a reconnect, and every 20 seconds.
// Settings (2026-11-20, was the page /online/fees): ordering hours, delivery areas and fees, for
// whoever has connect_orders.fees. The tab is kept in the address (?tab=).
import { useState } from 'react'
import { useSearchParams } from 'react-router-dom'
import { useQueryClient } from '@tanstack/react-query'
import toast from 'react-hot-toast'
import { Check, RefreshCw, StickyNote, X } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, Field, Spinner, Textarea, cx } from '@xenia/ui'
import { useCan } from '@xenia/access'
import { Button, EmptyState, Field, Page, Spinner, Tabs, Textarea, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { lineTotal, orderTotal } from '../overview/overviewLogic'
import { Pill } from '../overview/parts'
import FeesPage from './FeesPage'
import { ONLINE_TABS, ONLINE_TONE, onlineKind, onlineNextStep } from './onlineOrdersLogic'
const EVENTS = ['online_order_received', 'online_order_updated']
@@ -33,9 +38,13 @@ function useList(tab) {
export default function OnlineOrdersPage() {
const { t } = useTranslation('manager')
const qc = useQueryClient()
const [tab, setTab] = useState('incoming')
const canSettings = useCan('connect_orders.fees')
const [params, setParams] = useSearchParams()
const asked = params.get('tab')
const tab = asked === 'settings' ? (canSettings ? 'settings' : 'incoming') : ONLINE_TABS.includes(asked) ? asked : 'incoming'
const setTab = id => setParams(p => { const n = new URLSearchParams(p); n.set('tab', id); return n }, { replace: true })
const lists = { incoming: useList('incoming'), active: useList('active'), history: useList('history') }
const current = lists[tab]
const current = lists[tab] ?? lists.incoming
const refresh = () => qc.invalidateQueries({ queryKey: ['online-orders'] })
async function act(fn) {
@@ -47,34 +56,29 @@ export default function OnlineOrdersPage() {
: client.post(`/api/connect/orders/${id}/status`, { status: extra })
))
const tabs = [
...ONLINE_TABS.map(k => {
const count = lists[k].data?.length ?? 0
return { id: k, label: t(`onlineOrders.tab.${k}`), badge: count > 0 ? count : null, warn: k === 'incoming', testId: `online-tab-${k}` }
}),
...(canSettings ? [{ id: 'settings', label: t('onlineOrders.tab.settings'), testId: 'online-tab-settings' }] : []),
]
return (
<div className="flex flex-col h-full overflow-hidden" data-testid="online-orders">
<div className="shrink-0 flex items-end gap-1 border-b border-line px-4 md:px-6 pt-2" role="tablist">
{ONLINE_TABS.map(k => {
const count = lists[k].data?.length ?? 0
return (
<button key={k} type="button" role="tab" aria-selected={tab === k} onClick={() => setTab(k)} data-testid={`online-tab-${k}`}
className={cx('flex items-center gap-2 px-4 py-3 -mb-px border-b-2 text-body whitespace-nowrap transition-colors duration-fast',
tab === k ? 'border-accent text-ink font-semibold' : 'border-transparent text-ink-2 hover:text-ink')}>
{t(`onlineOrders.tab.${k}`)}
{count > 0 && <span className={cx('px-1.5 rounded-full text-caption font-bold tabular-nums', k === 'incoming' ? 'bg-danger-soft text-danger-ink' : 'bg-surface-2 text-ink-2')}>{count}</span>}
</button>
)
})}
<span className="flex-1" />
<Button size="sm" variant="ghost" className="mb-2" icon={<RefreshCw size={14} />} loading={current.isFetching} onClick={refresh}>{t('onlineOrders.refresh')}</Button>
</div>
<div className="flex-1 overflow-y-auto p-4 md:p-6">
<Page testId="online-orders"
top={<Tabs size="lg" tabs={tabs} value={tab} onChange={setTab}
end={tab !== 'settings' && <Button size="sm" variant="ghost" icon={<RefreshCw size={14} />} loading={current.isFetching} onClick={refresh}>{t('onlineOrders.refresh')}</Button>} />}>
{tab === 'settings' ? <FeesPage /> : (<>
{current.error && <EmptyState compact title={errorMessage(current.error, t)} />}
{current.isPending ? <div className="py-10 flex justify-center"><Spinner /></div>
: current.data?.length === 0 ? <EmptyState title={t(`onlineOrders.empty.${tab}`)} />
: (
<div className="grid gap-4 max-w-3xl">
<div className="grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,26rem),1fr))] items-start">
{current.data?.map(o => <OrderCard key={o.id} order={o} onAction={onAction} />)}
</div>
)}
</div>
</div>
</>)}
</Page>
)
}
@@ -1,3 +1,4 @@
// The tables' QR codes: Tables → QR codes (2026-11-20; was its own page /online/qr).
// The tables' QR codes (plan phase 3S, step S.7): one code per table that opens the QR menu
// at that table. The venue chooses whether guests can order from it (straight onto the
// table's order, to the kitchen, with a message to the table's waiters) or only read it. A
@@ -13,7 +14,7 @@ import { Button, Dialog, EmptyState, Spinner, Switch } from '@xenia/ui'
import { QrCode } from '@xenia/ui/qr'
import client from '../../api/client'
export default function QrCodesPage() {
export default function TableQrCodes() {
const { t } = useTranslation('manager')
const [data, setData] = useState(null)
const [error, setError] = useState(null)
@@ -31,17 +32,13 @@ export default function QrCodesPage() {
setBusy(false)
}
if (error) return <div className="p-6"><EmptyState title={error} /></div>
if (!data) return <div className="p-6 flex justify-center"><Spinner /></div>
if (error) return <EmptyState title={error} />
if (!data) return <div className="py-10 flex justify-center"><Spinner /></div>
return (
<div className="p-4 md:p-6 grid gap-6 max-w-6xl" data-testid="qr-page">
<header className="grid gap-1 print:hidden">
<h1 className="text-heading font-semibold text-ink">{t('qr.title')}</h1>
<p className="text-body text-ink-2 max-w-3xl">{t('qr.intro')}</p>
</header>
<section className="p-4 rounded-card border border-line bg-surface grid gap-3 print:hidden">
<div className="grid gap-5" data-testid="qr-page">
<section className="p-card rounded-card border border-line bg-surface shadow-raised grid gap-3 print:hidden">
<p className="text-body text-ink-2">{t('qr.intro')}</p>
<Switch checked={data.ordering} disabled={busy} data-testid="qr-ordering"
onChange={on => act(() => client.put('/api/connect/qr/ordering', { on }), t('fees.saved'))}
label={t('qr.ordering')} description={t(data.ordering ? 'qr.orderingOn' : 'qr.orderingOff')} />
@@ -57,7 +54,7 @@ export default function QrCodesPage() {
) : (
<ul className="grid gap-4 print:gap-6" style={{ gridTemplateColumns: 'repeat(auto-fill, minmax(13rem, 1fr))' }} data-testid="qr-tables">
{data.tables.map(tb => (
<li key={tb.id} className="p-4 rounded-card border border-line bg-surface grid justify-items-center gap-2 break-inside-avoid" data-testid="qr-table" data-table={tb.id} data-url={tb.url}>
<li key={tb.id} className="p-card rounded-card border border-line bg-surface grid justify-items-center gap-2 break-inside-avoid" data-testid="qr-table" data-table={tb.id} data-url={tb.url}>
<span className="text-title font-semibold text-ink">{t('qr.table', { name: tb.name })}</span>
{tb.group && <span className="text-label text-ink-2">{tb.group}</span>}
<QrCode value={tb.url} size={168} framed={false} />
@@ -10,7 +10,7 @@ import toast from 'react-hot-toast'
import { ArrowLeft, Ban, CheckCheck, CreditCard, Printer } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Select, Spinner, cx } from '@xenia/ui'
import { Button, Dialog, EmptyState, Page, Select, Spinner, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { useDuration } from '../overview/hooks'
@@ -54,8 +54,7 @@ function NewOrder({ tableId }) {
const table = tables.find(x => x.id === tableId)
const open = async () => (await client.post('/api/orders/', { table_id: tableId, order_type: 'here' })).data.id
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="order-new">
<div className="max-w-6xl mx-auto grid gap-4">
<Page testId="order-new">
<header className="flex flex-wrap items-center gap-3">
<Back />
<h1 className="text-title font-semibold text-ink">{t('orders.newTitle', { table: table ? tableName(table) : tableId ?? '' })}</h1>
@@ -66,8 +65,7 @@ function NewOrder({ tableId }) {
qc.invalidateQueries({ queryKey: ['orders-active'] })
navigate(`/orders/${id}`, { replace: true })
}} />
</div>
</div>
</Page>
)
}
@@ -121,8 +119,7 @@ function OrderView({ orderId }) {
}
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="order-page" data-status={order.status}>
<div className="max-w-6xl mx-auto grid gap-4">
<Page testId="order-page" data-status={order.status}>
<header className="flex flex-wrap items-center gap-3">
<Back />
<h1 className="text-title font-semibold text-ink">{order.table_name ? t('orders.title', { table: order.table_name }) : t('orders.titleNoTable', { id: order.id })}</h1>
@@ -167,7 +164,6 @@ function OrderView({ orderId }) {
)}
{tab === 'prices' && <section className="rounded-card border border-line bg-surface shadow-raised overflow-hidden"><PriceEventList events={priceEvents} /></section>}
{tab === 'history' && <section className="rounded-card border border-line bg-surface shadow-raised overflow-hidden"><AuditList order={order} /></section>}
</div>
{paying && <PayDialog orderId={order.id} itemIds={paying.ids} amount={paying.amount} card={venue.card} thenClose={!!paying.thenClose}
onClose={() => setPaying(null)}
@@ -192,6 +188,6 @@ function OrderView({ orderId }) {
<Button variant="danger" icon={<Printer size={16} />} loading={cancel.isPending && cancel.variables === true} onClick={() => cancel.mutate(true)}>{t('orders.lines.cancelPrint')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -25,7 +25,7 @@ export default function OrderPeople({ order, open, staff, onChanged }) {
return (
<section className="rounded-card border border-line bg-surface shadow-raised p-4 grid gap-3" data-testid="order-people">
<div className="grid gap-2">
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('orders.people.staff')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('orders.people.staff')}</h3>
<div className="flex flex-wrap items-center gap-2">
{order.waiters.length === 0 && <span className="text-label text-ink-3">{t('orders.people.noStaff')}</span>}
{order.waiters.map(w => (
@@ -65,7 +65,7 @@ function Customer({ order, open, onChanged }) {
return (
<div className="grid gap-2 border-t border-line pt-3">
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('orders.people.customer')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('orders.people.customer')}</h3>
{order.customer_id ? (
<div className="flex items-center gap-2 p-2 rounded-control bg-info-soft text-info-ink">
<UserRound size={16} aria-hidden="true" />
@@ -37,7 +37,7 @@ export default function PrintProblemsCard({ orderId = null, onOpen }) {
</span>}>
<PrintProblemsPanel problems={shown} printers={data?.printers ?? []} run={run} showPlace={orderId == null}
onOpen={onOpen ? p => onOpen(p.order_id, p.table_name) : undefined} />
<p className="px-4 pb-3 text-caption text-ink-3">{t('orders.printHelp')}</p>
<p className="px-card pb-3 text-caption text-ink-3">{t('orders.printHelp')}</p>
</Card>
)
}
@@ -4,11 +4,15 @@
// and can tell its waiters (or everyone) a message. Tickets that didn't print are listed below
// with what can be done about them (6.10).
// Everything stays current through the live events.
// 2026-11-20: the toolbar is the shared one (view, state chips, zones as a multi-select), a click on
// the card opens the table (no separate button), and the tables' QR codes are a view here (?view=qr;
// was the page /online/qr) for whoever manages the QR menu.
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { Clock, Lock, Printer, Zap } from 'lucide-react'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { Clock, LayoutGrid, Lock, Map as MapIcon, Printer, QrCode, Zap } from 'lucide-react'
import { useCan, useModule } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, IconButton, Select, Spinner, cx } from '@xenia/ui'
import { Dropdown, EmptyState, FilterChip, IconButton, Page, Segmented, Spinner, Toolbar, ToolbarSpacer, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import LiveFloor from '../floor/LiveFloor'
@@ -16,6 +20,7 @@ import { useDuration } from '../overview/hooks'
import { TABLE_STATES, durationParts, orderTotal, tableCards, tableName } from '../overview/overviewLogic'
import { Money, Pill } from '../overview/parts'
import PrintProblemsCard from './PrintProblemsCard'
import TableQrCodes from '../online/TableQrCodes'
import { BORDER, SOFT, SOLID } from '../overview/tones'
import QuickActions from './QuickActions'
import { NO_ZONE, cardTarget, filterCards, flagsByTable, personName } from './orderLogic'
@@ -27,9 +32,15 @@ export default function TablesPage() {
const { t } = useTranslation('manager')
const tc = useTranslation('common').t
const navigate = useNavigate()
const [view, setView] = useState('list')
const qrModule = useModule('connect_menu')
const qrAllowed = useCan('connect_menu.manage')
const qrOn = qrModule && qrAllowed
const [params, setParams] = useSearchParams()
const views = ['list', 'map', ...(qrOn ? ['qr'] : [])]
const view = views.includes(params.get('view')) ? params.get('view') : 'list'
const setView = v => setParams(p => { const n = new URLSearchParams(p); n.set('view', v); return n }, { replace: true })
const [states, setStates] = useState([])
const [zone, setZone] = useState('')
const [zones, setZones] = useState([])
const [quick, setQuick] = useState(null) // a card
const { data: tables = [], isPending: loadingTables } = useLiveQuery({
@@ -45,49 +56,47 @@ export default function TablesPage() {
const { data: staff = [] } = useLiveQuery({ queryKey: ['waiters'], queryFn: () => client.get('/api/waiters/').then(r => r.data), staleTime: 60_000 })
const cards = tableCards(tables, orders)
const shown = filterCards(cards, { states, zone })
const shown = filterCards(cards, { states, zones })
const flags = flagsByTable(flagDefs, flagRows)
const name = id => personName(staff.find(s => s.id === id)) || `#${id}`
const toggleState = s => setStates(list => (list.includes(s) ? list.filter(x => x !== s) : [...list, s]))
if (loadingTables || loadingOrders) return <div className="h-full grid place-items-center"><Spinner /></div>
const viewIcon = { list: <LayoutGrid size={15} />, map: <MapIcon size={15} />, qr: <QrCode size={15} /> }
const oneZone = zones.length === 1 && zones[0] !== NO_ZONE ? Number(zones[0]) : null
return (
<div className="h-full overflow-y-auto p-4 lg:p-6 grid gap-4 content-start" data-testid="tables-page">
<div className="flex flex-wrap items-center gap-2">
<div className="flex rounded-control border border-line overflow-hidden" role="group">
{['list', 'map'].map(v => (
<button key={v} type="button" aria-pressed={view === v} onClick={() => setView(v)} data-testid={`tables-view-${v}`}
className={cx('px-3 py-1.5 text-label font-medium', view === v ? 'bg-accent-soft text-accent-ink' : 'bg-surface text-ink-2 hover:bg-surface-2')}>
{tc(`floorMap.${v}`)}
</button>
))}
</div>
<span className="flex-1" />
<Page testId="tables-page">
<Toolbar className="print:hidden">
<Segmented value={view} onChange={setView} aria-label={t('orders.tables.viewAs')}
options={views.map(v => ({ value: v, label: v === 'qr' ? t('orders.tables.qrCodes') : tc(`floorMap.${v}`), icon: viewIcon[v], testId: `tables-view-${v}` }))} />
<ToolbarSpacer />
{view === 'list' && TABLE_STATES.map(s => (
<button key={s} type="button" aria-pressed={states.includes(s)} onClick={() => toggleState(s)} data-testid={`tables-state-${s}`}
className={cx('inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full border text-label font-semibold',
states.includes(s) ? `${SOFT[STATE_TONE[s]]} ${BORDER[STATE_TONE[s]]}` : 'border-line bg-surface text-ink-2 hover:bg-surface-2')}>
<span className={cx('w-2 h-2 rounded-full', SOLID[STATE_TONE[s]])} aria-hidden="true" />
<FilterChip key={s} tone={STATE_TONE[s]} pressed={states.includes(s)} onClick={() => toggleState(s)} data-testid={`tables-state-${s}`}
count={cards.filter(c => c.state === s).length}>
{t(`overview.tableState.${s}`)}
<span className="tabular-nums text-ink">{cards.filter(c => c.state === s).length}</span>
</button>
</FilterChip>
))}
<Select size="sm" value={zone} onChange={e => setZone(e.target.value)} aria-label={t('orders.tables.zone')} data-testid="tables-zone">
<option value="">{t('orders.tables.allZones')}</option>
{groups.map(g => <option key={g.id} value={String(g.id)}>{g.name}</option>)}
<option value={NO_ZONE}>{t('orders.tables.noZone')}</option>
</Select>
</div>
{view !== 'qr' && (
<Dropdown multiple value={zones} onChange={setZones} allLabel={t('orders.tables.allZones')} aria-label={t('orders.tables.zone')} data-testid="tables-zone"
options={[
...groups.map(g => ({ value: String(g.id), label: g.name, dot: g.color || undefined })),
{ value: NO_ZONE, label: t('orders.tables.noZone') },
]} />
)}
</Toolbar>
{view === 'qr' && <TableQrCodes />}
{view === 'map' && (
<LiveFloor zone={zone && zone !== NO_ZONE ? Number(zone) : null} onOpen={id => navigate(`/orders/${id}`)} />
<LiveFloor zone={oneZone} onOpen={id => navigate(`/orders/${id}`)} />
)}
{view === 'list' && (shown.length === 0
? <EmptyState title={t('orders.tables.none')} />
: (
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]">
<div className="grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,20.5rem),1fr))]">
{shown.map(card => (
<TableCard key={card.table.id} card={card} zone={groups.length > 1 ? groups.find(g => g.id === card.table.group_id)?.name : null} flags={flags[card.table.id] ?? []} waiterName={name}
onOpen={() => navigate(cardTarget(card))} onQuick={() => setQuick(card)} />
@@ -95,10 +104,10 @@ export default function TablesPage() {
</div>
))}
<PrintProblemsCard onOpen={id => navigate(`/orders/${id}`)} />
{view !== 'qr' && <PrintProblemsCard onOpen={id => navigate(`/orders/${id}`)} />}
{quick && <QuickActions card={quick} flagDefs={flagDefs} current={flags[quick.table.id] ?? []} onClose={() => setQuick(null)} />}
</div>
</Page>
)
}
@@ -114,7 +123,7 @@ function TableCard({ card, zone, flags, waiterName, onOpen, onQuick }) {
return (
<div className={cx('relative rounded-card border bg-surface shadow-raised overflow-hidden grid', BORDER[tone])} data-testid="table-card" data-state={state} data-table={table.id}>
<span className={cx('absolute inset-y-0 left-0 w-1.5', SOLID[tone])} aria-hidden="true" />
<button type="button" onClick={onOpen} className="text-left pl-5 pr-4 pt-3 pb-2 grid gap-2 hover:bg-surface-2 transition-colors duration-fast"
<button type="button" onClick={onOpen} data-testid="table-open" className="text-left pl-5 pr-4 pt-4 pb-3 grid gap-2.5 hover:bg-surface-2 transition-colors duration-fast"
aria-label={t('orders.tables.open', { table: tableName(table), state: t(`overview.tableState.${state}`) })}>
<span className="flex items-start gap-2">
<span className="flex-1 grid gap-1">
@@ -137,24 +146,23 @@ function TableCard({ card, zone, flags, waiterName, onOpen, onQuick }) {
</span>
<span className="grid grid-cols-2 gap-2">
<span className="grid">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('orders.total')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('orders.total')}</span>
{order ? <Money value={orderTotal(order.items)} className="text-title font-semibold text-ink" /> : <span className="text-title text-ink-3">—</span>}
</span>
<span className="grid">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('orders.tables.time')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('orders.tables.time')}</span>
<span className={cx('text-title tabular-nums inline-flex items-center gap-1', long ? 'font-bold text-warning-ink' : 'text-ink')}>
{order ? <><Clock size={14} aria-hidden="true" />{since(order.opened_at)}</> : <span className="text-ink-3">—</span>}
</span>
</span>
</span>
</button>
<div className="flex items-center gap-2 pl-5 pr-2 py-2 border-t border-line">
<div className="flex items-center gap-2 pl-5 pr-2 py-1.5 border-t border-line">
<span className="flex-1 min-w-0 truncate text-label text-ink-2">
{!order ? (table.seat_count ? t('orders.tables.seats', { count: table.seat_count }) : '')
: order.waiters.length ? order.waiters.map(w => waiterName(w.waiter_id)).join(', ') : t('orders.tables.noWaiter')}
</span>
<IconButton size="sm" variant="ghost" label={t('orders.quick.title', { table: tableName(table) })} onClick={onQuick} data-testid="table-quick"><Zap size={16} /></IconButton>
<Button size="sm" variant={order ? 'secondary' : 'primary'} onClick={onOpen} data-testid="table-open">{order ? t('orders.tables.view') : t('orders.tables.take')}</Button>
</div>
</div>
)
@@ -81,12 +81,13 @@ export const NO_ZONE = 'none'
/** Cards (overviewLogic.tableCards) shown for the chosen states (none = all) and zone
* ('' = all, NO_ZONE = tables without a zone, else a zone id as text). */
export function filterCards(cards, { states = [], zone = '' } = {}) {
export function filterCards(cards, { states = [], zone = '', zones } = {}) {
// zones: several at once (the toolbar's multi-select, 2026-11-20); [] = all. zone: one (older callers)
const picked = zones ?? (zone ? [zone] : [])
return cards.filter(c => {
if (states.length && !states.includes(c.state)) return false
if (zone === NO_ZONE) return !c.table.group_id
if (zone) return String(c.table.group_id ?? '') === zone
return true
if (!picked.length) return true
return picked.some(z => (z === NO_ZONE ? !c.table.group_id : String(c.table.group_id ?? '') === z))
})
}
@@ -70,7 +70,7 @@ function BookingRow({ booking: b, onEdit, onStatus, onConfirm, onDecline }) {
const { formatTime, formatDateTime } = useFormat()
const table = b.table_label || (b.table_id ? `#${b.table_id}` : null)
return (
<li className="flex items-center gap-3 px-4 py-2.5" data-testid="booking-row" data-status={b.status}>
<li className="flex items-center gap-3 px-card py-3" data-testid="booking-row" data-status={b.status}>
<span className="w-12 shrink-0 text-center grid">
<span className="text-body font-bold tabular-nums text-ink">{formatTime(b.reserved_for)}</span>
<span className="text-caption text-ink-3">{formatDateTime(b.reserved_for, { day: 'numeric', month: 'short' })}</span>
@@ -6,11 +6,10 @@ import { useState } from 'react'
import toast from 'react-hot-toast'
import { errorMessage } from '@xenia/api'
import { parseNumber, useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Spinner, cx } from '@xenia/ui'
import { Button, Dialog, EmptyState, Spinner, Tabs } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { CashTab, ChecksTab, MoneyTab, PrintersTab, StaffTab, ZonesTab } from './DaySummaryTabs'
import { Pill } from './parts'
export default function DaySummaryDialog({ dayId, closing = false, onClose, onClosed }) {
const { t } = useTranslation('manager')
@@ -40,13 +39,13 @@ export default function DaySummaryDialog({ dayId, closing = false, onClose, onCl
}
const tabs = [
{ id: 'money', label: t('overview.day.tab.money') },
{ id: 'staff', label: t('overview.day.tab.staff'), badge: data?.waiters?.length },
{ id: 'zones', label: t('overview.day.tab.zones'), badge: data?.zones?.length },
{ id: 'printers', label: t('overview.day.tab.printers'), badge: data?.printers?.length },
{ id: 'money', label: t('overview.day.tab.money'), testId: 'day-tab-money' },
{ id: 'staff', label: t('overview.day.tab.staff'), badge: data?.waiters?.length, testId: 'day-tab-staff' },
{ id: 'zones', label: t('overview.day.tab.zones'), badge: data?.zones?.length, testId: 'day-tab-zones' },
{ id: 'printers', label: t('overview.day.tab.printers'), badge: data?.printers?.length, testId: 'day-tab-printers' },
...(closing ? [
{ id: 'cash', label: t('overview.day.tab.cash') },
{ id: 'checks', label: t('overview.day.tab.checks'), badge: data?.checks ? data.checks.open_orders + data.checks.active_shifts : null, warn: data?.checks?.with_unpaid_items > 0 },
{ id: 'cash', label: t('overview.day.tab.cash'), testId: 'day-tab-cash' },
{ id: 'checks', label: t('overview.day.tab.checks'), badge: data?.checks ? data.checks.open_orders + data.checks.active_shifts : null, warn: data?.checks?.with_unpaid_items > 0, testId: 'day-tab-checks' },
] : []),
]
@@ -58,23 +57,17 @@ export default function DaySummaryDialog({ dayId, closing = false, onClose, onCl
</>)
return (
<Dialog open size="lg" onClose={onClose} footer={footer || undefined}
<Dialog open size="xl" onClose={onClose} footer={footer || undefined}
title={closing ? t('overview.day.closeTitle') : t('overview.day.statsTitle')}
description={data && <span className="inline-flex items-center gap-2">
<Pill tone={data.status === 'open' ? 'success' : 'neutral'}>{data.status === 'open' ? t('overview.day.open') : t('overview.day.closedState')}</Pill>
{t('overview.day.openedAt', { time: formatDateTime(data.opened_at, 'datetimeShort') })}
description={data && <span className="inline-flex flex-wrap items-center gap-x-1.5 text-label" data-testid="day-status">
{data.status === 'open'
? <span className="inline-flex items-center gap-1.5 font-semibold text-success-ink"><span className="w-2 h-2 rounded-full bg-success" aria-hidden="true" />{t('overview.day.open')}</span>
: <span>{t('overview.day.closedState')}</span>}
<span aria-hidden="true">·</span>
<span>{t('overview.day.openedAt', { time: formatDateTime(data.opened_at, 'datetimeShort') })}</span>
</span>}>
<div className="grid gap-4" data-testid="day-summary">
<div className="flex gap-1 overflow-x-auto border-b border-line -mx-1 px-1" role="tablist">
{tabs.map(tb => (
<button key={tb.id} type="button" role="tab" aria-selected={tab === tb.id} onClick={() => setTab(tb.id)} data-testid={`day-tab-${tb.id}`}
className={cx('flex items-center gap-1.5 px-3 py-2 -mb-px border-b-2 text-label whitespace-nowrap transition-colors duration-fast',
tab === tb.id ? 'border-accent text-ink font-semibold' : 'border-transparent text-ink-2 hover:text-ink')}>
{tb.label}
{tb.badge != null && <span className={cx('min-w-5 px-1 rounded-full text-caption font-bold tabular-nums', tb.warn ? 'bg-danger-soft text-danger-ink' : 'bg-surface-2 text-ink-2')}>{tb.badge}</span>}
</button>
))}
</div>
<Tabs tabs={tabs} value={tab} onChange={setTab} />
{isPending && <div className="py-10 flex justify-center"><Spinner /></div>}
{error && <EmptyState compact title={errorMessage(error, t)} />}
{data && (<>
@@ -9,7 +9,7 @@ import { PAY_METHODS, cashCheck, paymentTotals } from './overviewLogic'
import { Avatar, Figure, Money, Pill, SplitBar } from './parts'
import { SOFT } from './tones'
const PAY_TONE = { cash: 'success', card: 'info', transfer: 'accent', treat: 'warning', other: 'neutral' }
const PAY_TONE = { cash: 'success', card: 'info', transfer: 'accent', treat: 'warning', other: 'neutral', onTab: 'special' }
function usePayParts() {
const { t } = useTranslation('manager')
@@ -18,7 +18,7 @@ function usePayParts() {
function Row({ label, value, tone, warn, indent, sub, info }) {
return (
<div className={cx('flex items-baseline justify-between gap-3 py-1', indent && 'pl-4 text-label')}>
<div className={cx('flex items-baseline justify-between gap-3 py-1 text-label', indent && 'pl-4')}>
<span className={cx('flex-1 flex items-center gap-1', warn ? 'text-warning-ink' : indent ? 'text-ink-2' : 'text-ink')}>{label}{info}</span>
<span className="text-right grid">
<span className={cx('font-semibold tabular-nums', tone ?? 'text-ink')}>{value}</span>
@@ -30,13 +30,23 @@ function Row({ label, value, tone, warn, indent, sub, info }) {
function Section({ title, children, shaded }) {
return (
<div className={cx('px-4 py-3 border-b border-line last:border-b-0', shaded && 'bg-surface-2')}>
<div className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{title}</div>
<div className={cx('px-card py-card-y border-b border-line last:border-b-0', shaded && 'bg-surface-2')}>
<div className="text-overline font-semibold uppercase tracking-wide text-ink-3 mb-1.5">{title}</div>
{children}
</div>
)
}
/** One of the day's figures in its own box (v1's stat boxes). */
function StatBox({ label, children }) {
return (
<div className="rounded-card border border-line bg-surface-2 px-4 py-3 grid gap-1 content-start min-w-0">
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3 truncate">{label}</span>
<span className="text-title font-bold tabular-nums text-ink truncate">{children}</span>
</div>
)
}
export function MoneyTab({ data }) {
const { t } = useTranslation('manager')
const { formatMoney, formatDateTime } = useFormat()
@@ -45,15 +55,14 @@ export function MoneyTab({ data }) {
const sign = v => (v >= 0 ? 'text-success-ink' : 'text-danger-ink')
return (
<div className="grid gap-4" data-testid="day-money">
<div className="grid grid-cols-2 md:grid-cols-4 gap-3">
<Figure label={t('overview.day.revenue')}><Money value={data.total_revenue} /></Figure>
<Figure label={t('overview.day.orders')}>{data.total_orders}</Figure>
<Figure label={t('overview.day.items')}>{data.total_items_ordered}</Figure>
<Figure label={t('overview.day.waiters')}>{staff.length}</Figure>
</div>
<div className="flex flex-wrap gap-6">
<Figure label={t('overview.day.opened')}>{formatDateTime(data.opened_at, 'datetimeShort')}</Figure>
<Figure label={t('overview.day.closed')}>{data.closed_at ? formatDateTime(data.closed_at, 'datetimeShort') : <span className="text-success-ink">{t('overview.day.stillOpen')}</span>}</Figure>
{/* the six figures of the day, each in its own box, all the same size (as in v1) */}
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3" data-testid="day-figures">
<StatBox label={t('overview.day.revenue')}><Money value={data.total_revenue} /></StatBox>
<StatBox label={t('overview.day.orders')}>{data.total_orders}</StatBox>
<StatBox label={t('overview.day.items')}>{data.total_items_ordered}</StatBox>
<StatBox label={t('overview.day.waiters')}>{staff.length}</StatBox>
<StatBox label={t('overview.day.opened')}>{formatDateTime(data.opened_at, 'datetimeShort')}</StatBox>
<StatBox label={t('overview.day.closed')}>{data.closed_at ? formatDateTime(data.closed_at, 'datetimeShort') : <span className="text-success-ink">{t('overview.day.stillOpen')}</span>}</StatBox>
</div>
<div className="rounded-card border border-line overflow-hidden">
@@ -108,13 +117,16 @@ export function MoneyTab({ data }) {
</div>
<div className="grid gap-2">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('overview.day.payments')}</span>
{data.total_revenue > 0 ? <SplitBar parts={pay(paymentTotals(data.waiters))} /> : <span className="text-label text-ink-3">—</span>}
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('overview.day.payments')}</span>
{/* lines put on tabs are sold but not paid: their own part of the bar */}
{data.total_revenue + (data.tabbed_revenue || 0) > 0
? <SplitBar parts={[...pay(paymentTotals(data.waiters)), { key: 'onTab', tone: PAY_TONE.onTab, label: t('overview.pay.onTab'), value: data.tabbed_revenue || 0 }]} />
: <span className="text-label text-ink-3">—</span>}
</div>
{data.store_closing_cash != null && (
<div className="rounded-card border border-line px-4 py-3">
<div className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('overview.day.drawer')}</div>
<div className="rounded-card border border-line px-card py-card-y">
<div className="text-overline font-semibold uppercase tracking-wide text-ink-3 mb-1.5">{t('overview.day.drawer')}</div>
<Row label={t('overview.day.drawerExpected')} value={formatMoney(data.store_expected_closing)} />
<Row label={t('overview.day.drawerCounted')} value={formatMoney(data.store_closing_cash)} />
<Row label={t('overview.day.drawerDiff')} warn={data.store_cash_discrepancy !== 0}
@@ -140,7 +152,7 @@ export function StaffTab({ data }) {
return (
<div key={w.waiter_id} className="rounded-card border border-line overflow-hidden">
<button type="button" onClick={() => setOpen(shown ? null : w.waiter_id)} aria-expanded={shown}
className="w-full flex flex-wrap items-center gap-3 px-4 py-3 text-left bg-surface hover:bg-surface-2">
className="w-full flex flex-wrap items-center gap-x-6 gap-y-3 px-card py-card-y text-left bg-surface hover:bg-surface-2">
<Avatar name={w.waiter_name} />
<span className="flex-1 min-w-32 grid">
<span className="text-body font-semibold text-ink">{w.waiter_name}</span>
@@ -155,7 +167,7 @@ export function StaffTab({ data }) {
<ChevronDown size={16} className={cx('text-ink-3 transition-transform duration-base', shown && 'rotate-180')} aria-hidden="true" />
</button>
{shown && (
<div className="border-t border-line bg-surface-2 p-4 grid gap-3">
<div className="border-t border-line bg-surface-2 p-card grid gap-4">
<div className="grid grid-cols-2 md:grid-cols-4 gap-3">
<Figure label={t('overview.day.shiftStart')}>{w.shift_started_at ? formatTime(w.shift_started_at) : '—'}</Figure>
<Figure label={t('overview.day.shiftEnd')}>{w.shift_ended_at ? formatTime(w.shift_ended_at) : <span className="text-success-ink">{t('overview.day.shiftRunning')}</span>}</Figure>
@@ -181,7 +193,7 @@ export function ZonesTab({ data }) {
return (
<div className="grid gap-2" data-testid="day-zones">
{data.zones.map(z => (
<div key={z.group_id} className="rounded-card border border-line p-4 grid gap-3">
<div key={z.group_id} className="rounded-card border border-line p-card grid gap-3">
<div className="flex items-center gap-2">
{/* a zone's colour is the venue's choice (data), not styling */}
<span className={cx('w-3 h-3 rounded-sm shrink-0', !z.color && 'bg-ink-3')} style={z.color ? { background: z.color } : undefined} aria-hidden="true" />
@@ -210,7 +222,7 @@ export function PrintersTab({ data }) {
{data.printers.map(p => {
const rate = p.jobs > 0 ? Math.round((p.success / p.jobs) * 100) : 0
return (
<div key={p.printer_id} className="rounded-card border border-line p-4 grid gap-3">
<div key={p.printer_id} className="rounded-card border border-line p-card grid gap-3">
<div className="flex items-center gap-3">
<span className="w-9 h-9 grid place-items-center rounded-control bg-surface-2 text-ink-2"><Printer size={18} aria-hidden="true" /></span>
<span className="flex-1 grid">
@@ -247,8 +259,8 @@ export function CashTab({ data, counted, onCounted, value }) {
const tone = check ? (check.state === 'even' ? 'success' : 'danger') : null
return (
<div className="grid gap-4" data-testid="day-cash">
<div className="rounded-card border border-line bg-surface-2 px-4 py-3">
<div className="text-caption font-semibold uppercase tracking-wide text-ink-3 mb-1">{t('overview.day.takings')}</div>
<div className="rounded-card border border-line bg-surface-2 px-card py-card-y">
<div className="text-overline font-semibold uppercase tracking-wide text-ink-3 mb-1.5">{t('overview.day.takings')}</div>
<Row label={t('overview.day.staffTook')} value={formatMoney(data.total_waiter_collected)} />
{data.tabs?.received_outside_shifts?.total > 0 && <Row indent label={t('overview.day.tabOutsideShifts')} value={formatMoney(data.tabs.received_outside_shifts.total)}
info={<InfoTip>{t('overview.day.tabOutsideShiftsTip')}</InfoTip>} />}
@@ -38,7 +38,7 @@ export default function MessagesCard({ staff, tables }) {
const to = messageTargets(m, staff)
const acks = messageAcks(m, staff.length)
return (
<li key={m.id} className="flex items-start gap-3 px-4 py-2.5" data-testid="message-row">
<li key={m.id} className="flex items-start gap-3 px-card py-3" data-testid="message-row">
<span className="flex-1 min-w-0 grid">
<span className="text-body font-semibold text-ink">{m.body}</span>
<span className="text-caption text-ink-3">{t('overview.messages.to', { who: to ? to.join(', ') : t('overview.messages.everyone'), time: formatTime(m.created_at) })}</span>
@@ -27,7 +27,7 @@ export default function NotesCard() {
return (
<div className="relative" onMouseEnter={enter} onMouseLeave={leave}>
<button type="button" onClick={() => navigate('/notes')} onFocus={() => setPreview(true)} onBlur={leave}
className="w-full flex items-center gap-3 p-4 rounded-card border border-line bg-surface shadow-raised text-left hover:shadow-popover transition-shadow duration-fast"
className="w-full flex items-center gap-3 px-card py-4 rounded-card border border-line bg-surface shadow-raised text-left hover:shadow-popover transition-shadow duration-fast"
data-testid="notes-card">
<span className="flex-1 min-w-0 grid">
<span className="text-body-lg font-semibold text-ink">{t('overview.notes.title')}</span>
@@ -41,7 +41,7 @@ export default function NotesCard() {
{items.map(item => {
const Icon = item.kind === 'todo' ? (item.is_done ? CheckSquare : Square) : item.is_pinned ? Pin : FileText
return (
<li key={`${item.kind}-${item.id}`} className="flex items-start gap-2 px-4 py-2.5">
<li key={`${item.kind}-${item.id}`} className="flex items-start gap-2 px-card py-2.5">
<Icon size={14} className="mt-0.5 shrink-0 text-ink-3" aria-hidden="true" />
<span className={cx('text-label text-ink line-clamp-2', item.is_done && 'line-through opacity-50')}>{item.body}</span>
</li>
@@ -112,7 +112,7 @@ export default function OrderDialog({ orderId, tableName, onClose, onOpenFull })
<div className="grid gap-3 -mx-2" data-testid="order-dialog">
{order.waiters.length > 0 && (
<div className="flex flex-wrap items-center gap-2 px-2">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('overview.order.staff')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('overview.order.staff')}</span>
{order.waiters.map(w => <Pill key={w.waiter_id} tone="accent">{nameOf(w.waiter_id)}</Pill>)}
</div>
)}
@@ -13,7 +13,7 @@ import { BarChart3, Eye, EyeOff, Lock, Play, Power } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useCan, useModule } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, IconButton, Spinner, cx } from '@xenia/ui'
import { Button, Dialog, IconButton, Page, Spinner, cx } from '@xenia/ui'
import client from '../../api/client'
import { LicenseContext } from '../../shell/licenseContext'
import { useLiveQuery } from '../../live/useLiveQuery'
@@ -123,7 +123,7 @@ export default function OverviewPage() {
if (tablesPending || ordersPending || dayPending) return <div className="p-6 flex justify-center"><Spinner /></div>
return (
<div className="p-4 md:p-6 grid gap-5" data-testid="overview">
<Page testId="overview">
<header className="flex flex-wrap items-center justify-between gap-3">
<div className="grid gap-1">
<Pill tone={dayOpen ? 'success' : 'neutral'} className="justify-self-start uppercase tracking-wide" data-testid="day-state" data-open={dayOpen}>
@@ -171,7 +171,7 @@ export default function OverviewPage() {
onMessage={s => setMessage({ id: s.waiter_id, name: s.waiter_name })} />
<TablesCard cards={cards} onOpen={(id, table) => setOrder({ id, table })} />
<Card title={t('overview.revenueByHour')} testId="revenue-chart">
<div className="p-4"><HourBars buckets={hourBuckets(orderPairs(today), hourOf)} current={nowHour} /></div>
<div className="p-card"><HourBars buckets={hourBuckets(orderPairs(today), hourOf)} current={nowHour} /></div>
</Card>
</div>
<div className="grid gap-5 min-w-0">
@@ -198,14 +198,14 @@ export default function OverviewPage() {
</div>
</Dialog>
)}
</div>
</Page>
)
}
function Kpi({ label, sub, pct, tone, children }) {
return (
<div className={cx('rounded-card border bg-surface shadow-raised p-4 grid gap-1 content-start', tone === 'warning' ? 'border-warning' : 'border-line')}>
<span className="text-caption font-semibold uppercase tracking-wide text-ink-2">{label}</span>
<div className={cx('rounded-card border bg-surface shadow-raised p-card grid gap-1 content-start', tone === 'warning' ? 'border-warning' : 'border-line')}>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-2">{label}</span>
<span className="text-display font-bold tabular-nums text-ink leading-tight">{children}</span>
{sub && <span className="text-label text-ink-2">{sub}</span>}
{pct != null && (
@@ -82,7 +82,7 @@ export default function ShiftDialog({ shift, mode, onClose, onConfirm, busy }) {
{screen === 'overview' && (<>
<div className={cx('rounded-card border p-4 flex flex-wrap items-center justify-between gap-3', SOFT.success, 'border-success')}>
<div className="grid">
<span className="text-caption font-semibold uppercase tracking-wide">{t('overview.shift.expected')}</span>
<span className="text-overline font-semibold uppercase tracking-wide">{t('overview.shift.expected')}</span>
<Money value={money.expected} className="text-display font-bold text-ink" data-testid="shift-expected" />
</div>
<div className="text-label text-right">
@@ -106,7 +106,7 @@ export default function ShiftDialog({ shift, mode, onClose, onConfirm, busy }) {
{data.activity && <ShiftActivity a={data.activity} money={money} />}
{summary && shiftPairs(summary).length > 0 && (
<div className="grid gap-2">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('overview.shift.perHour')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('overview.shift.perHour')}</span>
<HourBars buckets={hourBuckets(shiftPairs(summary), hourOf, { from: 24, to: -1 })} height="h-16" />
</div>
)}
@@ -19,11 +19,11 @@ export default function ShiftsCard({ shifts, idle, dayOpen, hidden, onStart, onE
return (
<Card title={t('overview.shifts.title')} testId="shifts-card"
action={dayOpen && idle.length > 0 && <Button size="sm" variant="secondary" icon={<Plus size={16} />} onClick={() => setStarting(true)} data-testid="shift-start">{t('overview.shifts.start')}</Button>}>
<div className="p-3 grid gap-2">
<div className="p-card grid gap-2">
{shifts.length === 0 ? <EmptyState compact title={t('overview.shifts.none')} /> : shifts.map(s => {
const onBreak = Array.isArray(s.breaks) ? s.breaks.find(b => !b.ended_at) : null
return (
<div key={s.id} className={cx('flex items-center gap-3 p-2.5 rounded-card border', onBreak ? 'border-warning bg-warning-soft' : 'border-line bg-surface-2')} data-testid="shift-row">
<div key={s.id} className={cx('flex items-center gap-3 px-3.5 py-3 rounded-card border', onBreak ? 'border-warning bg-warning-soft' : 'border-line bg-surface-2')} data-testid="shift-row">
<Avatar name={s.waiter_name} url={s.avatar_url} />
<div className="flex-1 min-w-0">
<div className="flex flex-wrap items-center gap-2">
@@ -19,7 +19,7 @@ export default function TablesCard({ cards, onOpen }) {
return (
<Card title={t('overview.tables.title')} testId="tables-card"
action={<Button size="sm" variant="ghost" iconEnd={<ArrowRight size={16} />} onClick={() => navigate('/tables')}>{t('overview.tables.all')}</Button>}>
<div className="p-4 grid gap-3">
<div className="p-card grid gap-3">
<div className="grid gap-2 grid-cols-[repeat(auto-fill,minmax(3.5rem,1fr))]">
{cards.map(({ table, order, state }) => (
<button key={table.id} type="button" disabled={!order}
@@ -9,7 +9,7 @@ export function Card({ title, info, action, children, className, testId, tone })
return (
<section className={cx('rounded-card border bg-surface shadow-raised overflow-hidden', tone ? BORDER[tone] : 'border-line', className)} data-testid={testId}>
{(title || action) && (
<header className={cx('flex items-center gap-2 px-4 py-3 border-b', tone ? `${SOFT[tone]} ${BORDER[tone]}` : 'border-line')}>
<header className={cx('flex items-center gap-2 px-card py-card-y border-b', tone ? `${SOFT[tone]} ${BORDER[tone]}` : 'border-line')}>
<h2 className="flex-1 min-w-0 text-body-lg font-semibold flex items-center gap-1">{title}{info}</h2>
{action}
</header>
@@ -69,7 +69,7 @@ export function HourBars({ buckets, current, height = 'h-24', testId }) {
export function Figure({ label, children, sub, className }) {
return (
<div className={cx('grid gap-0.5', className)}>
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{label}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{label}</span>
<span className="text-title font-semibold tabular-nums text-ink">{children}</span>
{sub && <span className="text-caption text-ink-3">{sub}</span>}
</div>
@@ -6,11 +6,12 @@ export const SOFT = {
info: 'bg-info-soft text-info-ink',
warning: 'bg-warning-soft text-warning-ink',
danger: 'bg-danger-soft text-danger-ink',
special: 'bg-special-soft text-special-ink',
neutral: 'bg-surface-2 text-ink-2',
}
export const SOLID = {
accent: 'bg-accent', success: 'bg-success', info: 'bg-info', warning: 'bg-warning', danger: 'bg-danger', neutral: 'bg-ink-3',
accent: 'bg-accent', success: 'bg-success', info: 'bg-info', warning: 'bg-warning', danger: 'bg-danger', special: 'bg-special', neutral: 'bg-ink-3',
}
export const BORDER = {
accent: 'border-accent', success: 'border-success', info: 'border-info', warning: 'border-warning', danger: 'border-danger', neutral: 'border-line',
accent: 'border-accent', success: 'border-success', info: 'border-info', warning: 'border-warning', danger: 'border-danger', special: 'border-special', neutral: 'border-line',
}
@@ -14,7 +14,7 @@ import toast from 'react-hot-toast'
import { MonitorSmartphone, Plus } from 'lucide-react'
import { errorMessage, parseError } from '@xenia/api'
import { useTranslation, useFormat } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Field, Input, Select, Spinner } from '@xenia/ui'
import { Button, Dialog, EmptyState, Field, Input, Page, Select, Spinner } from '@xenia/ui'
import client from '../../api/client'
import DeviceConfigFields from './DeviceConfigFields'
import { configInitial, deviceStatus, deviceUsage, hasRoom, linkTargets, normalizeCode } from './devicesLogic'
@@ -104,7 +104,7 @@ export default function DevicesPage() {
}
return (
<div className="p-6 lg:p-8 max-w-6xl grid gap-6">
<Page>
<div className="flex flex-wrap items-start gap-4 justify-between">
<p className="text-body text-ink-2 max-w-2xl">{t('devices.intro')}</p>
<Button icon={<Plus size={16} />} onClick={() => setDialog({ kind: 'pair' })}>{t('devices.pair')}</Button>
@@ -187,7 +187,7 @@ export default function DevicesPage() {
<RemoveDialog device={dialog.device} onClose={() => setDialog(null)}
onRemove={() => act(() => client.post(`/api/devices/${dialog.device.id}/revoke`))} />
)}
</div>
</Page>
)
}
@@ -8,7 +8,7 @@ import toast from 'react-hot-toast'
import { errorMessage } from '@xenia/api'
import { useAccess } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, Spinner } from '@xenia/ui'
import { Button, EmptyState, Page, Spinner } from '@xenia/ui'
import client from '../../api/client'
export default function LicensePage() {
@@ -68,7 +68,7 @@ export default function LicensePage() {
const sorted = [...modules].sort((a, b) => t(`modules:${a.key}.name`).localeCompare(t(`modules:${b.key}.name`)))
return (
<div className="p-6 lg:p-8 max-w-5xl grid gap-6">
<Page>
<section className="bg-surface border border-line rounded-card shadow-raised p-6 grid gap-4" data-testid="license-status">
<div className="flex flex-wrap items-center gap-3 justify-between">
<div>
@@ -129,6 +129,6 @@ export default function LicensePage() {
</tbody>
</table>
</section>
</div>
</Page>
)
}
@@ -9,7 +9,7 @@ import toast from 'react-hot-toast'
import { errorMessage } from '@xenia/api'
import { useAccess, useCan } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Spinner, Switch } from '@xenia/ui'
import { Button, Dialog, EmptyState, Page, Spinner, Switch } from '@xenia/ui'
import client from '../../api/client'
import { moduleState, stoppedBy } from './modulesLogic'
@@ -79,7 +79,7 @@ function ModulesPage({ kinds, intro }) {
if (!modules) return <div className="p-8 flex justify-center"><Spinner /></div>
return (
<div className="p-6 lg:p-8 max-w-6xl grid gap-8">
<Page>
<div>
<p className="text-body text-ink-2 max-w-2xl">{intro}</p>
{!canManage && <p className="text-label text-ink-3 mt-1">{t('modules.readOnly')}</p>}
@@ -113,7 +113,7 @@ function ModulesPage({ kinds, intro }) {
</span>
)}
</Dialog>
</div>
</Page>
)
}
@@ -3,6 +3,7 @@
// apply to what is added to orders from then on (lines already on an order keep their price).
import { useState } from 'react'
import { useTranslation } from '@xenia/i18n'
import { Page } from '@xenia/ui'
import DealsTab from './DealsTab'
import DiscountsTab from './DiscountsTab'
import ModifiersTab from './ModifiersTab'
@@ -14,7 +15,7 @@ export default function PricingPage() {
const { t } = useTranslation('manager')
const [tab, setTab] = useState('rules')
return (
<div className="p-4 md:p-6 grid gap-5 max-w-5xl content-start" data-testid="pricing-page">
<Page testId="pricing-page">
<header className="grid gap-1">
<h1 className="text-heading font-semibold text-ink">{t('pricing.pageTitle')}</h1>
<p className="text-body text-ink-2 max-w-3xl">{t('pricing.intro')}</p>
@@ -32,6 +33,6 @@ export default function PricingPage() {
{tab === 'groups' && <PriceGroupsTab />}
{tab === 'deals' && <DealsTab />}
{tab === 'discounts' && <DiscountsTab />}
</div>
</Page>
)
}
@@ -9,7 +9,7 @@ import { CookingPot, Pencil, Plus, Printer, Trash2 } from 'lucide-react'
import { useCan } from '@xenia/access'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, IconButton, Spinner } from '@xenia/ui'
import { Button, Dialog, EmptyState, IconButton, Page, Spinner } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Pill } from '../overview/parts'
@@ -32,8 +32,7 @@ export default function PrepZonesPage() {
const nameOf = id => printers.find(p => p.id === id)?.name ?? `#${id}`
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="prep-zones-page">
<div className="max-w-6xl mx-auto grid gap-4">
<Page testId="prep-zones-page">
<header className="flex flex-wrap items-center gap-3">
<div className="flex-1 min-w-0">
<h1 className="text-title font-semibold text-ink">{t('printing.zones.title')}</h1>
@@ -61,13 +60,13 @@ export default function PrepZonesPage() {
</header>
<div className="grid gap-1 text-label">
<span className="flex flex-wrap items-center gap-1.5">
<span className="w-16 shrink-0 text-caption font-semibold uppercase tracking-wide text-ink-3">{t('printing.zones.main')}</span>
<span className="w-16 shrink-0 text-overline font-semibold uppercase tracking-wide text-ink-3">{t('printing.zones.main')}</span>
{z.master_printer_id ? <Pill tone="accent"><Printer size={12} aria-hidden="true" />{nameOf(z.master_printer_id)}{z.auto_print !== 'none' && z.master_copies > 1 ? ` ×${z.master_copies}` : ''}</Pill>
: <span className="text-ink-3">{t('printing.zones.noPrinter')}</span>}
</span>
{z.secondary_printer_ids?.length > 0 && (
<span className="flex flex-wrap items-center gap-1.5">
<span className="w-16 shrink-0 text-caption font-semibold uppercase tracking-wide text-ink-3">{t('printing.zones.also')}</span>
<span className="w-16 shrink-0 text-overline font-semibold uppercase tracking-wide text-ink-3">{t('printing.zones.also')}</span>
{z.secondary_printer_ids.map(id => <Pill key={id}><Printer size={12} aria-hidden="true" />{nameOf(id)}</Pill>)}
{z.auto_print === 'all' && z.secondary_copies > 1 && <span className="text-ink-3">×{z.secondary_copies}</span>}
</span>
@@ -86,7 +85,6 @@ export default function PrepZonesPage() {
))}
</div>
)}
</div>
{editing && <ZoneDialog zone={editing.id ? editing : null} printers={printers} categories={categories}
onClose={() => setEditing(null)} onSaved={() => { setEditing(null); qc.invalidateQueries({ queryKey: ['prep-zones'] }) }} />}
@@ -98,6 +96,6 @@ export default function PrepZonesPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(deleting.id)} data-testid="zone-delete-confirm">{t('printing.zones.deleteYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -6,7 +6,7 @@ import TicketSettings from './TicketSettings'
export default function PrintingSettings() {
return (
<div className="max-w-4xl grid gap-5" data-testid="printing-settings">
<div className="grid gap-5" data-testid="printing-settings">
<PrintersCard />
<PrintAlertSetting />
<TicketSettings />
@@ -97,7 +97,7 @@ export default function TicketSettings() {
<SettingsCard title={t('printing.ticket.fonts')} description={t('printing.ticket.fontsHint')} testId="ticket-fonts">
{FONT_GROUPS.map(g => (
<div key={g.key}>
<div className="px-5 pt-3 pb-1 text-caption font-semibold uppercase tracking-wide text-ink-3">{t(`printing.ticket.groups.${g.key}`)}</div>
<div className="px-5 pt-3 pb-1 text-overline font-semibold uppercase tracking-wide text-ink-3">{t(`printing.ticket.groups.${g.key}`)}</div>
{g.fields.map(key => <FontRow key={key} field={key} value={val(key)} onSave={v => s.save(key, v)} />)}
{g.key === 'items' && <DotsRow value={val('print.dot_style')} onSave={v => s.save('print.dot_style', v)} />}
</div>
@@ -15,7 +15,7 @@ import { AUTO_PRINT, SORT_BY, move, orderedCategories, setBypass, setMain, toggl
function Section({ title, children }) {
return (
<section className="grid gap-3">
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3">{title}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3">{title}</h3>
{children}
</section>
)
@@ -61,7 +61,7 @@ export default function ProductList({ groups, view, categories, prepZones, selec
<section key={g.key} data-testid="product-group" data-category={g.key}>
{headers && (
<button type="button" onClick={() => setFolded(s => { const n = new Set(s); if (n.has(g.key)) n.delete(g.key); else n.add(g.key); return n })}
className="flex items-center gap-2 py-1.5 text-caption font-semibold uppercase tracking-wide text-ink-3" aria-expanded={!shut}>
className="flex items-center gap-2 py-1.5 text-overline font-semibold uppercase tracking-wide text-ink-3" aria-expanded={!shut}>
{shut ? <ChevronRight size={14} /> : <ChevronDown size={14} />}
{g.cat && <Dot cat={g.cat} />}
{g.cat ? (g.cat.parent_id ? `${categories.find(c => c.id === g.cat.parent_id)?.name ?? ''} › ${g.cat.name}` : g.cat.name) : t('products.uncategorized')}
@@ -37,7 +37,7 @@ export default function Toolbar({ title, shown, total, search, onSearch, filters
{open && (
<div className="absolute z-popover top-full left-4 right-4 md:left-6 md:right-6 mt-1 p-4 rounded-card border border-line bg-surface shadow-popover flex flex-wrap items-end gap-5">
<label className="grid gap-1">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('products.price')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('products.price')}</span>
<span className="flex items-center gap-1.5">
<Input size="sm" className="w-20" inputMode="decimal" value={filters.priceMin} onChange={e => set('priceMin', e.target.value)} placeholder={t('products.from')} aria-label={t('products.from')} />
<span className="text-ink-3">–</span>
@@ -45,13 +45,13 @@ export default function Toolbar({ title, shown, total, search, onSearch, filters
</span>
</label>
<div className="grid gap-1">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('products.quality')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('products.quality')}</span>
<span className="flex gap-1">
{['all', 'no-photo', 'no-cat'].map(q => <Button key={q} size="sm" variant={filters.quality === q ? 'primary' : 'secondary'} onClick={() => set('quality', q)}>{t(`products.qualityOf.${q}`)}</Button>)}
</span>
</div>
<div className="grid gap-1">
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('products.show')}</span>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('products.show')}</span>
<span className="flex gap-1">
<Button size="sm" variant={filters.unavailableOnly ? 'primary' : 'secondary'} onClick={() => set('unavailableOnly', !filters.unavailableOnly)}>{t('products.unavailableOnly')}</Button>
<Button size="sm" variant={filters.showArchived ? 'primary' : 'secondary'} onClick={() => set('showArchived', !filters.showArchived)}>{t('products.withArchived')}</Button>
@@ -81,7 +81,7 @@ function Expenses() {
<p>{t('reports.exp.total')}: <b>{fmt.formatMoney(open.total_amount)}</b> · {t('reports.exp.paid')}: <b>{fmt.formatMoney(open.paid_amount)}</b>{open.due_amount ? <> · {t('reports.exp.due')}: <b className="text-danger-ink">{fmt.formatMoney(open.due_amount)}</b></> : null}</p>
{open.due_date && <p className="text-label text-ink-2">{t('reports.exp.dueDate', { date: fmt.formatDate(open.due_date) })}</p>}
{open.notes && <p className="text-label text-ink-2">{open.notes}</p>}
<h3 className="text-caption font-semibold uppercase tracking-wide text-ink-3 mt-2">{t('reports.exp.payments')}</h3>
<h3 className="text-overline font-semibold uppercase tracking-wide text-ink-3 mt-2">{t('reports.exp.payments')}</h3>
{open.payments?.length ? (
<ul className="divide-y divide-line">
{open.payments.map(p => <li key={p.id} className="py-1.5 flex justify-between text-label"><span>{fmt.formatDate(p.paid_at)}{p.paid_by_name ? ` · ${p.paid_by_name}` : ''}{p.notes ? ` · ${p.notes}` : ''}</span><b className="tabular-nums">{fmt.formatMoney(p.amount)}</b></li>)}
@@ -7,7 +7,7 @@ import toast from 'react-hot-toast'
import { ArrowDown, ArrowUp, Download, Info } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, InfoTip, Spinner, cx } from '@xenia/ui'
import { Button, EmptyState, InfoTip, Page, Spinner, cx } from '@xenia/ui'
import client from '../../../api/client'
import { sortRows } from './reportLogic'
@@ -17,8 +17,7 @@ export function ReportPage({ title, tabs = [], children, testId }) {
const active = tabs.find(t => t.id === params.get('tab'))?.id ?? tabs[0]?.id
const tab = tabs.find(t => t.id === active)
return (
<div className="h-full overflow-y-auto" data-testid={testId}>
<div className="max-w-7xl mx-auto p-4 lg:p-6 grid gap-4">
<Page testId={testId}>
<header className="flex flex-wrap items-end gap-3">
<h1 className="text-title font-semibold text-ink flex-1 min-w-0">{title}</h1>
{tabs.length > 1 && (
@@ -33,8 +32,7 @@ export function ReportPage({ title, tabs = [], children, testId }) {
)}
</header>
{tab ? <tab.Component key={tab.id} /> : children}
</div>
</div>
</Page>
)
}
@@ -43,12 +41,12 @@ export function Panel({ title, tip, actions, children, className, padded = true,
return (
<section className={cx('rounded-card border border-line bg-surface shadow-raised overflow-hidden', className)} data-testid={testId}>
{(title || actions) && (
<header className="flex flex-wrap items-center gap-2 px-4 py-3 border-b border-line">
<header className="flex flex-wrap items-center gap-2 px-card py-card-y border-b border-line">
<h2 className="flex-1 min-w-0 text-body font-semibold text-ink flex items-center gap-1">{title}{tip && <InfoTip>{tip}</InfoTip>}</h2>
{actions}
</header>
)}
<div className={padded ? 'p-4' : ''}>{children}</div>
<div className={padded ? 'p-card' : ''}>{children}</div>
</section>
)
}
@@ -58,8 +56,8 @@ const TONE = { success: 'text-success-ink', danger: 'text-danger-ink', warning:
/** A figure: a label over a value, an optional line under it, a tone for the value. */
export function Stat({ label, value, sub, tip, tone, big = false, testId }) {
return (
<div className="rounded-card border border-line bg-surface shadow-raised p-4 grid gap-1 content-start" data-testid={testId}>
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3 flex items-center gap-1">{label}{tip && <InfoTip>{tip}</InfoTip>}</span>
<div className="rounded-card border border-line bg-surface shadow-raised p-card grid gap-1 content-start" data-testid={testId}>
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3 flex items-center gap-1">{label}{tip && <InfoTip>{tip}</InfoTip>}</span>
<span className={cx('font-semibold tabular-nums', big ? 'text-display' : 'text-title', TONE[tone] ?? 'text-ink')}>{value}</span>
{sub && <span className="text-caption text-ink-2">{sub}</span>}
</div>
@@ -94,7 +92,7 @@ export function Table({ columns, rows, initialSort, onRow, rowTestId, limit = 20
<thead>
<tr className="bg-surface-2 text-ink-2">
{columns.map(c => (
<th key={c.key} className={cx('px-3 py-2 font-semibold whitespace-nowrap', c.align === 'right' ? 'text-right' : 'text-left')}>
<th key={c.key} className={cx('px-4 py-2.5 align-middle font-semibold whitespace-nowrap', c.align === 'right' ? 'text-right' : 'text-left')}>
{c.sort === false ? c.label : (
<button type="button" className="inline-flex items-center gap-1 hover:text-ink" onClick={() => flip(c)}>
{c.label}{sort?.key === c.key && (sort.dir === 'desc' ? <ArrowDown size={12} /> : <ArrowUp size={12} />)}
@@ -110,7 +108,7 @@ export function Table({ columns, rows, initialSort, onRow, rowTestId, limit = 20
<tr key={rowKey(r)} onClick={onRow ? () => onRow(r) : undefined} data-testid={rowTestId}
className={cx(onRow && 'cursor-pointer hover:bg-surface-2')}>
{columns.map(c => (
<td key={c.key} className={cx('px-3 py-2 align-top', c.align === 'right' && 'text-right tabular-nums')}>{c.render ? c.render(r) : r[c.key]}</td>
<td key={c.key} className={cx('px-4 py-2.5 align-middle', c.align === 'right' && 'text-right tabular-nums')}>{c.render ? c.render(r) : r[c.key]}</td>
))}
</tr>
))}
@@ -10,7 +10,7 @@ import toast from 'react-hot-toast'
import { ChevronLeft, ChevronRight, Plus, Settings2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, IconButton, Spinner, cx } from '@xenia/ui'
import { Button, EmptyState, IconButton, Page, Spinner, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import ShiftDialog from './ShiftDialog'
@@ -53,8 +53,7 @@ export default function SchedulePage() {
const dateLabel = d => fmt.formatDateTime(`${d}T12:00:00Z`, { day: '2-digit', month: '2-digit' })
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="schedule-page">
<div className="max-w-7xl mx-auto grid gap-4">
<Page testId="schedule-page">
<header className="flex flex-wrap items-center gap-3">
<div className="flex-1 min-w-0">
<h1 className="text-title font-semibold text-ink">{t('schedule.title')}</h1>
@@ -139,14 +138,13 @@ export default function SchedulePage() {
<span key={s} className="inline-flex items-center gap-1.5"><span className={cx('w-4 h-3 rounded-sm border', STATE[s])} aria-hidden="true" />{t(`schedule.legend.${s}`)}</span>
))}
</div>
</div>
{editing && <ShiftDialog people={people} scheduled={scheduled} {...editing}
onClose={() => setEditing(null)} onDelete={id => { remove.mutate(id); setEditing(null) }}
onSaved={() => { setEditing(null); qc.invalidateQueries({ queryKey: ['schedule-week'] }) }} />}
{settings && <ViewDialog view={view} onClose={() => setSettings(false)}
onSave={next => { if (next.mondayFirst !== view.mondayFirst) setStart(weekStartOf(start, next.mondayFirst)); setView(next); setSettings(false) }} />}
</div>
</Page>
)
}
@@ -7,7 +7,7 @@ import toast from 'react-hot-toast'
import { Monitor, Plus, Smartphone } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Field, Input, Select, Spinner } from '@xenia/ui'
import { Button, Dialog, EmptyState, Field, Input, Page, Select, Spinner } from '@xenia/ui'
import * as api from './signageApi'
import PlaylistEditor from './PlaylistEditor'
import SchedulesTab from './SchedulesTab'
@@ -29,7 +29,7 @@ export default function SignagePage() {
useEffect(() => { load().then(l => { if (l?.length) setCurrent(c => c ?? l[0].id) }) }, [load])
return (
<div className="p-4 md:p-6 grid gap-5 max-w-7xl" data-testid="signage-page">
<Page testId="signage-page">
<header className="grid gap-1">
<h1 className="text-heading font-semibold text-ink">{t('signage.pageTitle')}</h1>
<p className="text-body text-ink-2 max-w-3xl">{t('signage.intro')}</p>
@@ -79,7 +79,7 @@ export default function SignagePage() {
{creating && <NewPlaylist onClose={() => setCreating(false)} onCreate={async body => {
try { const p = await api.createPlaylist(body); setCreating(false); await load(); setCurrent(p.id) } catch (err) { toast.error(errorMessage(err, t)) }
}} />}
</div>
</Page>
)
}
@@ -7,7 +7,7 @@ import { Link } from 'react-router-dom'
import { ShieldCheck } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useTranslation, useFormat } from '@xenia/i18n'
import { Button, EmptyState, Spinner } from '@xenia/ui'
import { Button, EmptyState, Page, Spinner } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { approvalState, approvalTarget, permLabelKey } from './permissionsLogic'
@@ -29,7 +29,7 @@ export default function ApprovalsPage() {
if (!rows) return <div className="p-8 flex justify-center"><Spinner /></div>
return (
<div className="p-6 lg:p-8 max-w-6xl grid gap-6">
<Page>
<p className="text-body text-ink-2 max-w-2xl">{t('approvals.intro')}</p>
{rows.length === 0
? <EmptyState icon={<ShieldCheck />} title={t('approvals.empty')} description={t('approvals.emptyBody')} />
@@ -68,6 +68,6 @@ export default function ApprovalsPage() {
</table>
</div>
)}
</div>
</Page>
)
}
@@ -10,7 +10,7 @@ import { LogIn } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useAccess } from '@xenia/access'
import { useTranslation, useFormat } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Spinner } from '@xenia/ui'
import { Button, Dialog, EmptyState, Page, Spinner } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { canEndSession } from './permissionsLogic'
@@ -48,7 +48,7 @@ export default function SessionsPage() {
const live = rows.filter(s => !s.ended_at)
return (
<div className="p-6 lg:p-8 max-w-6xl grid gap-6">
<Page>
<p className="text-body text-ink-2 max-w-2xl">{t('sessions.intro')}</p>
{live.length === 0 && !showEnded
@@ -100,7 +100,7 @@ export default function SessionsPage() {
<EndDialog session={ending} name={person(ending)} where={where(ending)} onClose={() => setEnding(null)}
onDone={() => { setEnding(null); toast.success(t('sessions.ended', { name: person(ending) })); load() }} />
)}
</div>
</Page>
)
}
@@ -10,7 +10,7 @@ import { Ban, CheckCircle2, KeyRound, LockKeyhole, MapPin, Pencil, Plus, Search,
import { useAccess } from '@xenia/access'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, IconButton, Input, Select, Spinner, cx } from '@xenia/ui'
import { Button, Dialog, EmptyState, IconButton, Input, Page, Select, Spinner, cx } from '@xenia/ui'
import client from '../../api/client'
import { useLiveQuery } from '../../live/useLiveQuery'
import { Avatar, Pill } from '../overview/parts'
@@ -45,8 +45,7 @@ export default function StaffPage() {
const open = (kind, member = null) => setDialog({ kind, member })
return (
<div className="h-full overflow-y-auto p-4 lg:p-6" data-testid="staff-page">
<div className="max-w-6xl mx-auto grid gap-4">
<Page testId="staff-page">
<header className="flex flex-wrap items-center gap-3">
<div className="flex-1 min-w-0">
<h1 className="text-title font-semibold text-ink">{t('staff.title')}</h1>
@@ -124,7 +123,6 @@ export default function StaffPage() {
})}
</ul>
)}
</div>
{(dialog?.kind === 'new' || dialog?.kind === 'edit') && (
<StaffDialog member={dialog.member} onClose={() => setDialog(null)} onSaved={() => { setDialog(null); changed() }} />
@@ -142,6 +140,6 @@ export default function StaffPage() {
<Button variant="danger" loading={remove.isPending} onClick={() => remove.mutate(dialog.member)} data-testid="staff-delete-confirm">{t('staff.deleteYes')}</Button>
</>} />
)}
</div>
</Page>
)
}
@@ -48,7 +48,7 @@ export default function ProfileDialog({ onClose }) {
<Field label={t('profile.username')} error={err('username')}><Input value={f.username} autoCapitalize="none" autoComplete="off" onChange={e => set('username', e.target.value)} /></Field>
</div>
<fieldset className="grid gap-3 rounded-card bg-surface-2 p-3">
<legend className="text-caption font-semibold uppercase tracking-wide text-ink-3 px-1">{t('profile.password')}</legend>
<legend className="text-overline font-semibold uppercase tracking-wide text-ink-3 px-1">{t('profile.password')}</legend>
<p className="text-label text-ink-2 -mt-1">{t('profile.keepHint')}</p>
<Field label={t('profile.current')} error={err('current')}><Input type="password" autoComplete="current-password" value={f.current} onChange={e => set('current', e.target.value)} /></Field>
<div className="grid gap-3 sm:grid-cols-2">
@@ -57,7 +57,7 @@ export default function ProfileDialog({ onClose }) {
</div>
</fieldset>
<fieldset className="grid gap-3 rounded-card bg-surface-2 p-3">
<legend className="text-caption font-semibold uppercase tracking-wide text-ink-3 px-1">{t('profile.pin')}</legend>
<legend className="text-overline font-semibold uppercase tracking-wide text-ink-3 px-1">{t('profile.pin')}</legend>
<p className="text-label text-ink-2 -mt-1">{t('profile.pinHint')}</p>
<div className="grid gap-3 sm:grid-cols-2">
<Field label={t('profile.newPin')} error={err('pin')}><Input type="password" inputMode="numeric" autoComplete="new-password" value={f.pin} onChange={e => set('pin', digits(e.target.value))} data-testid="profile-pin" /></Field>
+2 -3
View File
@@ -17,7 +17,7 @@ import {
BookUser, Users, Receipt, CreditCard,
Package, TableProperties, UserCog, CalendarDays, Trash2, Boxes,
BarChart2, TrendingUp, Users2, ShoppingCart, Tag, Activity, Printer, ConciergeBell, FileText,
AppWindow, Settings, CookingPot, Truck, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, QrCode, Images, Tv,
AppWindow, Settings, CookingPot, StickyNote, Percent, Plug, BadgeCheck, MonitorSmartphone, LogIn, ShieldCheck, Images, Tv,
} from 'lucide-react'
const DASH = 'core.dashboard.access'
@@ -31,8 +31,7 @@ export const NAV = [
{ to: '/dashboard', icon: LayoutDashboard, label: 'nav.dashboard', module: 'core', perm: DASH },
{ to: '/tables', icon: LayoutGrid, label: 'nav.tables', module: 'ordering', perm: DASH },
{ to: '/online-orders', icon: ShoppingBag, label: 'nav.onlineOrders', module: 'connect_orders', perm: DASH, badge: 'onlineOrders' },
{ to: '/online/fees', icon: Truck, label: 'nav.deliveryFees', module: 'connect_orders', perm: 'connect_orders.fees' },
{ to: '/online/qr', icon: QrCode, label: 'nav.qrCodes', module: 'connect_menu', perm: 'connect_menu.manage' },
// 2026-11-20: delivery fees are Online orders → Settings, the QR codes a view of Tables
],
},
{
+3
View File
@@ -36,6 +36,8 @@ test('a payment is above zero and no more than what is due', () => {
test('filters, totals, late ones and what each supplier is owed', () => {
assert.deepEqual(filterExpenses(expenses, { status: 'unpaid' }).map(e => e.id), [1, 3])
assert.deepEqual(filterExpenses(expenses, { category: 'rent' }).map(e => e.id), [2])
assert.deepEqual(filterExpenses(expenses, { status: ['due', 'partial'] }).map(e => e.id), [1, 3]) // multi-select
assert.deepEqual(filterExpenses(expenses, { status: [], category: ['rent', 'supplier'] }).map(e => e.id), [1, 2, 3])
assert.deepEqual(filterExpenses(expenses, { q: 'nikos tins' }).map(e => e.id), [3])
assert.deepEqual(filterExpenses(expenses, { q: 'γάλα' }).map(e => e.id), [1])
assert.equal(isLate(expenses[0], '2026-11-19', key), true)
@@ -51,6 +53,7 @@ test('a contact: name needed, a wrong e-mail caught, empty fields cleared', () =
assert.deepEqual(contactBody({ ...f, name: ' Dairy ', phone: ' ' }), { name: 'Dairy', type: 'supplier', phone: null, email: null, address: null, notes: null })
const list = [{ id: 1, name: 'Dairy Nikos', type: 'supplier', phone: '2310' }, { id: 2, name: 'DEH', type: 'utility' }]
assert.deepEqual(filterContacts(list, { type: 'utility' }).map(c => c.id), [2])
assert.deepEqual(filterContacts(list, { type: ['utility', 'supplier'] }).map(c => c.id), [1, 2])
assert.deepEqual(filterContacts(list, { q: '2310' }).map(c => c.id), [1])
})
+2
View File
@@ -50,6 +50,8 @@ test('tables: filters by state and zone, flags per table, where a card goes', ()
assert.deepEqual(filterCards(cards, { states: ['free'] }).map(c => c.table.id), [2, 3])
assert.deepEqual(filterCards(cards, { zone: NO_ZONE }).map(c => c.table.id), [2])
assert.deepEqual(filterCards(cards, { zone: '11', states: ['free'] }).map(c => c.table.id), [3])
assert.deepEqual(filterCards(cards, { zones: ['10', NO_ZONE] }).map(c => c.table.id), [1, 2]) // several zones at once
assert.deepEqual(filterCards(cards, { zones: [] }).map(c => c.table.id), [1, 2, 3])
assert.deepEqual(flagsByTable([{ id: 1, name: 'VIP' }], [{ flag_id: 1, table_id: 2, assigned_at: 'x' }, { flag_id: 9, table_id: 2 }]), { 2: [{ id: 1, name: 'VIP', assigned_at: 'x' }] })
assert.equal(cardTarget(cards[0]), '/orders/7')
assert.equal(cardTarget(cards[1]), '/orders/new?table=2')
+7 -3
View File
@@ -952,7 +952,8 @@
"tab": {
"incoming": "Εισερχόμενες",
"active": "Ενεργές",
"history": "Ιστορικό"
"history": "Ιστορικό",
"settings": "Ρυθμίσεις"
},
"refresh": "Ανανέωση",
"empty": {
@@ -1664,7 +1665,8 @@
"card": "Κάρτα",
"transfer": "Τρ. μεταφορά",
"treat": "Κεράστηκε",
"other": "Άλλο"
"other": "Άλλο",
"onTab": "Σε καρτέλες"
},
"tables": {
"title": "Τραπέζια τώρα",
@@ -2718,7 +2720,9 @@
"seats_other": "{{count}} θέσεις",
"noWaiter": "Χωρίς σερβιτόρο",
"view": "Άνοιγμα",
"take": "Νέα παραγγελία"
"take": "Νέα παραγγελία",
"viewAs": "Προβολή",
"qrCodes": "Κωδικοί QR"
},
"quick": {
"title": "Τραπέζι {{table}}: γρήγορες ενέργειες",
+7 -3
View File
@@ -952,7 +952,8 @@
"tab": {
"incoming": "New",
"active": "In progress",
"history": "History"
"history": "History",
"settings": "Settings"
},
"refresh": "Refresh",
"empty": {
@@ -1664,7 +1665,8 @@
"card": "Card",
"transfer": "Bank transfer",
"treat": "On the house",
"other": "Other"
"other": "Other",
"onTab": "On tabs"
},
"tables": {
"title": "Tables now",
@@ -2718,7 +2720,9 @@
"seats_other": "{{count}} seats",
"noWaiter": "No waiter",
"view": "Open",
"take": "Take an order"
"take": "Take an order",
"viewAs": "View as",
"qrCodes": "QR codes"
},
"quick": {
"title": "Table {{table}}: quick actions",
+7 -4
View File
@@ -518,9 +518,9 @@ try {
ooUrls.some(u => u.startsWith('/api/connect/orders')) && !ooUrls.some(u => u.startsWith('/api/stream')), [...new Set(ooUrls)].filter(u => u.startsWith('/api/')).join(' '))
// ── phase 3S S.3: delivery areas and fees, set up and tested on the real page ──
await page.goto(`${APP}/online/fees`)
r.check('fees: the page opens from the nav entry, no rules yet', await page.getByTestId('fees-page').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false)
&& await page.locator('a[href="/online/fees"]').count() >= 1 && await page.getByTestId('rule').count() === 0)
await page.goto(`${APP}/online/fees`) // the old address leads to Online orders → Settings (2026-11-20)
r.check('fees: Online orders → Settings opens, no rules yet', await page.getByTestId('fees-page').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false)
&& await page.getByTestId('online-tab-settings').getAttribute('aria-selected') === 'true' && await page.getByTestId('rule').count() === 0)
r.check('ordering link: the venue\'s ordering app address is shown, with its QR code', await page.getByTestId('ordering-link').count() === 1
&& (await page.getByTestId('ordering-link-url').textContent()).endsWith('/order/test-site-1') && await page.getByTestId('ordering-link').locator('svg').count() >= 1)
await page.getByTestId('area-add').click()
@@ -1412,7 +1412,10 @@ try {
const gone = await milkRow.waitFor({ state: 'detached', timeout: 8000 }).then(() => true).catch(() => false)
milk = (await api('GET', '/api/expenses/', { token: boss })).find(e => e.id === milk.id)
r.check(`${fi} the rest paid: it shows paid and leaves the "not fully paid" list`, gone && milk.status === 'paid' && milk.payments.length === 2, JSON.stringify(milk))
await page.getByTestId('expenses-status').selectOption('paid')
// the status filter is the shared multi-select (2026-11-20): add Paid to Due + Partly paid
await page.getByTestId('expenses-status').click()
await page.locator('.x-dropdown__option', { hasText: 'Paid' }).filter({ hasNotText: 'Partly' }).click()
await page.keyboard.press('Escape')
await page.locator('[data-testid="expense-row"]', { hasText: 'E2E milk November' }).click()
r.check(`${fi} the expense opens with its two payments`, await page.getByTestId('expense-view').waitFor({ timeout: 8000 }).then(() => true).catch(() => false)
&& await page.locator('[data-testid="expense-view"] li').count() === 2)
+115
View File
@@ -0,0 +1,115 @@
// The page rule (2026-11-20): every manager page is a <Page> that scrolls on its own, fills a
// 1080p screen and stays at 16:9 width, centred, on an ultrawide. For each page, at 1920×1080
// and 3440×1440: the page body exists, fills the content area (1080p) or is capped and centred
// (ultrawide), and the page scrolls when its content is taller than the screen. Screenshots of a
// few key screens (and the open dropdowns / the day summary) go to out/manager-layout/.
//
// node manager_layout.mjs
//
// Starts its own backend (:8067, demo data) and the manager (:5191).
import { mkdirSync, openSync } from 'node:fs'
import path from 'node:path'
import { spawn } from 'node:child_process'
import { chromium } from 'playwright'
import { BROWSER_CHANNEL, CS, OUT, reporter, sleep } from './lib/env.mjs'
import { killTree, login, startBackend, waitHttp } from './lib/proc.mjs'
const DIR = path.join(OUT, 'manager-layout')
mkdirSync(DIR, { recursive: true })
// pages on <Page> (the rest have their own layout: products, tables set-up, stock placeholder)
const PAGES = [
'dashboard', 'tables', 'tables?view=qr', 'online-orders', 'online-orders?tab=settings', 'crm/contacts', 'crm/customers',
'financials/expenses', 'financials/tabs', 'management/media', 'management/signage', 'management/staff', 'management/sessions',
'management/approvals', 'management/schedule', 'management/prep-zones', 'management/pricing', 'inventory/throwaways', 'notes',
'reports/today', 'reports/store', 'devices', 'license', 'apps', 'settings?tab=operation',
]
const SHOTS = ['dashboard', 'tables', 'tables?view=qr', 'online-orders?tab=settings', 'crm/contacts', 'crm/customers', 'financials/expenses']
const SCREENS = [{ id: '1080p', width: 1920, height: 1080 }, { id: 'ultrawide', width: 3440, height: 1440 }]
const MODULES = ['connect_orders', 'connect_menu', 'crm', 'tabs', 'expenses', 'inventory', 'notes', 'chat', 'reservations', 'pricing', 'signage', 'staff_planning']
const backend = await startBackend({ port: 8067, siteId: 'test-site-1', env: { LICENSE_MODE: 'off' } })
const APP = 'http://localhost:5191'
const log = openSync(path.join(OUT, 'vite-5191.log'), 'w')
const vite = spawn('npx', ['vite', '--port', '5191', '--strictPort'], {
cwd: path.join(CS, 'manager_dashboard'), shell: process.platform === 'win32', detached: process.platform !== 'win32',
stdio: ['ignore', log, log], env: { ...process.env, XENIA_BACKEND: backend.url },
})
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
const r = reporter('manager layout (the page rule): fills 1080p, 16:9 and centred on ultrawides, scrolls')
const name = p => p.replace(/[/?=]/g, '-')
try {
await waitHttp(APP)
const boss = await login(backend.url)
const call = (method, url, body) => fetch(`${backend.url}${url}`, { method, headers: { 'content-type': 'application/json', authorization: `Bearer ${boss}` }, body: body ? JSON.stringify(body) : undefined })
for (const m of MODULES) await call('PUT', `/api/platform/modules/${m}`, { enabled: true }).catch(() => {})
await call('POST', '/api/business-day/open', {}).catch(() => {})
const errors = []
for (const screen of SCREENS) {
const ctx = await browser.newContext({ viewport: { width: screen.width, height: screen.height } })
const page = await ctx.newPage()
page.on('pageerror', e => errors.push(String(e)))
await page.goto(`${APP}/login`)
await page.getByTestId('login-form').waitFor({ timeout: 60_000 })
if (!(await page.getByTestId('login-account').count())) await page.getByLabel('Username').fill('manager')
await page.getByLabel('Password').fill('password')
await page.getByRole('button', { name: 'Sign in', exact: true }).click()
await page.waitForURL(u => u.pathname === '/dashboard', { timeout: 20_000 })
const bad = []
for (const p of PAGES) {
await page.goto(`${APP}/${p}`)
await page.waitForLoadState('networkidle').catch(() => {})
await sleep(500)
const m = await page.evaluate(() => {
const body = document.querySelector('main .x-page__body')
const main = document.querySelector('main')
if (!body || !main) return null
const b = body.getBoundingClientRect(); const a = main.getBoundingClientRect()
const scroll = body.closest('.x-page__scroll')
// a form page (settings) is centred at its own width
const form = body.classList.contains('x-page__body--form')
return { form, left: b.left - a.left, right: a.right - b.right, width: b.width, area: a.width, cap: Math.max(1280, innerHeight * 16 / 9),
scrolls: scroll.scrollHeight <= scroll.clientHeight + 1 || getComputedStyle(scroll).overflowY === 'auto' }
})
if (!m) { bad.push(`${p}: no <Page>`); continue }
const centred = Math.abs(m.left - m.right) <= 2
const fills = m.form || m.width >= Math.min(m.area, m.cap) - 2
if (!centred || !fills || !m.scrolls) bad.push(`${p}: ${JSON.stringify(m)}`)
if (SHOTS.includes(p)) await page.screenshot({ path: path.join(DIR, `${name(p)}-${screen.id}.png`) })
}
r.check(`${screen.id}: every page fills its area up to 16:9, centred, and scrolls`, bad.length === 0, bad.join('\n'))
if (screen.id === '1080p') {
// the shared dropdown: multi-select, same height as the search box
await page.goto(`${APP}/financials/expenses`)
const search = page.locator('.x-search input')
await search.waitFor()
const hs = await search.boundingBox()
const dd = page.getByTestId('expenses-status')
const hd = await dd.boundingBox()
r.check('expenses: dropdowns are as tall as the search box', Math.abs(hs.height - hd.height) < 1, `${hs.height} vs ${hd.height}`)
await dd.click()
await page.locator('.x-dropdown__menu').waitFor()
await page.screenshot({ path: path.join(DIR, 'expenses-dropdown-open.png') })
await page.keyboard.press('Escape')
// the day summary
await page.goto(`${APP}/dashboard`)
await page.getByTestId('day-stats').click()
await page.getByTestId('day-summary').waitFor()
await sleep(400)
const tabsScroll = await page.evaluate(() => { const l = document.querySelector('.x-dialog .x-tabs__list'); return l.scrollHeight - l.clientHeight })
r.check('day summary: the tab strip has no up/down scroll', tabsScroll === 0, String(tabsScroll))
await page.screenshot({ path: path.join(DIR, 'day-summary.png') })
await page.getByTestId('day-tab-staff').click()
await sleep(300)
await page.screenshot({ path: path.join(DIR, 'day-summary-staff.png') })
}
await ctx.close()
}
r.check('no page errors', errors.length === 0, errors.slice(0, 3).join(' | '))
console.log(` screenshots: ${DIR}`)
} finally {
await browser.close()
killTree(vite)
await backend.stop()
}
process.exit(r.done() ? 1 : 0)
+1 -1
View File
@@ -23,7 +23,7 @@ const LOOKS = [
...(extra ? [{ id: 'nord-light', mode: 'light', palette: 'nord', style: 'sharp' }, { id: 'nord-dark', mode: 'dark', palette: 'nord', style: 'sharp' }] : []),
]
const PAGES = [
'dashboard', 'tables', 'online-orders', 'online/fees', 'online/qr', 'crm/contacts', 'crm/customers', 'financials/expenses', 'financials/tabs',
'dashboard', 'tables', 'online-orders', 'online-orders?tab=settings', 'tables?view=qr', 'crm/contacts', 'crm/customers', 'financials/expenses', 'financials/tabs',
'management/products', 'management/media', 'management/signage', 'management/tables', 'management/staff', 'management/sessions',
'management/approvals', 'management/schedule', 'management/prep-zones', 'management/pricing', 'inventory/throwaways', 'inventory/stock', 'notes',
'reports/today', 'reports/store', 'reports/staff', 'reports/products', 'reports/prep-zones', 'reports/expenses', 'reports/technical', 'reports/misc',