File size: 2,267 Bytes
6c2251a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
63
64
// src/components/shared/Navigation.tsx
import React from 'react';
import { Home, BookOpen, Code, MessageCircle, User, LogOut } from 'lucide-react';
import { useUser } from '../../contexts/UserContext';

const NavLink = ({ href, icon, children }) => (
  <a
    href={href}
    className="inline-flex items-center gap-2 px-1 pt-1 text-gray-600 hover:text-gray-900
              border-b-2 border-transparent hover:border-blue-500"
  >
    {icon}
    <span>{children}</span>
  </a>
);

const Navigation = () => {
  const { user, logout } = useUser();

  return (
    <nav className="bg-white shadow-sm">
      <div className="max-w-7xl mx-auto px-4">
        <div className="flex justify-between h-16">
          {/* Logo and main nav */}
          <div className="flex">
            <div className="flex-shrink-0 flex items-center">
              <span className="text-2xl font-bold text-blue-600">EduAI</span>
            </div>
            
            <div className="hidden sm:ml-6 sm:flex sm:space-x-8">
              <NavLink icon={<Home size={20} />} href="/">Home</NavLink>
              <NavLink icon={<BookOpen size={20} />} href="/paths">Learning Paths</NavLink>
              <NavLink icon={<MessageCircle size={20} />} href="/tutor">AI Tutor</NavLink>
              <NavLink icon={<Code size={20} />} href="/playground">Code Playground</NavLink>
            </div>
          </div>

          {/* User menu */}
          <div className="flex items-center">
            {user.isAuthenticated ? (
              <div className="flex items-center gap-4">
                <span className="text-gray-700">{user.username}</span>
                <button
                  onClick={logout}
                  className="flex items-center gap-2 text-gray-600 hover:text-gray-900"
                >
                  <LogOut size={20} />
                  <span className="hidden sm:inline">Sign out</span>
                </button>
              </div>
            ) : (
              <button className="flex items-center gap-2 text-blue-600 hover:text-blue-800">
                <User size={20} />
                <span>Sign in</span>
              </button>
            )}
          </div>
        </div>
      </div>
    </nav>
  );
};

export default Navigation;