import React from 'react'; import { createBrowserRouter, Outlet, Navigate, useLocation } from 'react-router-dom'; import { useAuth } from './auth/context'; import { ADMIN_BASE_PATH, ADMIN_DEFAULT_AFTER_LOGIN_PATH, ADMIN_EVENTS_PATH, ADMIN_LOGIN_START_PATH, ADMIN_PUBLIC_LANDING_PATH, } from './constants'; const LoginPage = React.lazy(() => import('./pages/LoginPage')); const DashboardPage = React.lazy(() => import('./pages/DashboardPage')); const EventsPage = React.lazy(() => import('./pages/EventsPage')); const SettingsPage = React.lazy(() => import('./pages/SettingsPage')); const EventFormPage = React.lazy(() => import('./pages/EventFormPage')); const EventPhotosPage = React.lazy(() => import('./pages/EventPhotosPage')); const EventDetailPage = React.lazy(() => import('./pages/EventDetailPage')); const EventMembersPage = React.lazy(() => import('./pages/EventMembersPage')); const EventTasksPage = React.lazy(() => import('./pages/EventTasksPage')); const EventToolkitPage = React.lazy(() => import('./pages/EventToolkitPage')); const EventInvitesPage = React.lazy(() => import('./pages/EventInvitesPage')); const EventPhotoboothPage = React.lazy(() => import('./pages/EventPhotoboothPage')); const EngagementPage = React.lazy(() => import('./pages/EngagementPage')); const BillingPage = React.lazy(() => import('./pages/BillingPage')); const TasksPage = React.lazy(() => import('./pages/TasksPage')); const TaskCollectionsPage = React.lazy(() => import('./pages/TaskCollectionsPage')); const EmotionsPage = React.lazy(() => import('./pages/EmotionsPage')); const FaqPage = React.lazy(() => import('./pages/FaqPage')); const AuthCallbackPage = React.lazy(() => import('./pages/AuthCallbackPage')); const WelcomeTeaserPage = React.lazy(() => import('./pages/WelcomeTeaserPage')); const LoginStartPage = React.lazy(() => import('./pages/LoginStartPage')); const ProfilePage = React.lazy(() => import('./pages/ProfilePage')); const LogoutPage = React.lazy(() => import('./pages/LogoutPage')); const LiveRedirectPage = React.lazy(() => import('./pages/LiveRedirectPage')); function RequireAuth() { const { status } = useAuth(); const location = useLocation(); if (status === 'loading') { return (