import { Navigate, Route, Routes } from "react-router-dom";
import Layout from "./components/Layout";
import CarPage from "./pages/CarPage";
import LoginPage from "./pages/LoginPage";
import PaymentPage from "./pages/PaymentPage";
import ReportsPage from "./pages/ReportsPage";
import ServiceRecordPage from "./pages/ServiceRecordPage";
import ServicePage from "./pages/ServicePage";
import RegisterPage from "./pages/RegisterPage";
import SessionBootstrap from "./pages/SessionBootstrap";

function App() {
  return (
    <Routes>
      <Route path="/login" element={<LoginPage />} />
      <Route path="/register" element={<RegisterPage />} />

      <Route
        path="*"
        element={
          <SessionBootstrap>
            <Layout>
              <Routes>
                <Route path="/cars" element={<CarPage />} />
                <Route path="/services" element={<ServicePage />} />
                <Route path="/service-records" element={<ServiceRecordPage />} />
                <Route path="/payments" element={<PaymentPage />} />
                <Route path="/reports" element={<ReportsPage />} />
                <Route path="*" element={<Navigate to="/cars" replace />} />
              </Routes>
            </Layout>
          </SessionBootstrap>
        }
      />
    </Routes>
  );
}

export default App;


