import { Switch, Route, Redirect, useLocation } from "wouter"; import { useEffect } from "react"; import { queryClient } from "./lib/queryClient"; import { QueryClientProvider, useQuery } from "@tanstack/react-query"; import { Toaster } from "@/components/ui/toaster"; import { TooltipProvider } from "@/components/ui/tooltip"; import NotFound from "@/pages/not-found"; import Login from "@/pages/login"; import Dashboard from "@/pages/dashboard"; import NewPost from "@/pages/new-post"; import Calendar from "@/pages/calendar"; import Media from "@/pages/media"; import ImageEditor from "@/pages/image-editor"; import PagesManagement from "@/pages/pages"; import AI from "@/pages/ai"; import History from "@/pages/history"; import Settings from "@/pages/settings"; import SqlAdmin from "@/pages/sql"; import UsersAdmin from "@/pages/users-admin"; function ProtectedRoute({ component: Component, adminOnly = false }: { component: React.ComponentType; adminOnly?: boolean }) { const [, setLocation] = useLocation(); const { data: session, isLoading } = useQuery({ queryKey: ["/api/auth/session"], retry: false, }); useEffect(() => { if (!isLoading && !session) { setLocation("/login"); } }, [isLoading, session, setLocation]); if (isLoading) { return (

Chargement...

); } if (!session) { return null; } if (adminOnly && (session as any).role !== "admin") { return (

Accès refusé

Cette page est réservée aux administrateurs.

); } return ; } function Router() { return ( {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } {() => } ); } function App() { return (
); } export default App;