mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-12 01:36:54 +02:00
Integrates a new image editor page with routing, sidebar navigation, and Cloudinary transformation URL generation for applying various filters, ribbons, price badges, and logos to selected media. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/dE5lg1s
98 lines
3.4 KiB
TypeScript
98 lines
3.4 KiB
TypeScript
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 (
|
|
<div className="flex items-center justify-center h-screen bg-background">
|
|
<div className="text-center">
|
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto mb-4"></div>
|
|
<p className="text-muted-foreground">Chargement...</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!session) {
|
|
return null;
|
|
}
|
|
|
|
if (adminOnly && (session as any).role !== "admin") {
|
|
return (
|
|
<div className="flex items-center justify-center h-screen bg-background">
|
|
<div className="text-center">
|
|
<h1 className="text-2xl font-bold mb-2">Accès refusé</h1>
|
|
<p className="text-muted-foreground">Cette page est réservée aux administrateurs.</p>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <Component />;
|
|
}
|
|
|
|
function Router() {
|
|
return (
|
|
<Switch>
|
|
<Route path="/login" component={Login} />
|
|
<Route path="/">{() => <ProtectedRoute component={Dashboard} />}</Route>
|
|
<Route path="/new">{() => <ProtectedRoute component={NewPost} />}</Route>
|
|
<Route path="/calendar">{() => <ProtectedRoute component={Calendar} />}</Route>
|
|
<Route path="/media">{() => <ProtectedRoute component={Media} />}</Route>
|
|
<Route path="/image-editor">{() => <ProtectedRoute component={ImageEditor} />}</Route>
|
|
<Route path="/pages">{() => <ProtectedRoute component={PagesManagement} />}</Route>
|
|
<Route path="/ai">{() => <ProtectedRoute component={AI} adminOnly />}</Route>
|
|
<Route path="/history">{() => <ProtectedRoute component={History} />}</Route>
|
|
<Route path="/settings">{() => <ProtectedRoute component={Settings} adminOnly />}</Route>
|
|
<Route path="/sql">{() => <ProtectedRoute component={SqlAdmin} adminOnly />}</Route>
|
|
<Route path="/users">{() => <ProtectedRoute component={UsersAdmin} adminOnly />}</Route>
|
|
<Route component={NotFound} />
|
|
</Switch>
|
|
);
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<TooltipProvider>
|
|
<div>
|
|
<Toaster />
|
|
<Router />
|
|
</div>
|
|
</TooltipProvider>
|
|
</QueryClientProvider>
|
|
);
|
|
}
|
|
|
|
export default App;
|