import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { AuthProvider, useAuth } from './auth/AuthContext';
import Login from './screens/Login';
import Sidebar from './components/Sidebar';
import Live from './screens/Live';
import Activities from './screens/Activities';
import Sessions from './screens/Sessions';

function AuthedShell() {
  return (
    <BrowserRouter>
      <div className="admin-shell">
        <Sidebar />
        <main className="admin-main">
          <Routes>
            <Route path="/" element={<Live />} />
            <Route path="/handelingen" element={<Activities />} />
            <Route path="/sessies" element={<Sessions />} />
          </Routes>
        </main>
      </div>
    </BrowserRouter>
  );
}

function Gate() {
  const { isAuthed } = useAuth();
  return isAuthed ? <AuthedShell /> : <Login />;
}

export default function App() {
  return (
    <AuthProvider>
      <Gate />
    </AuthProvider>
  );
}
