import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import './index.css'
import App from './App.tsx'
import Login from './pages/Login.tsx'
import AdminLayout from './pages/admin/AdminLayout.tsx'
import ProtectedRoute from './components/ProtectedRoute.tsx'

import Cover from './pages/admin/pages/Cover.tsx'
import Intro from './pages/admin/pages/Intro.tsx'
import AudienceOverview from './pages/admin/pages/AudienceOverview.tsx'
import TikTokAnalytics from './pages/admin/pages/TikTokAnalytics.tsx'
import InstagramAnalytics from './pages/admin/pages/InstagramAnalytics.tsx'
import YouTubeOverview from './pages/admin/pages/YouTubeOverview.tsx'
import CreativeProcess from './pages/admin/pages/CreativeProcess.tsx'
import Rates from './pages/admin/pages/Rates.tsx'
import CleansingBalmHero from './pages/admin/pages/CleansingBalmHero.tsx'
import PartnerProgram from './pages/admin/pages/PartnerProgram.tsx'
import ProgramOverview from './pages/admin/pages/ProgramOverview.tsx'
import PartnerPerks from './pages/admin/pages/PartnerPerks.tsx'
import SponsoredVsMentions from './pages/admin/pages/SponsoredVsMentions.tsx'
import PackageAndPricing from './pages/admin/pages/PackageAndPricing.tsx'
import LetsWorkTogether from './pages/admin/pages/LetsWorkTogether.tsx'

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      retry: 1,
      refetchOnWindowFocus: false,
      staleTime: 30_000,
    },
  },
})

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <QueryClientProvider client={queryClient}>
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<App />} />
          <Route path="/login" element={<Login />} />
          <Route
            path="/dashboard"
            element={
              <ProtectedRoute>
                <AdminLayout />
              </ProtectedRoute>
            }
          >
            <Route index element={<Navigate to="cover" replace />} />
            <Route path="cover" element={<Cover />} />
            <Route path="intro" element={<Intro />} />
            <Route path="audience-overview" element={<AudienceOverview />} />
            <Route path="tiktok-analytics" element={<TikTokAnalytics />} />
            <Route path="instagram-analytics" element={<InstagramAnalytics />} />
            <Route path="youtube-overview" element={<YouTubeOverview />} />
            <Route path="creative-process" element={<CreativeProcess />} />
            <Route path="rates" element={<Rates />} />
            <Route path="cleansing-balm-hero" element={<CleansingBalmHero />} />
            <Route path="partner-program" element={<PartnerProgram />} />
            <Route path="program-overview" element={<ProgramOverview />} />
            <Route path="partner-perks" element={<PartnerPerks />} />
            <Route path="sponsored-vs-mentions" element={<SponsoredVsMentions />} />
            <Route path="package-and-pricing" element={<PackageAndPricing />} />
            <Route path="lets-work-together" element={<LetsWorkTogether />} />
          </Route>
        </Routes>
      </BrowserRouter>
    </QueryClientProvider>
  </StrictMode>,
)
