aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/components/Navigation.tsx
blob: d6e20c959c3c1bd181f1100b0476f49fc36b3806 (plain)
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
import {
	faBookOpen,
	faCircleCheck,
	faGear,
	faRightFromBracket,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, useLocation } from "wouter";
import { useAuth } from "../contexts/AuthContext";
import { MenuItem } from "./MenuItem";

export function Navigation() {
	const { logout, user } = useAuth();
	const [, setLocation] = useLocation();

	const handleLogout = async () => {
		await logout();
		setLocation("/login");
	};

	return (
		<nav className="bg-white shadow-sm border-b border-gray-200">
			<div className="container mx-auto px-4">
				<div className="flex items-center justify-between h-16">
					<Link href="/" className="text-xl font-bold text-gray-900">
						feedaka
					</Link>
					<div className="flex items-center space-x-6">
						<MenuItem path="/unread" label="Unread" icon={faBookOpen} />
						<MenuItem path="/read" label="Read" icon={faCircleCheck} />
						<MenuItem path="/settings" label="Settings" icon={faGear} />
						{user && (
							<button
								type="button"
								onClick={handleLogout}
								className="flex items-center space-x-2 text-gray-600 hover:text-gray-900"
								title={`Logout (${user.username})`}
							>
								<FontAwesomeIcon icon={faRightFromBracket} />
								<span>Logout</span>
							</button>
						)}
					</div>
				</div>
			</div>
		</nav>
	);
}