import { useState } from 'react' import { act, clearRun, toggleDark, useStore } from './store' import { Overview } from './components/Overview' import { RunPanel } from './components/RunPanel' import { Report } from './components/Report' import { Review } from './components/Review' const TABS = { dashboard: ['Dashboard', 'Overview of every batch', <>], run: ['Run', 'Live progress and log', ], review: ['Review', 'Check extracted fields against the document', <>], report: ['Report', 'Result of every processed item', <>], // OPTIONAL: admin/roles tab goes here } as const type Tab = keyof typeof TABS const DOT = { ready: 'bg-ok', done: 'bg-ok', running: 'bg-warn animate-pulse', error: 'bg-bad' } export function App() { const { status, user, dark } = useStore() const [tab, setTab] = useState('dashboard') const [unsaved, setUnsaved] = useState(0) // review edits not saved yet const show = (t: Tab) => { if (t === tab) return if (unsaved && !window.confirm(`${unsaved} unsaved change(s) on this document. Discard them and leave?`)) return setUnsaved(0) setTab(t) if (t === 'dashboard') act('load_dashboard') if (t === 'report') act('load_latest_report') } const run = () => { show('run') clearRun() act('start_automation') } return (
{TABS[tab][0]}
{TABS[tab][1]}
{status.msg || status.state}
{tab === 'dashboard' && } {tab === 'run' && } {tab === 'review' && } {tab === 'report' && }
) }