mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-05-19 09:28:47 +02:00
Replaces the Next.js scaffold with a Vite SPA paired with a Hono sidecar that hosts the CopilotKit runtime and proxies AG-UI traffic to the MAF backend. Adds dev/prod Dockerfile, .dockerignore, .gitignore, pnpm workspace config, and updates entrypoints (main.tsx / App.tsx / index.css / index.html) plus the service worker accordingly. Server middleware reconciles MAF MESSAGES_SNAPSHOT id mismatches so post-tool-call assistant text doesn't render twice, suppresses duplicate text emitted alongside render tools, and strips OpenAI training-token leaks from streamed deltas. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
|
|
import { CopilotKit } from "@copilotkit/react-core";
|
|
import { AuthProvider, useAuth } from "./AuthContext";
|
|
import { ThemeProvider } from "./contexts/theme-context";
|
|
import { PrivacyProvider } from "./contexts/privacy-context";
|
|
import Layout from "./components/Layout";
|
|
import LoginPage from "./pages/Login";
|
|
import Asistente from "./pages/Asistente";
|
|
import Analytics from "./pages/Analytics";
|
|
import Budget from "./pages/Budget";
|
|
import Salarios from "./pages/Salarios";
|
|
import Pensions from "./pages/Pensions";
|
|
import Proyecciones from "./pages/Proyecciones";
|
|
import ServiciosMunicipales from "./pages/ServiciosMunicipales";
|
|
|
|
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
if (isLoading) return null;
|
|
return isAuthenticated ? <>{children}</> : <Navigate to="/login" replace />;
|
|
}
|
|
|
|
function AppRoutes() {
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
|
|
if (isLoading) return null;
|
|
|
|
return (
|
|
<Routes>
|
|
<Route
|
|
path="/login"
|
|
element={isAuthenticated ? <Navigate to="/asistente" replace /> : <LoginPage />}
|
|
/>
|
|
<Route
|
|
element={
|
|
<ProtectedRoute>
|
|
<Layout />
|
|
</ProtectedRoute>
|
|
}
|
|
>
|
|
<Route index element={<Navigate to="/asistente" replace />} />
|
|
<Route path="/asistente" element={<Asistente />} />
|
|
<Route path="/budget" element={<Budget />} />
|
|
<Route path="/analytics" element={<Analytics />} />
|
|
<Route path="/proyecciones" element={<Proyecciones />} />
|
|
<Route path="/salarios" element={<Salarios />} />
|
|
<Route path="/pensions" element={<Pensions />} />
|
|
<Route path="/servicios-municipales" element={<ServiciosMunicipales />} />
|
|
<Route path="/transactions" element={<Navigate to="/budget" replace />} />
|
|
<Route path="/transfers" element={<Navigate to="/budget" replace />} />
|
|
</Route>
|
|
</Routes>
|
|
);
|
|
}
|
|
|
|
export default function App() {
|
|
return (
|
|
<BrowserRouter>
|
|
<ThemeProvider>
|
|
<PrivacyProvider>
|
|
<AuthProvider>
|
|
<CopilotKit runtimeUrl="/api/copilotkit" agent="wealthysmart" a2ui={{}}>
|
|
<AppRoutes />
|
|
</CopilotKit>
|
|
</AuthProvider>
|
|
</PrivacyProvider>
|
|
</ThemeProvider>
|
|
</BrowserRouter>
|
|
);
|
|
}
|