2025-07-27 10:05:37 -07:00
|
|
|
"use client";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
2025-07-27 10:05:37 -07:00
|
|
|
import type { LucideIcon } from "lucide-react";
|
2025-07-27 10:41:15 -07:00
|
|
|
import type * as React from "react";
|
2025-08-02 21:20:36 -07:00
|
|
|
import { useMemo } from "react";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
|
|
|
|
import {
|
2025-07-27 10:05:37 -07:00
|
|
|
SidebarGroup,
|
2025-07-27 10:41:15 -07:00
|
|
|
SidebarGroupLabel,
|
2025-07-27 10:05:37 -07:00
|
|
|
SidebarMenu,
|
|
|
|
|
SidebarMenuButton,
|
|
|
|
|
SidebarMenuItem,
|
|
|
|
|
} from "@/components/ui/sidebar";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
2025-08-02 21:20:36 -07:00
|
|
|
interface NavSecondaryItem {
|
|
|
|
|
title: string;
|
|
|
|
|
url: string;
|
|
|
|
|
icon: LucideIcon;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-07 23:47:06 -07:00
|
|
|
export function NavSecondary({
|
2025-07-27 10:05:37 -07:00
|
|
|
items,
|
|
|
|
|
...props
|
2025-04-07 23:47:06 -07:00
|
|
|
}: {
|
2025-08-02 21:20:36 -07:00
|
|
|
items: NavSecondaryItem[];
|
2025-04-07 23:47:06 -07:00
|
|
|
} & React.ComponentPropsWithoutRef<typeof SidebarGroup>) {
|
2025-08-02 21:20:36 -07:00
|
|
|
// Memoize items to prevent unnecessary re-renders
|
|
|
|
|
const memoizedItems = useMemo(() => items, [items]);
|
|
|
|
|
|
2025-07-27 10:05:37 -07:00
|
|
|
return (
|
|
|
|
|
<SidebarGroup {...props}>
|
|
|
|
|
<SidebarGroupLabel>SearchSpace</SidebarGroupLabel>
|
|
|
|
|
<SidebarMenu>
|
2025-08-02 21:20:36 -07:00
|
|
|
{memoizedItems.map((item, index) => (
|
2025-07-27 10:05:37 -07:00
|
|
|
<SidebarMenuItem key={`${item.title}-${index}`}>
|
2025-08-02 21:20:36 -07:00
|
|
|
<SidebarMenuButton asChild size="sm" aria-label={item.title}>
|
2025-07-27 10:05:37 -07:00
|
|
|
<a href={item.url}>
|
|
|
|
|
<item.icon />
|
|
|
|
|
<span>{item.title}</span>
|
|
|
|
|
</a>
|
|
|
|
|
</SidebarMenuButton>
|
|
|
|
|
</SidebarMenuItem>
|
|
|
|
|
))}
|
|
|
|
|
</SidebarMenu>
|
|
|
|
|
</SidebarGroup>
|
|
|
|
|
);
|
2025-04-07 23:47:06 -07:00
|
|
|
}
|