-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLayout.jsx
More file actions
57 lines (50 loc) · 1.43 KB
/
Layout.jsx
File metadata and controls
57 lines (50 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import React from "react";
import { useContext } from "react";
import { Link, useNavigate } from "react-router-dom";
import { AppContext } from "./pages/AppContext";
const Layout = ({ children }) => {
const { currentUser, logoutUser } = useContext(AppContext);
const navigate = useNavigate();
const handleLogout = () => {
logoutUser();
navigate("/");
};
return (
<div className="quote-page">
<header className="navbar">
<div className="navbar-left">
<Link to="/" className="logo">QuoteOfTheDay</Link>
<nav>
<Link to="/">Home</Link>
<Link to="/privacy">Privacy</Link>
</nav>
</div>
<div className="navbar-right">
{currentUser ?
(
<>
<span>Hello, {currentUser}!</span>
<button onClick={handleLogout} className="logout-btn">Logout</button>
</>
) :
(
<>
<Link to="/register">Register</Link>
<Link to="/login">Login</Link>
</>
)
}
</div>
</header>
<main className="quote-container">
{children}
</main>
<footer>
<p>© 2024 - QuoteOfTheDay - <Link to="/privacy">Privacy</Link></p>
</footer>
</div>
);
};
export default Layout;