import { Switch, Route, useLocation, Link } from "wouter"; import { lazy, Suspense, useEffect, type ComponentType } from "react"; import { queryClient } from "./lib/queryClient"; import { QueryClientProvider } from "@tanstack/react-query"; import { ShieldAlert } from "lucide-react"; import { Toaster } from "@/components/ui/toaster"; import { TooltipProvider } from "@/components/ui/tooltip"; import { Button } from "@/components/ui/button"; import { ThemeProvider } from "@/components/theme-provider"; import { AppShell, Page } from "@/components/layout/app-shell"; import { EmptyState } from "@/components/empty-state"; import { LogoMark } from "@/components/brand/logo"; import { useSession } from "@/hooks/use-session"; import NotFound from "@/pages/not-found"; import Login from "@/pages/login"; // Pages chargées à la demande : une seule version responsive par écran. const Dashboard = lazy(() => import("@/pages/dashboard")); const NewPost = lazy(() => import("@/pages/new-post")); const NewReel = lazy(() => import("@/pages/new-reel")); const ScheduleReel = lazy(() => import("@/pages/schedule-reel")); const Calendar = lazy(() => import("@/pages/calendar")); const Media = lazy(() => import("@/pages/media")); const ImageEditor = lazy(() => import("@/pages/image-editor")); const PagesManagement = lazy(() => import("@/pages/pages")); const AI = lazy(() => import("@/pages/ai")); const History = lazy(() => import("@/pages/history")); const Settings = lazy(() => import("@/pages/settings")); const SqlAdmin = lazy(() => import("@/pages/sql")); const AudioAdmin = lazy(() => import("@/pages/audio-admin")); const UsersAdmin = lazy(() => import("@/pages/users-admin")); const Analytics = lazy(() => import("@/pages/analytics")); function FullScreenLoader() { return (

Chargement…

); } function PageLoader() { return (
); } function ProtectedRoute({ component: Component, adminOnly = false }: { component: ComponentType; adminOnly?: boolean }) { const [, setLocation] = useLocation(); const { session, isAdmin, isLoading } = useSession(); useEffect(() => { if (!isLoading && !session) { setLocation("/login"); } }, [isLoading, session, setLocation]); if (isLoading) return ; if (!session) return null; return ( {adminOnly && !isAdmin ? ( Retour au tableau de bord } /> ) : ( }> )} ); } function Router() { return ( {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } ); } function App() { return ( ); } export default App;