All files / client/src/components app-sidebar.tsx

0% Statements 0/10
0% Branches 0/5
0% Functions 0/6
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174                                                                                                                                                                                                                                                                                                                                                           
import { Link, useLocation } from "wouter";
import {
  Sidebar,
  SidebarContent,
  SidebarGroup,
  SidebarGroupContent,
  SidebarGroupLabel,
  SidebarHeader,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarFooter,
} from "@/components/ui/sidebar";
import {
  LayoutDashboard,
  Target,
  FolderKanban,
  Calendar,
  Trophy,
  Settings,
  Sparkles,
  Brain,
  FlaskConical,
  ExternalLink,
  BarChart3,
  Map,
  BookOpen,
  Beaker,
  Cpu,
} from "lucide-react";
import { categories, type Category } from "@shared/schema";
import { categoryColors } from "@/lib/categories";
 
const mainNavItems = [
  { title: "Dashboard", url: "/", icon: LayoutDashboard },
  { title: "All Resolutions", url: "/resolutions", icon: Target },
  { title: "Calendar", url: "/calendar", icon: Calendar },
  { title: "Achievements", url: "/achievements", icon: Trophy },
  { title: "Analytics", url: "/analytics", icon: BarChart3 },
  { title: "AI Analytics", url: "/ai-dashboard", icon: Brain },
  { title: "Prompt Playground", url: "/prompt-playground", icon: FlaskConical },
];
 
const modelMapItems = [
  { title: "My Map", url: "/model-map", icon: Map },
  { title: "Use Cases", url: "/model-map/use-cases", icon: BookOpen },
  { title: "Test Lab", url: "/model-map/test-lab", icon: Beaker },
  { title: "My Models", url: "/model-map/my-models", icon: Cpu },
];
 
interface AppSidebarProps {
  selectedCategory: Category | null;
  onCategorySelect: (category: Category | null) => void;
}
 
export function AppSidebar({ selectedCategory, onCategorySelect }: AppSidebarProps) {
  const [location] = useLocation();
 
  return (
    <Sidebar>
      <SidebarHeader className="p-4">
        <Link href="/" className="flex items-center gap-2">
          <div className="rounded-md bg-primary p-1.5">
            <Sparkles className="h-5 w-5 text-primary-foreground" />
          </div>
          <span className="text-lg font-semibold">Resolutions</span>
        </Link>
      </SidebarHeader>
      <SidebarContent>
        <SidebarGroup>
          <SidebarGroupLabel>Navigation</SidebarGroupLabel>
          <SidebarGroupContent>
            <SidebarMenu>
              {mainNavItems.map((item) => (
                <SidebarMenuItem key={item.title}>
                  <SidebarMenuButton 
                    asChild 
                    isActive={location === item.url}
                    data-testid={`nav-${item.title.toLowerCase().replace(/\s+/g, '-')}`}
                  >
                    <Link href={item.url}>
                      <item.icon className="h-4 w-4" />
                      <span>{item.title}</span>
                    </Link>
                  </SidebarMenuButton>
                </SidebarMenuItem>
              ))}
            </SidebarMenu>
          </SidebarGroupContent>
        </SidebarGroup>
 
        <SidebarGroup>
          <SidebarGroupLabel>Model Map</SidebarGroupLabel>
          <SidebarGroupContent>
            <SidebarMenu>
              {modelMapItems.map((item) => (
                <SidebarMenuItem key={item.title}>
                  <SidebarMenuButton 
                    asChild 
                    isActive={location === item.url || (item.url === "/model-map" && location === "/model-map/my-map")}
                    data-testid={`nav-model-map-${item.title.toLowerCase().replace(/\s+/g, '-')}`}
                  >
                    <Link href={item.url}>
                      <item.icon className="h-4 w-4" />
                      <span>{item.title}</span>
                    </Link>
                  </SidebarMenuButton>
                </SidebarMenuItem>
              ))}
            </SidebarMenu>
          </SidebarGroupContent>
        </SidebarGroup>
 
        <SidebarGroup>
          <SidebarGroupLabel>Categories</SidebarGroupLabel>
          <SidebarGroupContent>
            <SidebarMenu>
              <SidebarMenuItem>
                <SidebarMenuButton 
                  isActive={selectedCategory === null}
                  onClick={() => onCategorySelect(null)}
                  data-testid="filter-all-categories"
                >
                  <FolderKanban className="h-4 w-4" />
                  <span>All Categories</span>
                </SidebarMenuButton>
              </SidebarMenuItem>
              {categories.map((category) => {
                const colors = categoryColors[category];
                return (
                  <SidebarMenuItem key={category}>
                    <SidebarMenuButton 
                      isActive={selectedCategory === category}
                      onClick={() => onCategorySelect(category)}
                      data-testid={`filter-${category.toLowerCase().replace(/\s+/g, '-')}`}
                    >
                      <div className={`h-3 w-3 rounded-sm ${colors.bg}`} />
                      <span>{category}</span>
                    </SidebarMenuButton>
                  </SidebarMenuItem>
                );
              })}
            </SidebarMenu>
          </SidebarGroupContent>
        </SidebarGroup>
      </SidebarContent>
      <SidebarFooter className="p-4">
        <SidebarMenu>
          <SidebarMenuItem>
            <SidebarMenuButton asChild data-testid="nav-settings">
              <Link href="/settings">
                <Settings className="h-4 w-4" />
                <span>Settings</span>
              </Link>
            </SidebarMenuButton>
          </SidebarMenuItem>
        </SidebarMenu>
        <div className="mt-2 pt-2 border-t border-sidebar-border">
          <a
            href={`https://github.com/nexaddo/ten-week-AI-resolution-project/releases/${__APP_VERSION__ !== "dev" ? `tag/${__APP_VERSION__}` : ""}`}
            target="_blank"
            rel="noopener noreferrer"
            className="flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors"
            data-testid="version-link"
          >
            <span>{__APP_VERSION__}</span>
            <ExternalLink className="h-3 w-3" />
          </a>
        </div>
      </SidebarFooter>
    </Sidebar>
  );
}