File size: 1,696 Bytes
3c48b32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Outlet, NavLink, useNavigate } from 'react-router-dom'

const navItems = [
  { to: '/', label: '🏠 Dashboard', end: true },
  { to: '/workouts', label: '💪 Workouts' },
  { to: '/health', label: '❤️ Health' },
  { to: '/chat', label: '🤖 AI Coach' },
]

export default function Layout() {
  const navigate = useNavigate()

  function logout() {
    localStorage.removeItem('token')
    navigate('/login')
  }

  return (
    <div className="flex flex-col min-h-screen">
      {/* Top nav */}
      <header className="bg-indigo-600 text-white px-4 py-3 flex items-center justify-between shadow">
        <span className="font-bold text-lg tracking-tight">⚡ FitAI Coach</span>
        <button
          onClick={logout}
          className="text-sm bg-indigo-500 hover:bg-indigo-400 px-3 py-1 rounded transition"
        >
          Logout
        </button>
      </header>

      <div className="flex flex-1">
        {/* Sidebar */}
        <nav className="w-44 bg-white border-r flex flex-col gap-1 p-3 shrink-0">
          {navItems.map(({ to, label, end }) => (
            <NavLink
              key={to}
              to={to}
              end={end}
              className={({ isActive }) =>
                `px-3 py-2 rounded text-sm font-medium transition ${
                  isActive
                    ? 'bg-indigo-50 text-indigo-700'
                    : 'text-gray-600 hover:bg-gray-100'
                }`
              }
            >
              {label}
            </NavLink>
          ))}
        </nav>

        {/* Main content */}
        <main className="flex-1 p-6 overflow-auto">
          <Outlet />
        </main>
      </div>
    </div>
  )
}