"use client";
import {
RiArrowLeftRightLine,
RiBankCard2Line,
RiBankLine,
RiCalendarEventLine,
RiDashboardLine,
RiFileChartLine,
RiFundsLine,
RiGroupLine,
RiInboxLine,
RiMenuLine,
RiPriceTag3Line,
RiSparklingLine,
RiTodoLine,
} from "@remixicon/react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useState } from "react";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuList,
NavigationMenuTrigger,
} from "@/components/ui/navigation-menu";
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet";
import { cn } from "@/lib/utils/ui";
type TopNavMenuProps = {
preLancamentosCount?: number;
};
const triggerClass =
"!bg-transparent !text-foreground/80 hover:!bg-foreground/10 hover:!text-foreground focus:!bg-foreground/10 focus:!text-foreground data-[state=open]:!bg-foreground/10 data-[state=open]:!text-foreground";
function SimpleNavLink({
href,
children,
}: {
href: string;
children: React.ReactNode;
}) {
const pathname = usePathname();
const isActive =
href === "/dashboard"
? pathname === href
: pathname === href || pathname.startsWith(`${href}/`);
return (
{children}
);
}
type DropdownLinkItem = {
href: string;
label: string;
icon: React.ReactNode;
badge?: number;
};
function DropdownLinkList({ items }: { items: DropdownLinkItem[] }) {
return (
{items.map((item) => (
-
{item.icon}
{item.label}
{item.badge && item.badge > 0 ? (
{item.badge}
) : null}
))}
);
}
function MobileNavLink({
href,
icon,
children,
onClick,
badge,
}: {
href: string;
icon: React.ReactNode;
children: React.ReactNode;
onClick?: () => void;
badge?: number;
}) {
const pathname = usePathname();
const isActive =
href === "/dashboard"
? pathname === href
: pathname === href || pathname.startsWith(`${href}/`);
return (
{icon}
{children}
{badge && badge > 0 ? (
{badge}
) : null}
);
}
function MobileSectionLabel({ label }: { label: string }) {
return (
{label}
);
}
export function TopNavMenu({ preLancamentosCount = 0 }: TopNavMenuProps) {
const [sheetOpen, setSheetOpen] = useState(false);
const close = () => setSheetOpen(false);
const lancamentosItems: DropdownLinkItem[] = [
{
href: "/lancamentos",
label: "Lançamentos",
icon: ,
},
{
href: "/pre-lancamentos",
label: "Pré-Lançamentos",
icon: ,
badge: preLancamentosCount,
},
];
const organizacaoItems: DropdownLinkItem[] = [
{
href: "/orcamentos",
label: "Orçamentos",
icon: ,
},
{
href: "/pagadores",
label: "Pagadores",
icon: ,
},
{
href: "/categorias",
label: "Categorias",
icon: ,
},
{
href: "/anotacoes",
label: "Anotações",
icon: ,
},
];
const analiseItems: DropdownLinkItem[] = [
{
href: "/insights",
label: "Insights",
icon: ,
},
{
href: "/relatorios/tendencias",
label: "Tendências",
icon: ,
},
{
href: "/relatorios/uso-cartoes",
label: "Uso de Cartões",
icon: ,
},
];
return (
<>
{/* Desktop nav */}
{/* Mobile hamburger */}
Menu
>
);
}