From 49b78da6004879c17d4a22435a450671559a9f9b Mon Sep 17 00:00:00 2001 From: andrei Date: Sat, 5 Oct 2024 10:25:45 +0500 Subject: [PATCH] ._. --- src/App.jsx | 2 ++ src/components/Header.jsx | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/components/Header.jsx diff --git a/src/App.jsx b/src/App.jsx index ab39322..3b2e586 100755 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,12 +2,14 @@ import React from "react"; import RoutesComponent from "./AppRouter.jsx"; import { AuthProvider } from "./AuthContext.jsx"; import { BrowserRouter as Router } from "react-router-dom"; +import Header from "./components/Header.jsx"; const App = () => { return (
+
diff --git a/src/components/Header.jsx b/src/components/Header.jsx new file mode 100644 index 0000000..55f4db9 --- /dev/null +++ b/src/components/Header.jsx @@ -0,0 +1,51 @@ +import React from "react"; +import { Link, useNavigate } from "react-router-dom"; +import { useAuth } from "../AuthContext"; + +const Header = () => { + const { isAuthenticated, logout } = useAuth(); + const navigate = useNavigate(); + + const handleLogout = () => { + logout(); + navigate("/login"); + }; + + return ( +
+
+ + My App + +
+
    +
  • + + Home + +
  • +
  • + + Accessories + +
  • + {/* Добавьте другие ссылки, если необходимо */} +
+
+ {isAuthenticated ? ( + + ) : ( + + Login + + )} +
+
+
+
+ ); +}; + +export default Header;