import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import "keen-slider/keen-slider.min.css";

import Index from "./pages/Index";
import MitgliedWerdenPage from "./pages/MitgliedWerden";
import AlleNeuigkeitenPage from "./pages/AlleNeuigkeiten";
import Layout from "./layout/Layout";
import TeamDetailPage from "./pages/TeamDetailPage";


import "./index.css"
import LoginPage from "./pages/LoginPage";
import AdminDashboard from "./admin/AdminDashboard";
import NewsManager from "./admin/NewsManager";
import { AuthProvider } from "./context/AuthContext";
import PrivateRoute from "./components/PrivateRoute";
import UserManagementPage from "./admin/UserManagementPage";
import UserCreatePage from "./admin/UserCreatePage";
import UserEditPage from "./admin/UserEditPage";
import TeamList from "./admin/TeamList";
import TeamCreate from "./admin/TeamCreate";
import TeamDetail from "./admin/TeamDetail";
import TeamAddPlayer from "./admin/TeamAddPlayer";
import PlayerEdit from "./admin/PlayerEdit";



ReactDOM.createRoot(document.getElementById("root")!).render(
    <React.StrictMode>
      <BrowserRouter>
      <AuthProvider>
          <Routes>
            <Route
              path="/"
              element={
                <Layout>
                  <Index />
                </Layout>
              }
            />
            <Route
              path="/mitglied-werden"
              element={
                <Layout>
                  <MitgliedWerdenPage />
                </Layout>
              }
            />
            <Route
              path="/alle-neuigkeiten"
              element={
                <Layout>
                  <AlleNeuigkeitenPage />
                </Layout>
              }
            />
          <Route path="/teams/:id" element={<Layout><TeamDetailPage /></Layout>} />
          <Route path="/login" element={<Layout><LoginPage /></Layout>}/>
          <Route path="/admin/login" element={<LoginPage />} />
          <Route path="/admin" element={<PrivateRoute><Layout><AdminDashboard /></Layout></PrivateRoute>} />
          <Route path="/admin/news" element={<PrivateRoute><Layout><NewsManager /></Layout></PrivateRoute>} />
          <Route path="/admin/users" element={<PrivateRoute><Layout><UserManagementPage /></Layout></PrivateRoute>} />
          <Route path="/admin/users/new" element={<PrivateRoute><Layout><UserCreatePage /></Layout></PrivateRoute>} />
          <Route path="/admin/users/edit/:id" element={<PrivateRoute><Layout><UserEditPage /></Layout></PrivateRoute>} />
          <Route path="/admin/teams" element={<PrivateRoute><Layout><TeamList /></Layout></PrivateRoute>} />
          <Route path="/admin/teams/new" element={<PrivateRoute><Layout><TeamCreate /></Layout></PrivateRoute>} />
          <Route path="/admin/teams/:id" element={<PrivateRoute><Layout><TeamDetail /></Layout></PrivateRoute>} />
          <Route path="/admin/teams/:id/add-player" element={<PrivateRoute><Layout><TeamAddPlayer /></Layout></PrivateRoute>} />
          <Route path="/admin/players/:id/edit" element={<PrivateRoute><Layout><PlayerEdit /></Layout></PrivateRoute>} />
          
          </Routes>
        </AuthProvider>
      </BrowserRouter>
    </React.StrictMode>
  );