diff --git a/src/App.tsx b/src/App.tsx
index 7d54fae..e36b229 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,15 +1,21 @@
import './App.css'
import {Route, Routes} from "react-router-dom";
import Home from "./routes/Home.tsx";
+import {LoginPage} from "./routes/LoginPage.tsx";
+import {PrivateRoute} from "./components/PrivateRoute.tsx";
+import {NotFound} from "./routes/NotFound.tsx";
function App() {
return (
<>
- }>
+ } />
+ } />
+ } />
test
+
>
)
}
diff --git a/src/components/PrivateRoute.tsx b/src/components/PrivateRoute.tsx
new file mode 100644
index 0000000..f5df4ae
--- /dev/null
+++ b/src/components/PrivateRoute.tsx
@@ -0,0 +1,8 @@
+import {useAuth} from "../context/AuthContext.tsx";
+import {Navigate} from "react-router-dom";
+import React from "react";
+
+export const PrivateRoute = ({ children} : {children: React.ReactNode}) => {
+ const {isAuthenticated } = useAuth();
+ return isAuthenticated ? <> {children}>: ;
+}
\ No newline at end of file
diff --git a/src/context/AuthContext.tsx b/src/context/AuthContext.tsx
new file mode 100644
index 0000000..eb26d0c
--- /dev/null
+++ b/src/context/AuthContext.tsx
@@ -0,0 +1,22 @@
+import React, { createContext, useState, useContext } from 'react';
+
+const AuthContext = createContext({
+ isAuthenticated: false,
+ login: () => {},
+ logout: () => {}
+});
+
+export const AuthProvider= ({ children }: { children: React.ReactNode }) => {
+ const [isAuthenticated, setIsAuthenticated] = useState(false);
+
+ const login = () => setIsAuthenticated(true);
+ const logout = () => setIsAuthenticated(false);
+
+ return (
+
+ {children}
+
+ );
+};
+
+export const useAuth = () => useContext(AuthContext);
\ No newline at end of file
diff --git a/src/main.tsx b/src/main.tsx
index 814e5c3..1c644b5 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -3,11 +3,15 @@ import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import {BrowserRouter} from "react-router-dom";
+import {AuthProvider} from "./context/AuthContext.tsx";
createRoot(document.getElementById('root')!).render(
-
-
-
+
+
+
+
+
+
,
)
diff --git a/src/routes/LoginPage.tsx b/src/routes/LoginPage.tsx
new file mode 100644
index 0000000..6c1552f
--- /dev/null
+++ b/src/routes/LoginPage.tsx
@@ -0,0 +1,3 @@
+export function LoginPage() {
+ return <>Login page>
+}
\ No newline at end of file
diff --git a/src/routes/NotFound.tsx b/src/routes/NotFound.tsx
new file mode 100644
index 0000000..1f61b5a
--- /dev/null
+++ b/src/routes/NotFound.tsx
@@ -0,0 +1,3 @@
+export function NotFound() {
+ return Page not found
+}
\ No newline at end of file