-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavbar.jsx
More file actions
36 lines (31 loc) · 1.11 KB
/
Copy pathNavbar.jsx
File metadata and controls
36 lines (31 loc) · 1.11 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
// components/Navbar.jsx
// Top navigation bar showing the current user and a logout button.
import React from 'react';
import { LogOut } from 'lucide-react';
import { useAuth } from '../context/AuthContext';
import { useNavigate } from 'react-router-dom';
const Navbar = () => {
const { user, logout } = useAuth();
const navigate = useNavigate();
const handleLogout = () => {
logout();
navigate('/login');
};
return (
<header className="flex h-16 items-center justify-between border-b border-gray-200 bg-white px-6">
<h1 className="text-lg font-semibold text-gray-800">Welcome back, {user?.name?.split(' ')[0]}</h1>
<div className="flex items-center gap-4">
<span className="rounded-full bg-brand-50 px-3 py-1 text-xs font-medium capitalize text-brand-700">
{user?.role}
</span>
<button
onClick={handleLogout}
className="flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium text-gray-600 hover:bg-gray-100"
>
<LogOut size={16} /> Logout
</button>
</div>
</header>
);
};
export default Navbar;