feat(manager): every report on the shared controls (one toolbar height, modern dropdowns, shared tabs)

- The period: one toolbar (range / day as a Segmented, dates, quick choices, the report's own
  filters and export / print on the right), every control 44 px; the business day a searchable
  Dropdown.
- Report filters (person, category, status, waiter, table, printer) are the shared Dropdown;
  export / print buttons as tall as the rest; trends' step a Segmented.
- A report's tabs are the shared tab strip above the page; a day's and an order's sections too.
- e2e: the floor editor's edge '+' and the layout check cover products, tables set-up and the
  channel prices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 15:27:07 +02:00
co-authored by Claude Opus 5.5
parent 244e93f827
commit 9021373a6b
13 changed files with 71 additions and 93 deletions
@@ -4,7 +4,7 @@
// The period is filtered by the server (venue dates, 6.13a); categories / statuses are `finance.*` texts. // The period is filtered by the server (venue dates, 6.13a); categories / statuses are `finance.*` texts.
import { useState } from 'react' import { useState } from 'react'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, Select } from '@xenia/ui' import { Button, Dialog, Dropdown } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { Pill } from '../../overview/parts' import { Pill } from '../../overview/parts'
@@ -51,10 +51,10 @@ function Expenses() {
] ]
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} allowDay={false} right={<span className="flex gap-2 items-end"> <PeriodPicker value={period} onChange={setPeriod} allowDay={false} right={<span className="flex flex-wrap gap-2 items-center">
<Select size="sm" value={status} onChange={e => setStatus(e.target.value)} aria-label={t('reports.status')} <Dropdown value={status} onChange={v => setStatus(v)} aria-label={t('reports.status')}
options={[{ value: '', label: t('reports.store.anyStatus') }, ...['due', 'partial', 'paid'].map(s => ({ value: s, label: t(`finance.status.${s}`) }))]} /> options={[{ value: '', label: t('reports.store.anyStatus') }, ...['due', 'partial', 'paid'].map(s => ({ value: s, label: t(`finance.status.${s}`) }))]} />
<Select size="sm" value={category} onChange={e => setCategory(e.target.value)} aria-label={t('reports.prod.category')} <Dropdown value={category} onChange={v => setCategory(v)} aria-label={t('reports.prod.category')}
options={[{ value: '', label: t('reports.prod.allCategories') }, ...CATEGORIES.map(c => ({ value: c, label: catName(c) }))]} /> options={[{ value: '', label: t('reports.prod.allCategories') }, ...CATEGORIES.map(c => ({ value: c, label: catName(c) }))]} />
</span>} /> </span>} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<> {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
@@ -65,7 +65,7 @@ function Expenses() {
</div> </div>
{groups.length > 0 && ( {groups.length > 0 && (
<Panel title={t('reports.exp.split')} actions={<span className="flex gap-1">{['category', 'supplier'].map(s => ( <Panel title={t('reports.exp.split')} actions={<span className="flex gap-1">{['category', 'supplier'].map(s => (
<Button key={s} size="sm" variant={split === s ? 'primary' : 'ghost'} onClick={() => setSplit(s)}>{t(`reports.exp.by.${s}`)}</Button>))}</span>}> <Button key={s} size="sm" variant={split === s ? 'secondary' : 'ghost'} aria-pressed={split === s} onClick={() => setSplit(s)}>{t(`reports.exp.by.${s}`)}</Button>))}</span>}>
<BarList testId="expenses-split" format={v => fmt.formatMoney(v)} rows={groups.map(g => ({ ...g, sub: g.due ? t('reports.exp.dueSub', { amount: fmt.formatMoney(g.due) }) : undefined }))} /> <BarList testId="expenses-split" format={v => fmt.formatMoney(v)} rows={groups.map(g => ({ ...g, sub: g.due ? t('reports.exp.dueSub', { amount: fmt.formatMoney(g.due) }) : undefined }))} />
</Panel> </Panel>
)} )}
@@ -5,7 +5,7 @@ import { useState } from 'react'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
import { ArrowRight } from 'lucide-react' import { ArrowRight } from 'lucide-react'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog } from '@xenia/ui' import { Button, Dialog, Tabs } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { AuditList, PriceEventList } from '../../orders/OrderHistory' import { AuditList, PriceEventList } from '../../orders/OrderHistory'
@@ -41,9 +41,7 @@ export default function OrderDialog({ order: summary, onClose }) {
<Button variant="ghost" iconEnd={<ArrowRight size={16} />} onClick={() => navigate(`/orders/${summary.id}`)}>{t('reports.openOrder')}</Button> <Button variant="ghost" iconEnd={<ArrowRight size={16} />} onClick={() => navigate(`/orders/${summary.id}`)}>{t('reports.openOrder')}</Button>
</>}> </>}>
<div className="grid gap-3" data-testid="report-order-dialog"> <div className="grid gap-3" data-testid="report-order-dialog">
<span className="flex gap-1" role="tablist"> <Tabs value={tab} onChange={setTab} tabs={TABS.map(k => ({ id: k, label: t(`reports.orderTabs.${k}`) }))} />
{TABS.map(k => <Button key={k} size="sm" variant={tab === k ? 'primary' : 'ghost'} role="tab" aria-selected={tab === k} onClick={() => setTab(k)}>{t(`reports.orderTabs.${k}`)}</Button>)}
</span>
{!order ? <Loading /> : tab === 'lines' ? <OrderLines order={order} open={false} priceEvents={events} onPay={() => {}} onChanged={() => {}} /> {!order ? <Loading /> : tab === 'lines' ? <OrderLines order={order} open={false} priceEvents={events} onPay={() => {}} onChanged={() => {}} />
: tab === 'prices' ? <PriceEventList events={events} /> : <AuditList order={order} />} : tab === 'prices' ? <PriceEventList events={events} /> : <AuditList order={order} />}
</div> </div>
@@ -1,15 +1,15 @@
// The period a report covers (plan step 6.12a): dates (from – to, with quick choices) or one // The period a report covers (plan step 6.12a): dates (from – to, with quick choices) or one
// business day. Dates are venue calendar days; the backend reads them in venue time. // business day. Dates are venue calendar days; the backend reads them in venue time.
import { useId } from 'react' // 2026-11-20: one toolbar (the shared controls, one height): range / day, the dates, the quick
// choices, then what the report adds on the right (filters, export, print).
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Input, Select } from '@xenia/ui' import { Button, Dropdown, Input, Segmented, Toolbar, ToolbarSpacer } from '@xenia/ui'
import { dayChoices, quickRange, rangeProblem } from './reportLogic' import { dayChoices, quickRange, rangeProblem } from './reportLogic'
import { useBusinessDays } from './useBusinessDays' import { useBusinessDays } from './useBusinessDays'
export function PeriodPicker({ value, onChange, allowDay = true, right }) { export function PeriodPicker({ value, onChange, allowDay = true, right }) {
const { t } = useTranslation('manager') const { t } = useTranslation('manager')
const fmt = useFormat() const fmt = useFormat()
const id = useId()
const today = fmt.venueToday() const today = fmt.venueToday()
const { data: days = [] } = useBusinessDays() const { data: days = [] } = useBusinessDays()
const set = patch => onChange({ ...value, ...patch }) const set = patch => onChange({ ...value, ...patch })
@@ -17,38 +17,33 @@ export function PeriodPicker({ value, onChange, allowDay = true, right }) {
const dayLabel = d => `${fmt.formatDateTime(d.opened_at, 'datetimeShort')}${d.status === 'open' ? ` · ${t('reports.open')}` : ''}` const dayLabel = d => `${fmt.formatDateTime(d.opened_at, 'datetimeShort')}${d.status === 'open' ? ` · ${t('reports.open')}` : ''}`
return ( return (
<div className="rounded-card border border-line bg-surface shadow-raised px-4 py-3 flex flex-wrap items-end gap-3" data-testid="report-period"> <div className="rounded-card border border-line bg-surface shadow-raised px-card py-card-y grid gap-2" data-testid="report-period">
{allowDay && ( <Toolbar>
<div className="flex rounded-control border border-line overflow-hidden self-end" role="group" aria-label={t('reports.period')}> {allowDay && (
{['range', 'day'].map(m => ( <Segmented aria-label={t('reports.period')} value={value.mode}
<button key={m} type="button" aria-pressed={value.mode === m} onClick={() => set({ mode: m, dayId: m === 'day' && !value.dayId ? String(days[0]?.id ?? '') : value.dayId })} onChange={m => set({ mode: m, dayId: m === 'day' && !value.dayId ? String(days[0]?.id ?? '') : value.dayId })}
className={`px-3 py-1.5 text-label font-medium ${value.mode === m ? 'bg-accent-soft text-accent-ink' : 'bg-surface text-ink-2 hover:bg-surface-2'}`}> options={['range', 'day'].map(m => ({ value: m, label: t(`reports.modes.${m}`), testId: `period-mode-${m}` }))} />
{t(`reports.modes.${m}`)} )}
</button> {value.mode === 'range' ? (<>
))} <label className="flex items-center gap-2 text-label text-ink-2">{t('reports.from')}
</div> <Input type="date" className="w-44" value={value.from} max={today} onChange={e => set({ from: e.target.value })} data-testid="period-from" />
)} </label>
{value.mode === 'range' ? (<> <label className="flex items-center gap-2 text-label text-ink-2">{t('reports.to')}
<label className="grid gap-1 text-caption text-ink-2" htmlFor={`${id}-from`}>{t('reports.from')} <Input type="date" className="w-44" value={value.to} max={today} onChange={e => set({ to: e.target.value })} data-testid="period-to" />
<Input id={`${id}-from`} type="date" value={value.from} max={today} onChange={e => set({ from: e.target.value })} data-testid="period-from" /> </label>
</label> <span className="flex flex-wrap gap-1">
<label className="grid gap-1 text-caption text-ink-2" htmlFor={`${id}-to`}>{t('reports.to')} {['today', 'week', 'month', 'thirty'].map(k => (
<Input id={`${id}-to`} type="date" value={value.to} max={today} onChange={e => set({ to: e.target.value })} data-testid="period-to" /> <Button key={k} variant="ghost" onClick={() => set(quickRange(k, today))}>{t(`reports.quick.${k}`)}</Button>
</label> ))}
<span className="flex flex-wrap gap-1"> </span>
{['today', 'week', 'month', 'thirty'].map(k => ( </>) : (
<Button key={k} size="sm" variant="ghost" onClick={() => set(quickRange(k, today))}>{t(`reports.quick.${k}`)}</Button> <Dropdown className="min-w-64" value={value.dayId} onChange={v => set({ dayId: v })} aria-label={t('reports.businessDay')} data-testid="period-day" searchable
))} options={dayChoices(days).map(d => ({ value: String(d.id), label: dayLabel(d) }))} placeholder={days.length ? t('reports.businessDay') : t('reports.noDays')} />
</span> )}
</>) : ( <ToolbarSpacer />
<label className="grid gap-1 text-caption text-ink-2 min-w-56" htmlFor={`${id}-day`}>{t('reports.businessDay')} {right}
<Select id={`${id}-day`} value={value.dayId} onChange={e => set({ dayId: e.target.value })} data-testid="period-day" </Toolbar>
options={dayChoices(days).map(d => ({ value: String(d.id), label: dayLabel(d) }))} placeholder={days.length ? undefined : t('reports.noDays')} /> {problem && <p role="alert" className="text-label text-danger-ink">{t(`reports.rangeProblem.${problem}`)}</p>}
</label>
)}
<span className="flex-1" />
{right}
{problem && <p role="alert" className="w-full text-label text-danger-ink">{t(`reports.rangeProblem.${problem}`)}</p>}
</div> </div>
) )
} }
@@ -7,7 +7,7 @@ import toast from 'react-hot-toast'
import { ArrowDown, ArrowUp, Download, Info } from 'lucide-react' import { ArrowDown, ArrowUp, Download, Info } from 'lucide-react'
import { errorMessage } from '@xenia/api' import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, EmptyState, InfoTip, Page, Spinner, cx } from '@xenia/ui' import { Button, EmptyState, InfoTip, Page, PageHeader, Spinner, Tabs, cx } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { sortRows } from './reportLogic' import { sortRows } from './reportLogic'
@@ -17,21 +17,11 @@ export function ReportPage({ title, tabs = [], children, testId }) {
const active = tabs.find(t => t.id === params.get('tab'))?.id ?? tabs[0]?.id const active = tabs.find(t => t.id === params.get('tab'))?.id ?? tabs[0]?.id
const tab = tabs.find(t => t.id === active) const tab = tabs.find(t => t.id === active)
return ( return (
<Page testId={testId}> <Page testId={testId}
<header className="flex flex-wrap items-end gap-3"> top={tabs.length > 1 ? <Tabs size="lg" value={active} tabs={tabs.map(t => ({ id: t.id, label: t.label, testId: `report-tab-${t.id}` }))}
<h1 className="text-title font-semibold text-ink flex-1 min-w-0">{title}</h1> onChange={id => setParams(p => { const n = new URLSearchParams(p); n.set('tab', id); return n }, { replace: true })} /> : undefined}>
{tabs.length > 1 && ( <PageHeader title={title} />
<nav className="flex flex-wrap gap-1" role="tablist"> {tab ? <tab.Component key={tab.id} /> : children}
{tabs.map(t => (
<Button key={t.id} size="sm" variant={t.id === active ? 'primary' : 'ghost'} role="tab" aria-selected={t.id === active}
onClick={() => setParams(p => { const n = new URLSearchParams(p); n.set('tab', t.id); return n }, { replace: true })} data-testid={`report-tab-${t.id}`}>
{t.label}
</Button>
))}
</nav>
)}
</header>
{tab ? <tab.Component key={tab.id} /> : children}
</Page> </Page>
) )
} }
@@ -149,5 +139,5 @@ export function ExportButton({ endpoint, params, filename }) {
setTimeout(() => URL.revokeObjectURL(url), 1000) setTimeout(() => URL.revokeObjectURL(url), 1000)
} catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) } } catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) }
} }
return <Button size="sm" variant="secondary" icon={<Download size={14} />} loading={busy} onClick={run} data-testid="report-export">{t('reports.export')}</Button> return <Button variant="secondary" icon={<Download size={16} />} loading={busy} onClick={run} data-testid="report-export">{t('reports.export')}</Button>
} }
@@ -82,9 +82,9 @@ function ZoneCard({ zone: z, period }) {
{z.notification_name && <span className="text-label font-normal text-ink-2">{z.notification_name}</span>} {z.notification_name && <span className="text-label font-normal text-ink-2">{z.notification_name}</span>}
{z.printers.map(p => <Pill key={p.id}><Printer size={12} aria-hidden="true" />{p.name}</Pill>)}</span>} {z.printers.map(p => <Pill key={p.id}><Printer size={12} aria-hidden="true" />{p.name}</Pill>)}</span>}
actions={<span className="flex flex-wrap gap-1"> actions={<span className="flex flex-wrap gap-1">
<Button size="sm" variant="ghost" icon={<Download size={14} />} onClick={products} disabled={!z.all_products.length}>{t('reports.zones.productsCsv')}</Button> <Button variant="ghost" icon={<Download size={16} />} onClick={products} disabled={!z.all_products.length}>{t('reports.zones.productsCsv')}</Button>
<Button size="sm" variant="ghost" icon={<Download size={14} />} onClick={ordersCsv} disabled={!z.all_orders.length}>{t('reports.zones.ordersCsv')}</Button> <Button variant="ghost" icon={<Download size={16} />} onClick={ordersCsv} disabled={!z.all_orders.length}>{t('reports.zones.ordersCsv')}</Button>
<Button size="sm" variant="secondary" icon={<Printer size={14} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button> <Button variant="secondary" icon={<Printer size={16} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>
</span>}> </span>}>
<div className="grid gap-3 p-4 grid-cols-[repeat(auto-fill,minmax(10rem,1fr))]"> <div className="grid gap-3 p-4 grid-cols-[repeat(auto-fill,minmax(10rem,1fr))]">
<Stat label={t('reports.zones.items')} value={fmt.formatNumber(z.item_count, { maxDecimals: 3 })} /> <Stat label={t('reports.zones.items')} value={fmt.formatNumber(z.item_count, { maxDecimals: 3 })} />
@@ -5,7 +5,7 @@
import { useState } from 'react' import { useState } from 'react'
import { Printer } from 'lucide-react' import { Printer } from 'lucide-react'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Select } from '@xenia/ui' import { Button, Dropdown } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { BarList } from '../kit/charts' import { BarList } from '../kit/charts'
@@ -67,9 +67,9 @@ function ProductsTab() {
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} right={<span className="flex gap-2"> <PeriodPicker value={period} onChange={setPeriod} right={<span className="flex gap-2">
<ExportButton endpoint="/api/reports/products/export" params={params} filename={`products-${periodSlug(period)}.csv`} /> <ExportButton endpoint="/api/reports/products/export" params={params} filename={`products-${periodSlug(period)}.csv`} />
<Button size="sm" variant="secondary" icon={<Printer size={14} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button> <Button variant="secondary" icon={<Printer size={16} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>
</span>} /> </span>} />
<Select size="sm" value={category} onChange={e => setCategory(e.target.value)} aria-label={t('reports.prod.category')} className="w-64" <Dropdown value={category} onChange={v => setCategory(v)} aria-label={t('reports.prod.category')} className="w-64"
options={[{ value: '', label: t('reports.prod.allCategories') }, ...cats.flatMap(c => [c, ...(c.subcategories ?? [])]).map(c => ({ value: String(c.id), label: c.name }))]} /> options={[{ value: '', label: t('reports.prod.allCategories') }, ...cats.flatMap(c => [c, ...(c.subcategories ?? [])]).map(c => ({ value: String(c.id), label: c.name }))]} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<> {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]"> <div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]">
@@ -119,7 +119,7 @@ function CategoriesTab() {
] ]
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} right={<Button size="sm" variant="secondary" icon={<Printer size={14} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>} /> <PeriodPicker value={period} onChange={setPeriod} right={<Button variant="secondary" icon={<Printer size={16} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<> {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
{rows.length > 0 && ( {rows.length > 0 && (
<Panel title={t('reports.prod.shareTitle')}> <Panel title={t('reports.prod.shareTitle')}>
@@ -8,7 +8,7 @@ import { Trash2 } from 'lucide-react'
import { useCan } from '@xenia/access' import { useCan } from '@xenia/access'
import { errorMessage } from '@xenia/api' import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, IconButton, Select } from '@xenia/ui' import { Button, Dialog, Dropdown, IconButton } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { useDuration } from '../../overview/hooks' import { useDuration } from '../../overview/hooks'
@@ -40,7 +40,7 @@ function PersonFilter({ value, onChange }) {
const { t } = useTranslation('manager') const { t } = useTranslation('manager')
const { data: people = [] } = usePeople() const { data: people = [] } = usePeople()
return ( return (
<Select size="sm" value={value} onChange={e => onChange(e.target.value)} aria-label={t('reports.person')} className="w-56" <Dropdown value={value} onChange={v => onChange(v)} aria-label={t('reports.person')} className="w-56"
options={[{ value: '', label: t('reports.store.anyone') }, ...people.map(p => ({ value: String(p.id), label: p.name }))]} /> options={[{ value: '', label: t('reports.store.anyone') }, ...people.map(p => ({ value: String(p.id), label: p.name }))]} />
) )
} }
@@ -85,7 +85,7 @@ function ShiftsTab() {
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} <PeriodPicker value={period} onChange={setPeriod}
right={<span className="flex gap-2 items-end"><PersonFilter value={person} onChange={setPerson} /> right={<span className="flex flex-wrap gap-2 items-center"><PersonFilter value={person} onChange={setPerson} />
<ExportButton endpoint="/api/reports/shifts/export" params={params} filename={`shifts-${periodSlug(period)}.csv`} /></span>} /> <ExportButton endpoint="/api/reports/shifts/export" params={params} filename={`shifts-${periodSlug(period)}.csv`} /></span>} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : ( {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (
<Panel padded={false} title={t('reports.staff.shiftsCount', { count: rows.length })} <Panel padded={false} title={t('reports.staff.shiftsCount', { count: rows.length })}
@@ -9,7 +9,7 @@ import { Pencil, Trash2 } from 'lucide-react'
import { useCan } from '@xenia/access' import { useCan } from '@xenia/access'
import { errorMessage } from '@xenia/api' import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, IconButton, Input } from '@xenia/ui' import { Button, Dialog, IconButton, Input, Tabs } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { useDuration } from '../../overview/hooks' import { useDuration } from '../../overview/hooks'
@@ -148,13 +148,8 @@ function DayDialog({ day: initial, owner, onClose }) {
<Button size="sm" variant="ghost" onClick={() => setEditing(false)}>{t('reports.back')}</Button> <Button size="sm" variant="ghost" onClick={() => setEditing(false)}>{t('reports.back')}</Button>
</div> </div>
)} )}
<span className="flex gap-1" role="tablist"> <Tabs value={tab} onChange={setTab}
{['orders', 'shifts'].map(k => ( tabs={['orders', 'shifts'].map(k => ({ id: k, label: t(`reports.store.dayTabs.${k}`, { count: k === 'orders' ? orders.length : shifts.length }), testId: `day-tab-${k}` }))} />
<Button key={k} size="sm" variant={tab === k ? 'primary' : 'ghost'} role="tab" aria-selected={tab === k} onClick={() => setTab(k)}>
{t(`reports.store.dayTabs.${k}`, { count: k === 'orders' ? orders.length : shifts.length })}
</Button>
))}
</span>
{(tab === 'orders' ? loadingOrders : loadingShifts) ? <Loading /> : tab === 'orders' {(tab === 'orders' ? loadingOrders : loadingShifts) ? <Loading /> : tab === 'orders'
? <Table columns={orderCols} rows={orders} onRow={setOrder} limit={500} /> ? <Table columns={orderCols} rows={orders} onRow={setOrder} limit={500} />
: <Table columns={shiftCols} rows={shifts} onRow={setShift} />} : <Table columns={shiftCols} rows={shifts} onRow={setShift} />}
@@ -2,7 +2,7 @@
// waiter and table; products, delivery fee and refunds per order; a tap opens it; export. // waiter and table; products, delivery fee and refunds per order; a tap opens it; export.
import { useState } from 'react' import { useState } from 'react'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Select } from '@xenia/ui' import { Dropdown, Toolbar } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { Pill } from '../../overview/parts' import { Pill } from '../../overview/parts'
@@ -48,14 +48,14 @@ export default function OrdersTab() {
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} <PeriodPicker value={period} onChange={setPeriod}
right={<ExportButton endpoint="/api/reports/orders/export" params={params} filename={`orders-${periodSlug(period)}.csv`} />} /> right={<ExportButton endpoint="/api/reports/orders/export" params={params} filename={`orders-${periodSlug(period)}.csv`} />} />
<div className="flex flex-wrap gap-2"> <Toolbar>
<Select size="sm" value={filter.status} onChange={e => set('status', e.target.value)} aria-label={t('reports.status')} <Dropdown value={filter.status} onChange={v => set('status', v)} aria-label={t('reports.status')}
options={[{ value: '', label: t('reports.store.anyStatus') }, ...STATUSES.map(s => ({ value: s, label: t(`overview.orderStatus.${s}`) }))]} /> options={[{ value: '', label: t('reports.store.anyStatus') }, ...STATUSES.map(s => ({ value: s, label: t(`overview.orderStatus.${s}`) }))]} />
<Select size="sm" value={filter.waiter_id} onChange={e => set('waiter_id', e.target.value)} aria-label={t('reports.person')} <Dropdown value={filter.waiter_id} onChange={v => set('waiter_id', v)} aria-label={t('reports.person')}
options={[{ value: '', label: t('reports.store.anyone') }, ...waiters.map(w => ({ value: String(w.id), label: w.name }))]} /> options={[{ value: '', label: t('reports.store.anyone') }, ...waiters.map(w => ({ value: String(w.id), label: w.name }))]} />
<Select size="sm" value={filter.table_id} onChange={e => set('table_id', e.target.value)} aria-label={t('reports.place')} <Dropdown value={filter.table_id} onChange={v => set('table_id', v)} aria-label={t('reports.place')}
options={[{ value: '', label: t('reports.store.anyTable') }, ...tables.map(x => ({ value: String(x.id), label: x.group ? `${x.name} · ${x.group}` : x.name }))]} /> options={[{ value: '', label: t('reports.store.anyTable') }, ...tables.map(x => ({ value: String(x.id), label: x.group ? `${x.name} · ${x.group}` : x.name }))]} />
</div> </Toolbar>
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : ( {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (
<Panel padded={false} title={t('reports.store.ordersCount', { count: rows.length, total: fmt.formatMoney(total) })}> <Panel padded={false} title={t('reports.store.ordersCount', { count: rows.length, total: fmt.formatMoney(total) })}>
<Table columns={columns} rows={rows} onRow={setOrder} rowTestId="report-order" initialSort={{ key: 'id', dir: 'desc' }} limit={300} /> <Table columns={columns} rows={rows} onRow={setOrder} rowTestId="report-order" initialSort={{ key: 'id', dir: 'desc' }} limit={300} />
@@ -31,7 +31,7 @@ export default function TablesTab() {
] ]
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} right={<Button size="sm" variant="secondary" icon={<Printer size={14} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>} /> <PeriodPicker value={period} onChange={setPeriod} right={<Button variant="secondary" icon={<Printer size={16} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<> {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
<Panel padded={false} title={t('reports.tables.title')} tip={t('reports.tables.tip')}> <Panel padded={false} title={t('reports.tables.title')} tip={t('reports.tables.tip')}>
<Table columns={columns} rows={rows} rowKey={r => r.table_id ?? 'none'} initialSort={{ key: 'revenue', dir: 'desc' }} /> <Table columns={columns} rows={rows} rowKey={r => r.table_id ?? 'none'} initialSort={{ key: 'revenue', dir: 'desc' }} />
@@ -2,7 +2,7 @@
// dates, with the 7-day average for days; delivery fees beside the revenue. // dates, with the 7-day average for days; delivery fees beside the revenue.
import { useState } from 'react' import { useState } from 'react'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button } from '@xenia/ui' import { Button, Segmented } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { TrendChart } from '../kit/charts' import { TrendChart } from '../kit/charts'
@@ -35,7 +35,7 @@ export default function TrendsTab() {
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} allowDay={false} <PeriodPicker value={period} onChange={setPeriod} allowDay={false}
right={<span className="flex gap-1">{STEPS.map(s => <Button key={s} size="sm" variant={step === s ? 'primary' : 'ghost'} onClick={() => setStep(s)}>{t(`reports.trends.steps.${s}`)}</Button>)}</span>} /> right={<Segmented value={step} onChange={setStep} options={STEPS.map(s => ({ value: s, label: t(`reports.trends.steps.${s}`) }))} />} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<> {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
{rows.length > 1 && <Panel title={t('reports.trends.title')}><TrendChart points={rows.map(r => ({ label: label(r.date), revenue: r.revenue, profit: r.profit }))} showProfit={anyProfit} /></Panel>} {rows.length > 1 && <Panel title={t('reports.trends.title')}><TrendChart points={rows.map(r => ({ label: label(r.date), revenue: r.revenue, profit: r.profit }))} showProfit={anyProfit} /></Panel>}
<Panel padded={false} title={t('reports.trends.table')}><Table columns={columns} rows={rows} rowKey={r => r.date} initialSort={{ key: 'date', dir: 'desc' }} /></Panel> <Panel padded={false} title={t('reports.trends.table')}><Table columns={columns} rows={rows} rowKey={r => r.date} initialSort={{ key: 'date', dir: 'desc' }} /></Panel>
@@ -6,7 +6,7 @@ import { useState } from 'react'
import { Printer } from 'lucide-react' import { Printer } from 'lucide-react'
import { useCan } from '@xenia/access' import { useCan } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n' import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Select } from '@xenia/ui' import { Button, Dropdown } from '@xenia/ui'
import client from '../../../api/client' import client from '../../../api/client'
import { useLiveQuery } from '../../../live/useLiveQuery' import { useLiveQuery } from '../../../live/useLiveQuery'
import { Pill } from '../../overview/parts' import { Pill } from '../../overview/parts'
@@ -58,11 +58,11 @@ function PrintingTab() {
] ]
return ( return (
<div className="grid gap-4"> <div className="grid gap-4">
<PeriodPicker value={period} onChange={setPeriod} right={<span className="flex gap-2 items-end"> <PeriodPicker value={period} onChange={setPeriod} right={<span className="flex flex-wrap gap-2 items-center">
<Select size="sm" value={printer} onChange={e => setPrinter(e.target.value)} aria-label={t('reports.print.printer')} className="w-48" <Dropdown value={printer} onChange={v => setPrinter(v)} aria-label={t('reports.print.printer')} className="w-48"
options={[{ value: '', label: t('reports.tech.allPrinters') }, ...printers.map(p => ({ value: String(p.id), label: p.name }))]} /> options={[{ value: '', label: t('reports.tech.allPrinters') }, ...printers.map(p => ({ value: String(p.id), label: p.name }))]} />
<ExportButton endpoint="/api/reports/printers/export" params={params} filename={`printing-${periodSlug(period)}.csv`} /> <ExportButton endpoint="/api/reports/printers/export" params={params} filename={`printing-${periodSlug(period)}.csv`} />
<Button size="sm" variant="secondary" icon={<Printer size={14} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button> <Button variant="secondary" icon={<Printer size={16} />} onClick={() => setPrinting(true)}>{t('reports.print.button')}</Button>
</span>} /> </span>} />
{isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<> {isPending ? <Loading /> : error ? <Failed error={error} retry={refetch} /> : (<>
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]"> <div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]">
+1 -1
View File
@@ -1129,7 +1129,7 @@ try {
await page.mouse.move(mid.x, mid.y - 3) await page.mouse.move(mid.x, mid.y - 3)
await page.mouse.move(mid.x, mid.y, { steps: 2 }) await page.mouse.move(mid.x, mid.y, { steps: 2 })
await page.getByTestId('floor-edge-add').waitFor({ timeout: 3000 }).catch(() => {}) await page.getByTestId('floor-edge-add').waitFor({ timeout: 3000 }).catch(() => {})
r.check('floor: a "+" shows on the floor's edge under the pointer', await page.getByTestId('floor-edge-add').count() === 1) r.check('floor: a "+" shows on the edge of the floor under the pointer', await page.getByTestId('floor-edge-add').count() === 1)
await page.mouse.down() await page.mouse.down()
await page.mouse.move(mid.x - 120, mid.y + 10, { steps: 6 }) await page.mouse.move(mid.x - 120, mid.y + 10, { steps: 6 })
await page.mouse.up() await page.mouse.up()