"use client"; import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Inbox, Truck, MessageCircle, ListTodo, MoreHorizontal, X } from "lucide-react"; import { links, type Role } from "./nav-data"; // The 4 most-used sections get their own bottom-bar slot (bar's too narrow // for all 8, and cramming more in defeats the point of a thumb-reachable // tab bar); everything else lives behind "Ещё". const PRIMARY_HREFS = ["/chat", "/orders", "/tasks", "/inquiries"]; const PRIMARY_ICONS: Record = { "/chat": MessageCircle, "/orders": Truck, "/tasks": ListTodo, "/inquiries": Inbox, }; export function MobileNav({ role, unread }: { role: Role; unread: number }) { const pathname = usePathname(); const [moreOpen, setMoreOpen] = useState(false); const visibleLinks = links.filter((link) => link.roles.includes(role)); const primary = PRIMARY_HREFS.map((href) => visibleLinks.find((l) => l.href === href)).filter((l) => l !== undefined); const overflow = visibleLinks.filter((l) => !PRIMARY_HREFS.includes(l.href)); const overflowActive = overflow.some((l) => pathname.startsWith(l.href)); return ( <> {moreOpen && (
setMoreOpen(false)}>
e.stopPropagation()} >
Ещё
{overflow.map(({ href, label, icon: Icon }) => { const active = pathname.startsWith(href); return ( setMoreOpen(false)} className={`flex items-center gap-3 rounded-md px-3 py-2.5 text-sm font-medium ${ active ? "bg-accent-soft text-accent-soft-text" : "text-text-muted hover:bg-surface-hover hover:text-text" }`} > {label} ); })}
)} ); }