import React, { lazy, Suspense, useState } from "react"; import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom"; import { AuthProvider, useAuth } from "./context/AuthContext"; const LibraryPage = lazy(() => import("./pages/Library").then((m) => ({ default: m.LibraryPage }))); const BookDetailPage = lazy(() => import("./pages/BookDetailPage").then((m) => ({ default: m.BookDetailPage }))); const ReaderPage = lazy(() => import("./pages/Reader").then((m) => ({ default: m.ReaderPage }))); const AddBookPage = lazy(() => import("./pages/AddBook").then((m) => ({ default: m.AddBookPage }))); const EditEBookPage = lazy(() => import("./pages/EditEBook").then((m) => ({ default: m.EditEBookPage }))); const SettingsPage = lazy(() => import("./pages/Settings").then((m) => ({ default: m.SettingsPage }))); const BookmarksNotesPage = lazy(() => import("./components/annotations/BookmarksNotesPage").then((m) => ({ default: m.BookmarksNotesPage }))); const ReadingPage = lazy(() => import("./pages/ReadingPage").then((m) => ({ default: m.default }))); const AuthPage = lazy(() => import("./pages/AuthPage").then((m) => ({ default: () => { const [isLogin, setIsLogin] = useState(true); return isLogin ? setIsLogin(false)} /> : setIsLogin(true)} />; }, })), ); function LoadingFallback() { return

Loading...

; } function ProtectedRoute({ children }: { children: React.ReactNode }) { const { isAuthenticated, loading } = useAuth(); if (loading) return ; if (!isAuthenticated) return ; return <>{children}; } function AppRoutes() { const { isAuthenticated } = useAuth(); return ( }> : } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); } export default function App() { return ( ); }