File size: 1,538 Bytes
5f7dc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"use client";

import { useAuth } from "@/lib/auth";
import { useRouter } from "next/navigation";

export default function NavBar() {
  const { user, logout, loading } = useAuth();
  const router = useRouter();

  return (
    <nav className="border-b border-gray-800 bg-surface/80 backdrop-blur-sm">
      <div className="max-w-7xl mx-auto px-6 py-3 flex items-center justify-between">
        <button
          onClick={() => router.push("/")}
          className="text-lg font-bold text-primary tracking-tight"
        >
          Kernl
        </button>
        <div className="flex items-center gap-4 text-sm">
          {!loading && user ? (
            <>
              <span className="text-text-secondary">{user.email}</span>
              <button
                onClick={() => { logout(); router.push("/login"); }}
                className="text-text-secondary hover:text-foreground"
              >
                Sign Out
              </button>
            </>
          ) : (
            <>
              <button
                onClick={() => router.push("/login")}
                className="text-text-secondary hover:text-foreground"
              >
                Sign In
              </button>
              <button
                onClick={() => router.push("/register")}
                className="bg-primary text-background font-bold px-4 py-1.5 text-xs hover:opacity-90"
              >
                Sign Up
              </button>
            </>
          )}
        </div>
      </div>
    </nav>
  );
}