gaurv007 commited on
Commit
db4cb30
·
verified ·
1 Parent(s): 01389c4

fix: nav.tsx TypeScript error — type Icon as LucideIcon | null

Browse files
Files changed (1) hide show
  1. web/components/nav.tsx +13 -8
web/components/nav.tsx CHANGED
@@ -2,6 +2,7 @@
2
 
3
  import Link from "next/link";
4
  import { usePathname } from "next/navigation";
 
5
  import {
6
  ShieldCheck, Menu, X, Crown, GitCompare, LayoutDashboard,
7
  ScanText, Settings, LogIn, Zap
@@ -9,6 +10,12 @@ import {
9
  import { useState, useEffect } from "react";
10
  import { createClient } from "@/lib/supabase/client";
11
 
 
 
 
 
 
 
12
  export function Nav() {
13
  const [open, setOpen] = useState(false);
14
  const [userEmail, setUserEmail] = useState<string | null>(null);
@@ -35,19 +42,18 @@ export function Nav() {
35
  });
36
  }, []);
37
 
38
- // Build links dynamically based on auth state
39
- const publicLinks = [
40
  { href: "/#features", label: "Features" },
41
  { href: "/#pricing", label: "Pricing" },
42
  ];
43
 
44
- const appLinks = [
45
  { href: "/dashboard-pages/dashboard", label: "Dashboard", icon: LayoutDashboard },
46
  { href: "/dashboard-pages/analyze", label: "Scanner", icon: ScanText },
47
  { href: "/dashboard-pages/compare", label: "Compare", icon: GitCompare },
48
  ];
49
 
50
- const links = isLoggedIn ? appLinks : publicLinks;
51
 
52
  return (
53
  <nav className="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-zinc-100">
@@ -62,7 +68,7 @@ export function Nav() {
62
  {/* Desktop Nav */}
63
  <div className="hidden md:flex items-center gap-1">
64
  {links.map((l) => {
65
- const Icon = "icon" in l ? l.icon : null;
66
  const isActive = pathname === l.href;
67
  return (
68
  <Link key={l.href} href={l.href}
@@ -75,7 +81,6 @@ export function Nav() {
75
  );
76
  })}
77
 
78
- {/* Admin link — always visible for admins */}
79
  {isAdmin && (
80
  <Link href="/admin"
81
  className={`flex items-center gap-1.5 px-3 py-1.5 text-[13px] rounded-md transition-colors ${
@@ -104,7 +109,7 @@ export function Nav() {
104
  </>
105
  ) : (
106
  <>
107
- {!isLoggedIn && loaded && (
108
  <Link href="/auth/login"
109
  className="flex items-center gap-1.5 px-3 py-1.5 text-[13px] text-zinc-500 hover:text-zinc-900 rounded-md hover:bg-zinc-50 transition-colors">
110
  <LogIn className="w-3.5 h-3.5" /> Log in
@@ -133,7 +138,7 @@ export function Nav() {
133
  ))}
134
  {isAdmin && (
135
  <Link href="/admin" onClick={() => setOpen(false)}
136
- className="block px-3 py-2.5 text-sm text-amber-600 rounded-md hover:bg-amber-50 flex items-center gap-2">
137
  <Crown className="w-4 h-4" /> Admin Panel
138
  </Link>
139
  )}
 
2
 
3
  import Link from "next/link";
4
  import { usePathname } from "next/navigation";
5
+ import type { LucideIcon } from "lucide-react";
6
  import {
7
  ShieldCheck, Menu, X, Crown, GitCompare, LayoutDashboard,
8
  ScanText, Settings, LogIn, Zap
 
10
  import { useState, useEffect } from "react";
11
  import { createClient } from "@/lib/supabase/client";
12
 
13
+ interface NavLink {
14
+ href: string;
15
+ label: string;
16
+ icon?: LucideIcon;
17
+ }
18
+
19
  export function Nav() {
20
  const [open, setOpen] = useState(false);
21
  const [userEmail, setUserEmail] = useState<string | null>(null);
 
42
  });
43
  }, []);
44
 
45
+ const publicLinks: NavLink[] = [
 
46
  { href: "/#features", label: "Features" },
47
  { href: "/#pricing", label: "Pricing" },
48
  ];
49
 
50
+ const appLinks: NavLink[] = [
51
  { href: "/dashboard-pages/dashboard", label: "Dashboard", icon: LayoutDashboard },
52
  { href: "/dashboard-pages/analyze", label: "Scanner", icon: ScanText },
53
  { href: "/dashboard-pages/compare", label: "Compare", icon: GitCompare },
54
  ];
55
 
56
+ const links: NavLink[] = isLoggedIn ? appLinks : publicLinks;
57
 
58
  return (
59
  <nav className="sticky top-0 z-50 bg-white/80 backdrop-blur-md border-b border-zinc-100">
 
68
  {/* Desktop Nav */}
69
  <div className="hidden md:flex items-center gap-1">
70
  {links.map((l) => {
71
+ const Icon = l.icon ?? null;
72
  const isActive = pathname === l.href;
73
  return (
74
  <Link key={l.href} href={l.href}
 
81
  );
82
  })}
83
 
 
84
  {isAdmin && (
85
  <Link href="/admin"
86
  className={`flex items-center gap-1.5 px-3 py-1.5 text-[13px] rounded-md transition-colors ${
 
109
  </>
110
  ) : (
111
  <>
112
+ {loaded && (
113
  <Link href="/auth/login"
114
  className="flex items-center gap-1.5 px-3 py-1.5 text-[13px] text-zinc-500 hover:text-zinc-900 rounded-md hover:bg-zinc-50 transition-colors">
115
  <LogIn className="w-3.5 h-3.5" /> Log in
 
138
  ))}
139
  {isAdmin && (
140
  <Link href="/admin" onClick={() => setOpen(false)}
141
+ className="px-3 py-2.5 text-sm text-amber-600 rounded-md hover:bg-amber-50 flex items-center gap-2">
142
  <Crown className="w-4 h-4" /> Admin Panel
143
  </Link>
144
  )}