rotas
This commit is contained in:
+8
-1
@@ -6,6 +6,7 @@ import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import { ThemeProvider } from "next-themes";
|
||||
import Index from "./pages/Index";
|
||||
import NotFound from "./pages/NotFound";
|
||||
import Redirect from "./pages/Redirect";
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
@@ -17,9 +18,15 @@ const App = () => (
|
||||
<Sonner />
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Index />} />
|
||||
<Route
|
||||
path="/redir/:gsikey"
|
||||
element={<Redirect />}
|
||||
/>
|
||||
|
||||
<Route path="/*" element={<Index />} />
|
||||
{/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
|
||||
<Route path="*" element={<NotFound />} />
|
||||
<Route path="/404" element={<NotFound />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</TooltipProvider>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface FullScreenLoaderProps {
|
||||
show: boolean;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export default function FullScreenLoader({ show, text = "Carregando..." }: FullScreenLoaderProps) {
|
||||
const [visible, setVisible] = useState(show);
|
||||
|
||||
useEffect(() => {
|
||||
if (show) setVisible(true);
|
||||
else {
|
||||
// adiciona um pequeno atraso para suavizar o fade-out
|
||||
const timeout = setTimeout(() => setVisible(false), 200);
|
||||
return () => clearTimeout(timeout);
|
||||
}
|
||||
}, [show]);
|
||||
|
||||
if (!visible && !show) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`fixed inset-0 z-[9999] flex items-center justify-center bg-background/80 backdrop-blur-sm transition-opacity duration-200 ${
|
||||
show ? "opacity-100" : "opacity-0 pointer-events-none"
|
||||
}`}
|
||||
>
|
||||
<div className="flex flex-col items-center gap-3 p-6 rounded-2xl bg-card shadow-lg border border-border transition-all duration-200">
|
||||
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||
<p className="text-card-foreground text-sm font-medium">{text}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+10
-1
@@ -7,6 +7,7 @@ import { GenerationView } from "@/components/audio/GenerationView";
|
||||
import { BotView } from "@/components/bots/BotView";
|
||||
import { BotChat } from "@/components/bots/BotChat";
|
||||
import { AgentView } from "@/components/agent/AgentView";
|
||||
import { Navigate, Route, Routes } from "react-router-dom";
|
||||
|
||||
interface Bot {
|
||||
id: string;
|
||||
@@ -27,7 +28,10 @@ const Index = () => {
|
||||
setActiveBotChat(null);
|
||||
};
|
||||
|
||||
return (
|
||||
return (<Routes>
|
||||
<Route path="" element={<Navigate to={`/404`} replace />} />
|
||||
<Route path="codex">
|
||||
<Route path="" element={
|
||||
<Layout activeTab={activeView} onTabChange={setActiveView}>
|
||||
{activeView === "chat" && <ChatView />}
|
||||
{activeView === "images" && <ImageView />}
|
||||
@@ -42,6 +46,11 @@ const Index = () => {
|
||||
)}
|
||||
{activeView === "agent" && <AgentView />}
|
||||
</Layout>
|
||||
} />
|
||||
|
||||
</Route>
|
||||
</Routes>
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import FullScreenLoader from "@/components/FullScreenLoader";
|
||||
|
||||
|
||||
|
||||
export default function Redirect() {
|
||||
|
||||
return (
|
||||
<FullScreenLoader show={true} text="Carregando...Aguarde..." />
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user