import "./css/globals.css";
import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import RootLayout from "./app/layout";
import PublicLayout from "./app/(public)/layout";
import HomePage from "./app/(public)/page";
import AboutPage from "./app/(public)/about/page";
import ContactPage from "./app/(public)/contact-us/page";
import KomTokenPage from "./app/(public)/kom-token/page";
import TermsOfServicePage from "./app/(public)/terms-of-service/page";
import WhitePaperPage from "./app/(public)/white-paper/page";
import SearchPage from "./app/(public)/search/page";
import SingleQuestionPage from "./app/(public)/search/[questionId]/page";
import AuthLayout from "./app/(public)/(auth)/layout";

import LoginPage from "./app/(public)/(auth)/auth/login/page";
import PasswordLayout from "./app/(public)/(password)/layout";
import RegisterPage from "./app/(public)/(auth)/auth/register/page";
import DashboardLayout from "./app/dashboard/layout";
import DashboardHomePage from "./app/dashboard/page";
import DashboardBroadcasts from "./app/dashboard/broadcast/page";
import DashboardFeedback from "./app/dashboard/feedback/page";
import DashboardMessages from "./app/dashboard/messages/page";
import DashboardNotifications from "./app/dashboard/notifications/page";
import DashboardProfile from "./app/dashboard/profile/page";
import NewQuestionPage from "./app/dashboard/questions/new/page";
import Error401Page from "./app/401/page";
import Error403Page from "./app/403/page";
import DashboardLogout from "./app/dashboard/logout/page";
import PasswordResetPage from "./app/(public)/password/reset/page";
import NotFoundPage from "./app/404/page";
import DashboardRewards from "./app/dashboard/rewards/page";
import FAQ from "./app/(public)/faq/page";

const App = () => {
  return (
    <Router>
      <Routes>
        {/* Root layout wrapper */}
        <Route element={<RootLayout />}>
          {/* Public routes with public layout */}
          <Route element={<PublicLayout />}>
            {/* Home page */}
            <Route path="/" element={<HomePage />} />

            {/* Public pages */}
            <Route path="/faq" element={<FAQ />} />
            <Route path="/about" element={<AboutPage />} />
            <Route path="/contact-us" element={<ContactPage />} />
            <Route path="/kom-token" element={<KomTokenPage />} />
            <Route path="/terms-of-service" element={<TermsOfServicePage />} />
            <Route path="/white-paper" element={<WhitePaperPage />} />

            {/* Search routes */}
            <Route path="/search" element={<SearchPage />} />
            <Route
              path="/search/:questionId"
              element={<SingleQuestionPage />}
            />

            {/* Auth routes with auth layout */}
            <Route element={<AuthLayout />}>
              <Route path="/auth/login" element={<LoginPage />} />
              <Route path="/auth/register" element={<RegisterPage />} />
            </Route>

            {/* Password routes with password layout */}
            <Route element={<PasswordLayout />}>
              <Route path="/password/reset" element={<PasswordResetPage />} />
            </Route>
          </Route>

          {/* Dashboard routes with dashboard layout */}
          <Route element={<DashboardLayout />}>
            <Route path="/dashboard" element={<DashboardHomePage />} />
            {/* <Route
              path="/dashboard/broadcast"
              element={<DashboardBroadcasts />}
            /> */}
            {/* <Route path="/dashboard/feedback" element={<DashboardFeedback />} /> */}
            <Route path="/dashboard/logout" element={<DashboardLogout />} />
            <Route path="/dashboard/messages" element={<DashboardMessages />} />
            <Route
              path="/dashboard/notifications"
              element={<DashboardNotifications />}
            />
            <Route path="/dashboard/rewards" element={<DashboardRewards />} />
            <Route path="/dashboard/profile" element={<DashboardProfile />} />

            <Route
              path="/dashboard/questions/new"
              element={<NewQuestionPage />}
            />
          </Route>

          {/* Error pages */}
          <Route path="/401" element={<Error401Page />} />
          <Route path="/403" element={<Error403Page />} />
          <Route path="*" element={<NotFoundPage />} />
        </Route>
      </Routes>
    </Router>
  );
};

const root = ReactDOM.createRoot(document.getElementById("root")!);
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);
