Scaffold custom reports app (LXC 122 · /reports)

Framework for categorised custom reports pulling from NewBook, ResOS,
SambaPOS, and internal data. Report tree with collapsible categories
and subcategories; date-range params; run-audit log in reports_db.

Initial reports: NewBook arrivals/departures/stayovers/bookings-by-source,
ResOS covers/revenue, SambaPOS sales-summary/top-products, internal run-history.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-06 12:58:19 +00:00
commit 0511ac8d82
31 changed files with 1818 additions and 0 deletions

27
frontend/src/api.ts Normal file
View file

@ -0,0 +1,27 @@
import type { ReportMeta, ReportResult } from './types'
const BASE = '/reports/api'
async function request<T>(path: string, opts: RequestInit = {}): Promise<T> {
const res = await fetch(`${BASE}${path}`, {
credentials: 'include',
headers: { 'Content-Type': 'application/json', ...opts.headers },
...opts,
})
if (!res.ok) {
const err = await res.json().catch(() => ({ error: res.statusText }))
throw new Error((err as { error?: string }).error || `Request failed: ${res.status}`)
}
return res.json()
}
export function fetchReports(): Promise<ReportMeta[]> {
return request('/reports')
}
export function runReport(id: string, dateFrom: string, dateTo: string): Promise<ReportResult> {
return request(`/reports/${encodeURIComponent(id)}/run`, {
method: 'POST',
body: JSON.stringify({ dateFrom, dateTo }),
})
}