"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Lock } from "lucide-react"; import type { SidebarNavItem } from "@/config/navigation"; import { useI18n } from "@/i18n/i18n-context"; import { cn } from "@/lib/utils"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "@/components/ui/tooltip"; interface SidebarItemProps { item: SidebarNavItem; collapsed?: boolean; } export function SidebarItem({ item, collapsed = false }: SidebarItemProps) { const pathname = usePathname(); const { t } = useI18n(); const Icon = item.icon; const title = t(item.titleKey); const isActive = !!item.href && (pathname === item.href || pathname?.startsWith(`${item.href}/`)); const disabled = item.comingSoon || !item.href; const content = ( {!collapsed && ( <> {title} {item.comingSoon && ( {t("common.comingSoon")} )} )} ); const needsTooltip = collapsed || disabled; const tooltipLabel = item.tooltipKey ? t(item.tooltipKey) : title; const wrapped = disabled ? (
{content}
) : ( {content} ); if (!needsTooltip) return wrapped; return ( {wrapped} {tooltipLabel} ); }