import { useEffect, useState } from 'react'; import Dashboard from './components/Dashboard'; import ReportView from './components/ReportView'; import WidgetConfigurator from './components/WidgetConfigurator'; import Settings from './components/Settings'; type View = '' | 'report' | 'widget' | 'settings'; function parseHash(): View { const hash = window.location.hash.replace('#/', '').replace('#', '') as View; return ['', 'report', 'widget', 'settings'].includes(hash) ? hash : ''; } export default function App() { const [view, setView] = useState(parseHash); useEffect(() => { const onHashChange = () => setView(parseHash()); window.addEventListener('hashchange', onHashChange); return () => window.removeEventListener('hashchange', onHashChange); }, []); const navigate = (v: View) => { window.location.hash = v ? `/${v}` : '/'; setView(v); }; return (
{/* Sidebar nav */} {/* Main content */}
{view === '' && } {view === 'report' && } {view === 'widget' && } {view === 'settings' && }
); } function NavItem({ active, onClick, children, }: { active: boolean; onClick: () => void; children: React.ReactNode; }) { return (
  • ); }