Consolida recepcoes, stock, equipamentos e identidade SGC
This commit is contained in:
@@ -7,20 +7,36 @@ import {
|
||||
SidebarMenuItem,
|
||||
} from '@/components/ui/sidebar';
|
||||
import { useCurrentUrl } from '@/hooks/use-current-url';
|
||||
import { toUrl } from '@/lib/utils';
|
||||
import type { NavItem } from '@/types';
|
||||
|
||||
export function NavMain({ items }: { items: NavItem[] }) {
|
||||
const { isCurrentUrl } = useCurrentUrl();
|
||||
export function NavMain({
|
||||
items,
|
||||
title = 'Navegação',
|
||||
}: {
|
||||
items: NavItem[];
|
||||
title?: string;
|
||||
}) {
|
||||
const { isCurrentOrParentUrl, currentUrl } = useCurrentUrl();
|
||||
const receivingOrder = /^\/ordens\/\d+\/recepcoes/.test(currentUrl);
|
||||
|
||||
return (
|
||||
<SidebarGroup className="px-2 py-0">
|
||||
<SidebarGroupLabel>Platform</SidebarGroupLabel>
|
||||
<SidebarGroupLabel>{title}</SidebarGroupLabel>
|
||||
<SidebarMenu>
|
||||
{items.map((item) => (
|
||||
<SidebarMenuItem key={item.title}>
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
isActive={isCurrentUrl(item.href)}
|
||||
isActive={
|
||||
(toUrl(item.href) === '/recepcoes' &&
|
||||
receivingOrder) ||
|
||||
(isCurrentOrParentUrl(item.href) &&
|
||||
!(
|
||||
toUrl(item.href) === '/ordens' &&
|
||||
receivingOrder
|
||||
))
|
||||
}
|
||||
tooltip={{ children: item.title }}
|
||||
>
|
||||
<Link href={item.href} prefetch>
|
||||
|
||||
Reference in New Issue
Block a user