@@ -1,12 +1,12 @@
|
||||
import { useAuthStore } from "@/store/auth/auth.store";
|
||||
import { useAuthStore } from "@/modules/auth/store/useAuthStore";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
|
||||
const { isAuthenticated } = useAuthStore();
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <Navigate to="/auth" replace />;
|
||||
}
|
||||
// if (!isAuthenticated) {
|
||||
// return <Navigate to="/auth" replace />;
|
||||
// }
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
@@ -2,10 +2,105 @@ import { Suspense } from "react";
|
||||
import { Routes as ReactRoutes, Route, Navigate } from "react-router-dom";
|
||||
import { HomePage } from "@/pages/home.page";
|
||||
import { ThemesPage } from "@/pages/themes.page";
|
||||
import { TestPage } from "@/pages/test.page";
|
||||
import { Test2Page, type GraphData } from "@/pages/test2.page";
|
||||
import { AuthPage } from "@/pages/auth.page";
|
||||
import { RegisterPage } from "@/pages/register.page";
|
||||
import { AddAgentsPage } from "@/pages/add-agents.page";
|
||||
import { DefaultLayout } from "@/shared/layouts/DefaultLayout";
|
||||
import { AddAgentsPage } from "@/pages/add-agents.page";
|
||||
import { IDEPage } from "@/pages/ide.page";
|
||||
|
||||
export const mockGraphData: GraphData = {
|
||||
nodes: [
|
||||
{
|
||||
id: "api-gateway",
|
||||
name: "API Gateway",
|
||||
type: "service",
|
||||
val: 12,
|
||||
description: "Входная точка API",
|
||||
},
|
||||
{
|
||||
id: "auth-service",
|
||||
name: "Auth Service",
|
||||
type: "service",
|
||||
val: 12,
|
||||
description: "Аутентификация",
|
||||
},
|
||||
{
|
||||
id: "db-service",
|
||||
name: "Database",
|
||||
type: "service",
|
||||
val: 12,
|
||||
description: "Хранилище данных",
|
||||
},
|
||||
{
|
||||
id: "redis-service",
|
||||
name: "Redis",
|
||||
type: "service",
|
||||
val: 12,
|
||||
description: "Кэширование",
|
||||
},
|
||||
{
|
||||
id: "queue-service",
|
||||
name: "Message Queue",
|
||||
type: "service",
|
||||
val: 12,
|
||||
description: "Очередь сообщений",
|
||||
},
|
||||
{
|
||||
id: "user-agent",
|
||||
name: "User Agent",
|
||||
type: "agent",
|
||||
val: 8,
|
||||
description: "Обработка пользователей",
|
||||
},
|
||||
{
|
||||
id: "payment-agent",
|
||||
name: "Payment Agent",
|
||||
type: "agent",
|
||||
val: 8,
|
||||
description: "Платежи",
|
||||
},
|
||||
{
|
||||
id: "notification-agent",
|
||||
name: "Notification Agent",
|
||||
type: "agent",
|
||||
val: 8,
|
||||
description: "Уведомления",
|
||||
},
|
||||
{
|
||||
id: "analytics-agent",
|
||||
name: "Analytics Agent",
|
||||
type: "agent",
|
||||
val: 8,
|
||||
description: "Аналитика",
|
||||
},
|
||||
{
|
||||
id: "report-agent",
|
||||
name: "Report Agent",
|
||||
type: "agent",
|
||||
val: 8,
|
||||
description: "Отчеты",
|
||||
},
|
||||
],
|
||||
links: [
|
||||
{ source: "user-agent", target: "api-gateway", type: "uses" },
|
||||
{ source: "user-agent", target: "auth-service", type: "uses" },
|
||||
{ source: "user-agent", target: "db-service", type: "uses" },
|
||||
{ source: "payment-agent", target: "api-gateway", type: "uses" },
|
||||
{ source: "payment-agent", target: "auth-service", type: "uses" },
|
||||
{ source: "payment-agent", target: "queue-service", type: "uses" },
|
||||
{ source: "notification-agent", target: "redis-service", type: "uses" },
|
||||
{ source: "notification-agent", target: "queue-service", type: "uses" },
|
||||
{ source: "analytics-agent", target: "db-service", type: "uses" },
|
||||
{ source: "report-agent", target: "db-service", type: "uses" },
|
||||
{ source: "report-agent", target: "redis-service", type: "uses" },
|
||||
{ source: "api-gateway", target: "auth-service", type: "depends_on" },
|
||||
{ source: "auth-service", target: "db-service", type: "depends_on" },
|
||||
{ source: "api-gateway", target: "queue-service", type: "depends_on" },
|
||||
{ source: "queue-service", target: "redis-service", type: "depends_on" },
|
||||
],
|
||||
};
|
||||
|
||||
export const Routing = () => {
|
||||
return (
|
||||
@@ -17,19 +112,20 @@ export const Routing = () => {
|
||||
}
|
||||
>
|
||||
<ReactRoutes>
|
||||
{/* Публичные маршруты */}
|
||||
<Route path="/auth" element={<AuthPage />} />
|
||||
<Route path="/register" element={<RegisterPage />} />
|
||||
|
||||
{/* Защищённые маршруты с Layout */}
|
||||
<Route element={<DefaultLayout />}>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/themes" element={<ThemesPage />} />
|
||||
<Route path="/add-agents" element={<AddAgentsPage />} />
|
||||
<Route path="/themes" element={<ThemesPage />} />
|
||||
<Route path="/add-agents" element={<AddAgentsPage />} />
|
||||
<Route path="/IDE" element={<IDEPage />} />
|
||||
</Route>
|
||||
|
||||
<Route path="/test" element={<TestPage />} />
|
||||
|
||||
<Route path="/test2" element={<Test2Page data={mockGraphData} />} />
|
||||
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</ReactRoutes>
|
||||
</Suspense>
|
||||
|
||||
Reference in New Issue
Block a user