init: Init React Application
This commit is contained in:
33
src/app/router/index.tsx
Normal file
33
src/app/router/index.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import { DevicesPage, LoginPage, MainPage, SightPage } from "@pages";
|
||||
import { authStore } from "@shared";
|
||||
import { Layout } from "@widgets";
|
||||
|
||||
import { Navigate, Outlet, Route, Routes } from "react-router-dom";
|
||||
|
||||
const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
|
||||
const { isAuthenticated } = authStore;
|
||||
if (!isAuthenticated) {
|
||||
return <Navigate to="/login" />;
|
||||
}
|
||||
return children;
|
||||
};
|
||||
export const Router = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
<Layout>
|
||||
<Outlet />
|
||||
</Layout>
|
||||
}
|
||||
>
|
||||
<Route path="/" element={<MainPage />} />
|
||||
<Route path="/sights" element={<SightPage />} />
|
||||
<Route path="/devices" element={<DevicesPage />} />
|
||||
</Route>
|
||||
|
||||
<Route path="/login" element={<LoginPage />} />
|
||||
</Routes>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user