From 8b5c940976aa4bf9a2b8be285d37006a73a4644c Mon Sep 17 00:00:00 2001 From: developer1054 Date: Thu, 23 Oct 2025 15:30:48 -0300 Subject: [PATCH] rotas --- src/App.tsx | 9 ++++++- src/components/FullScreenLoader.tsx | 35 ++++++++++++++++++++++++++ src/pages/Index.tsx | 39 ++++++++++++++++++----------- src/pages/Redirect.tsx | 10 ++++++++ 4 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 src/components/FullScreenLoader.tsx create mode 100644 src/pages/Redirect.tsx diff --git a/src/App.tsx b/src/App.tsx index a09c767..c06f45b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 = () => ( - } /> + } + /> + + } /> {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */} } /> + } /> diff --git a/src/components/FullScreenLoader.tsx b/src/components/FullScreenLoader.tsx new file mode 100644 index 0000000..aed2a98 --- /dev/null +++ b/src/components/FullScreenLoader.tsx @@ -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 ( +
+
+ +

{text}

+
+
+ ); +} diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index e4d59f2..0bbacf8 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -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,21 +28,29 @@ const Index = () => { setActiveBotChat(null); }; - return ( - - {activeView === "chat" && } - {activeView === "images" && } - {activeView === "transcription" && } - {activeView === "generation" && } - {activeView === "bots" && ( - activeBotChat ? ( - - ) : ( - - ) - )} - {activeView === "agent" && } - + return ( + } /> + + + {activeView === "chat" && } + {activeView === "images" && } + {activeView === "transcription" && } + {activeView === "generation" && } + {activeView === "bots" && ( + activeBotChat ? ( + + ) : ( + + ) + )} + {activeView === "agent" && } + + } /> + + + + ); }; diff --git a/src/pages/Redirect.tsx b/src/pages/Redirect.tsx new file mode 100644 index 0000000..be5a203 --- /dev/null +++ b/src/pages/Redirect.tsx @@ -0,0 +1,10 @@ +import FullScreenLoader from "@/components/FullScreenLoader"; + + + +export default function Redirect() { + + return ( + + ); +}