import React from "react";
import { ThemeProvider } from "./context/ThemeContext.jsx";
import { AuthProvider, useAuth } from "./context/AuthContext.jsx";
import AdminApp from "./pages/admin/AdminApp.jsx";

function AppRoutes() {
  const { isAuthenticated, booting } = useAuth();

  if (booting || !isAuthenticated) {
    return <div className="ptw-loading">Redirecting to HSE sign-in...</div>;
  }

  return <AdminApp />;
}

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