- migration 20261018170000: pgmq badge_print/badge_print_dlq, print_stations, token-gated printer RPCs (claim/complete/fail/heartbeat), admin RPCs, welcome_checkin enqueue; badge_print_tests.sql (101 assertions) - apps/printer: Python worker (Playwright render -> brother_ql via pyusb), comitup captive-portal (Wi-Fi + HTTPS endpoint + anon key + token), arm64 image build + idempotent Pi setup/install scripts, 77 pytest - apps/admin: Printing view, station management/DLQ, global printer status pill, Print button on Registrations, standalone print renderer entry (print.html -> dist-print) with bundled fonts - docs: printing.md + architecture/schema/rpcs/tests/admin-app updates, apps/printer/AGENT.md operating manual - e2e: printing.spec.ts Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
143 lines
4.6 KiB
TypeScript
143 lines
4.6 KiB
TypeScript
import { useState } from 'react';
|
|
import { AuthProvider, useAuth } from './context/AuthContext';
|
|
import { ToastProvider } from './context/ToastContext';
|
|
import { Login } from './screens/Login';
|
|
import { Dashboard } from './views/Dashboard';
|
|
import { Contacts } from './views/Contacts';
|
|
import { Registrations } from './views/Registrations';
|
|
import { Sponsors } from './views/Sponsors';
|
|
import { Schedule } from './views/Schedule';
|
|
import { Activity } from './views/Activity';
|
|
import { Raffle } from './views/Raffle';
|
|
import { BadgeEditor } from './views/BadgeEditor';
|
|
import { Printing } from './views/Printing';
|
|
import { Events } from './views/Events';
|
|
import { Interfaces } from './views/Interfaces';
|
|
import { Reports } from './views/Reports';
|
|
import { Settings } from './views/Settings';
|
|
import { Settings as SettingsIcon } from 'lucide-react';
|
|
import { Spinner } from './components/ui';
|
|
import { PrinterStatusPill } from './components/PrinterStatusPill';
|
|
import { PrintStatusProvider } from './lib/printStatus';
|
|
|
|
export type View =
|
|
| 'dashboard'
|
|
| 'contacts'
|
|
| 'registrations'
|
|
| 'sponsors'
|
|
| 'schedule'
|
|
| 'activity'
|
|
| 'raffle'
|
|
| 'badges'
|
|
| 'printing'
|
|
| 'events'
|
|
| 'interfaces'
|
|
| 'reports'
|
|
| 'settings';
|
|
|
|
const NAV: { id: View; label: string; ico: string }[] = [
|
|
{ id: 'dashboard', label: 'Dashboard', ico: '📊' },
|
|
{ id: 'contacts', label: 'Contacts', ico: '👥' },
|
|
{ id: 'registrations', label: 'Registrations', ico: '🎟️' },
|
|
{ id: 'sponsors', label: 'Sponsors', ico: '🤝' },
|
|
{ id: 'schedule', label: 'Schedule', ico: '🗓️' },
|
|
{ id: 'activity', label: 'Activity', ico: '⚡' },
|
|
{ id: 'raffle', label: 'Raffle', ico: '🎯' },
|
|
{ id: 'badges', label: 'Badges', ico: '🎫' },
|
|
{ id: 'printing', label: 'Printing', ico: '🖨️' },
|
|
{ id: 'events', label: 'Events', ico: '📅' },
|
|
{ id: 'interfaces', label: 'Interfaces', ico: '🔌' },
|
|
{ id: 'reports', label: 'Reports', ico: '📤' },
|
|
{ id: 'settings', label: 'Settings', ico: '' },
|
|
];
|
|
|
|
function Shell() {
|
|
const { contact, loading, signOut } = useAuth();
|
|
const [view, setView] = useState<View>('dashboard');
|
|
|
|
if (loading) {
|
|
return (
|
|
<div className="loading-screen">
|
|
<Spinner />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!contact) return <Login />;
|
|
|
|
return (
|
|
<PrintStatusProvider>
|
|
<div className="app">
|
|
<aside className="sidebar">
|
|
<div className="brand">
|
|
<div className="logo"><img src="/icon-192.png" alt="APPE" /></div>
|
|
<div>
|
|
<div className="name">APPE</div>
|
|
<div className="sub">Admin</div>
|
|
</div>
|
|
</div>
|
|
<nav className="nav">
|
|
{NAV.map((n) => (
|
|
<button
|
|
key={n.id}
|
|
className={`nav-item ${view === n.id ? 'active' : ''}`}
|
|
onClick={() => setView(n.id)}
|
|
>
|
|
<span className="ico">{n.id === 'settings' ? <SettingsIcon size={19} aria-hidden="true" /> : n.ico}</span>
|
|
{n.label}
|
|
</button>
|
|
))}
|
|
</nav>
|
|
{/* Outside .sidebar-foot so it also shows on mobile (the Pi has no screen). */}
|
|
<PrinterStatusPill onNavigate={setView} />
|
|
<div className="sidebar-foot">
|
|
<div className="admin-card">
|
|
<span className="avatar" style={{ width: 36, height: 36, fontSize: 13, background: '#d50000' }}>
|
|
{contact.full_name
|
|
.split(' ')
|
|
.map((w) => w[0])
|
|
.slice(0, 2)
|
|
.join('')
|
|
.toUpperCase()}
|
|
</span>
|
|
<div className="who">
|
|
<div className="n">{contact.full_name}</div>
|
|
<div className="e">{contact.email}</div>
|
|
</div>
|
|
</div>
|
|
<button className="signout" onClick={signOut}>
|
|
Sign out
|
|
</button>
|
|
</div>
|
|
</aside>
|
|
|
|
<main className="content">
|
|
{view === 'dashboard' && <Dashboard onNavigate={setView} />}
|
|
{view === 'contacts' && <Contacts />}
|
|
{view === 'registrations' && <Registrations />}
|
|
{view === 'sponsors' && <Sponsors />}
|
|
{view === 'schedule' && <Schedule />}
|
|
{view === 'activity' && <Activity />}
|
|
{view === 'raffle' && <Raffle />}
|
|
{view === 'badges' && <BadgeEditor />}
|
|
{view === 'printing' && <Printing />}
|
|
{view === 'events' && <Events />}
|
|
{view === 'interfaces' && <Interfaces />}
|
|
{view === 'reports' && <Reports />}
|
|
{view === 'settings' && <Settings />}
|
|
</main>
|
|
</div>
|
|
</PrintStatusProvider>
|
|
);
|
|
}
|
|
|
|
export function App() {
|
|
return (
|
|
<ToastProvider>
|
|
<AuthProvider>
|
|
<Shell />
|
|
</AuthProvider>
|
|
</ToastProvider>
|
|
);
|
|
}
|