@@ -0,0 +1,12 @@
|
||||
import { PrimeReactProvider } from "primereact/api";
|
||||
import { Routing } from "./providers/routing/routing";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<PrimeReactProvider>
|
||||
<Routing />
|
||||
</PrimeReactProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useAuthStore } from "@/store/auth/auth.store";
|
||||
import { Navigate } from "react-router-dom";
|
||||
|
||||
export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
|
||||
const { isAuthenticated } = useAuthStore();
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <Navigate to="/auth" replace />;
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Suspense } from "react";
|
||||
import { Routes as ReactRoutes, Route, Navigate } from "react-router-dom";
|
||||
import { HomePage } from "@/pages/home.page";
|
||||
|
||||
export const Routing = () => {
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="flex items-center justify-center min-h-screen">
|
||||
Загрузка...
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<ReactRoutes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</ReactRoutes>
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user