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:
@@ -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>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user