🚀 Initial commit: Versão atual do TrackSteel APP
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import { SidebarMenuItem, SidebarMenuButton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem } from "@/components/ui/sidebar";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { MenuItem } from './types';
|
||||
|
||||
interface SidebarMenuItemProps {
|
||||
item: MenuItem;
|
||||
isActive: (url: string) => boolean;
|
||||
canAccessItem: (itemKey: string) => boolean;
|
||||
isAdmin: boolean;
|
||||
openGroups: { [key: string]: boolean };
|
||||
onSubmenuToggle: (itemKey: string, currentState: boolean) => void;
|
||||
onMenuItemClick: (hasSubItems?: boolean) => void;
|
||||
getIconProps: (itemKey?: string) => any;
|
||||
}
|
||||
|
||||
export const AppSidebarMenuItem: React.FC<SidebarMenuItemProps> = ({
|
||||
item,
|
||||
isActive,
|
||||
canAccessItem,
|
||||
isAdmin,
|
||||
openGroups,
|
||||
onSubmenuToggle,
|
||||
onMenuItemClick,
|
||||
getIconProps
|
||||
}) => {
|
||||
const canAccess = canAccessItem(item.key);
|
||||
|
||||
if (!canAccess && !isAdmin) {
|
||||
return null; // Don't show item if no access
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarMenuItem key={item.key || item.title}>
|
||||
{item.subItems && item.subItems.length > 0 ? (
|
||||
<Collapsible
|
||||
open={openGroups[item.key] || false}
|
||||
onOpenChange={(open) => onSubmenuToggle(item.key, openGroups[item.key] || false)}
|
||||
>
|
||||
<CollapsibleTrigger asChild>
|
||||
<SidebarMenuButton className="w-full justify-between">
|
||||
<div className="flex items-center">
|
||||
{item.icon && <item.icon {...getIconProps(item.key)} />}
|
||||
<span>{item.title}</span>
|
||||
</div>
|
||||
<ChevronRight className="h-4 w-4 transition-transform data-[state=open]:rotate-90" />
|
||||
</SidebarMenuButton>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent>
|
||||
<SidebarMenuSub>
|
||||
{item.subItems?.map((subItem) => {
|
||||
// Filter theme customization for non-admins
|
||||
if (subItem.url === "/admin/theme-customization" && !isAdmin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<SidebarMenuSubItem key={subItem.key || subItem.title}>
|
||||
<SidebarMenuSubButton
|
||||
asChild
|
||||
isActive={isActive(subItem.url)}
|
||||
>
|
||||
<Link
|
||||
to={subItem.url}
|
||||
onClick={() => onMenuItemClick(false)}
|
||||
>
|
||||
{subItem.icon && <subItem.icon className="mr-2 h-4 w-4" />}
|
||||
<span>{subItem.title}</span>
|
||||
</Link>
|
||||
</SidebarMenuSubButton>
|
||||
</SidebarMenuSubItem>
|
||||
);
|
||||
})}
|
||||
</SidebarMenuSub>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
) : (
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
isActive={isActive(item.url || '#')}
|
||||
>
|
||||
<Link
|
||||
to={item.url || '#'}
|
||||
onClick={() => onMenuItemClick(false)}
|
||||
>
|
||||
{item.icon && <item.icon {...getIconProps(item.key)} />}
|
||||
<span>{item.title}</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
)}
|
||||
</SidebarMenuItem>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,280 @@
|
||||
import {
|
||||
BarChart3,
|
||||
FileText,
|
||||
Wrench,
|
||||
Warehouse,
|
||||
FolderOpen,
|
||||
Building2,
|
||||
Monitor,
|
||||
Truck,
|
||||
HardHat,
|
||||
CheckSquare,
|
||||
Book,
|
||||
Clipboard,
|
||||
MessageSquare,
|
||||
Users,
|
||||
Network,
|
||||
Settings,
|
||||
Shield,
|
||||
UserCog,
|
||||
Cog
|
||||
} from "lucide-react";
|
||||
import { MenuItem, MenuGroup } from './types';
|
||||
|
||||
export const menuGroups: MenuGroup[] = [
|
||||
{
|
||||
id: 'main',
|
||||
name: 'Principal',
|
||||
color: '#3b82f6',
|
||||
items: [
|
||||
{
|
||||
key: "dashboard",
|
||||
title: "Dashboard",
|
||||
url: "/dashboard",
|
||||
icon: BarChart3,
|
||||
},
|
||||
{
|
||||
key: "cadastro",
|
||||
title: "Cadastro",
|
||||
icon: FileText,
|
||||
subItems: [
|
||||
{
|
||||
key: "ficha-tecnica-of",
|
||||
title: "Ficha Técnica da OF",
|
||||
url: "/cadastro-of",
|
||||
},
|
||||
{
|
||||
key: "cadastro-pecas",
|
||||
title: "Cadastro de Peças",
|
||||
url: "/seletor-of",
|
||||
},
|
||||
{
|
||||
key: "equipamentos",
|
||||
title: "Equipamentos",
|
||||
url: "/equipamentos",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "ferramentas",
|
||||
title: "Ferramentas",
|
||||
icon: Wrench,
|
||||
requiresSpecialPermission: true,
|
||||
subItems: [
|
||||
{
|
||||
key: "conversores",
|
||||
title: "Conversores de dados",
|
||||
url: "/ferramentas/conversores",
|
||||
},
|
||||
{
|
||||
key: "inconsistencias",
|
||||
title: "Ver Inconsistências",
|
||||
url: "/ferramentas/inconsistencias",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "estoque",
|
||||
title: "Estoque",
|
||||
icon: Warehouse,
|
||||
subItems: [
|
||||
{
|
||||
key: "estoque-main",
|
||||
title: "Estoque",
|
||||
url: "/estoque",
|
||||
},
|
||||
{
|
||||
key: "solicitacao-compras",
|
||||
title: "Solicitação de Compras",
|
||||
url: "/estoque/solicitacao-compras",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "ofs",
|
||||
title: "OFs",
|
||||
icon: FolderOpen,
|
||||
subItems: [
|
||||
{
|
||||
key: "ordens-fabricacao",
|
||||
title: "Ordens de Fabricação",
|
||||
url: "/ofs",
|
||||
},
|
||||
{
|
||||
key: "cronograma",
|
||||
title: "Cronograma",
|
||||
url: "/ofs/cronograma",
|
||||
},
|
||||
{
|
||||
key: "ofs-concluidas",
|
||||
title: "OFs Concluídas",
|
||||
url: "/cadastro/ofs-concluidas",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "producao",
|
||||
title: "Produção",
|
||||
icon: Building2,
|
||||
subItems: [
|
||||
{
|
||||
key: "visao-geral",
|
||||
title: "Visão Geral",
|
||||
url: "/producao",
|
||||
},
|
||||
{
|
||||
key: "diario-producao",
|
||||
title: "Diário de Produção",
|
||||
url: "/diario-producao",
|
||||
},
|
||||
{
|
||||
key: "apontamento-producao",
|
||||
title: "Apontamento de Produção",
|
||||
url: "/apontamento-producao",
|
||||
},
|
||||
{
|
||||
key: "dashboard-producao",
|
||||
title: "Dashboard de Produção",
|
||||
url: "/dashboard-producao",
|
||||
},
|
||||
{
|
||||
key: "prioridades-fabricacao",
|
||||
title: "Prioridades de Fabricação",
|
||||
url: "/prioridades-fabricacao",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "painel-industrial",
|
||||
title: "Painel Industrial",
|
||||
url: "/painel-industrial",
|
||||
icon: Monitor,
|
||||
},
|
||||
{
|
||||
key: "expedicao",
|
||||
title: "Expedição",
|
||||
url: "/expedicao",
|
||||
icon: Truck,
|
||||
},
|
||||
{
|
||||
key: "obra",
|
||||
title: "Obra",
|
||||
icon: HardHat,
|
||||
subItems: [
|
||||
{
|
||||
key: "dashboard-obras",
|
||||
title: "Dashboard de Obras",
|
||||
url: "/obra",
|
||||
},
|
||||
{
|
||||
key: "configuracoes-obra",
|
||||
title: "Configurações da Obra",
|
||||
url: "/obra/configuracoes",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "tarefas",
|
||||
title: "Tarefas",
|
||||
icon: CheckSquare,
|
||||
requiresSpecialPermission: true,
|
||||
subItems: [
|
||||
{
|
||||
key: "lista-tarefas",
|
||||
title: "Lista de Tarefas",
|
||||
url: "/tarefas",
|
||||
},
|
||||
{
|
||||
key: "historico-tarefas",
|
||||
title: "Histórico de Tarefas",
|
||||
url: "/tarefas/historico",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "biblioteca",
|
||||
title: "Biblioteca",
|
||||
icon: Book,
|
||||
subItems: [
|
||||
{
|
||||
key: "catalogos",
|
||||
title: "Catálogos",
|
||||
url: "/biblioteca/catalogos",
|
||||
},
|
||||
{
|
||||
key: "normas",
|
||||
title: "Normas",
|
||||
url: "/biblioteca/normas",
|
||||
},
|
||||
{
|
||||
key: "referencias",
|
||||
title: "Referências",
|
||||
url: "/biblioteca/referencias",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "sistema",
|
||||
title: "Sistema",
|
||||
url: "/sistema",
|
||||
icon: Clipboard,
|
||||
requiresSpecialPermission: true,
|
||||
},
|
||||
{
|
||||
key: "sugestoes",
|
||||
title: "Sugestões",
|
||||
url: "/sugestoes",
|
||||
icon: MessageSquare,
|
||||
requiresSpecialPermission: true,
|
||||
},
|
||||
{
|
||||
key: "atribuicoes",
|
||||
title: "Atribuições",
|
||||
url: "/atribuicoes",
|
||||
icon: Users,
|
||||
},
|
||||
{
|
||||
key: "mapa-interativo",
|
||||
title: "Mapa Interativo",
|
||||
url: "/mapa-interativo",
|
||||
icon: Network,
|
||||
},
|
||||
{
|
||||
key: "configuracoes",
|
||||
title: "Configurações",
|
||||
icon: Settings,
|
||||
subItems: [
|
||||
{
|
||||
key: "configuracoes-gerais",
|
||||
title: "Configurações Gerais",
|
||||
url: "/configuracoes",
|
||||
},
|
||||
{
|
||||
key: "personalizacao-tema",
|
||||
title: "Personalização de Tema",
|
||||
url: "/admin/theme-customization",
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'admin',
|
||||
name: 'Administração',
|
||||
color: '#dc2626',
|
||||
items: [
|
||||
{
|
||||
key: "admin",
|
||||
title: "Admin",
|
||||
url: "/admin",
|
||||
icon: Shield,
|
||||
},
|
||||
{
|
||||
key: "gerenciar-usuarios",
|
||||
title: "Gerenciar Usuários",
|
||||
url: "/user-management",
|
||||
icon: UserCog,
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
import { LucideIcon } from 'lucide-react';
|
||||
|
||||
export interface MenuItem {
|
||||
title: string;
|
||||
url?: string;
|
||||
icon?: LucideIcon; // Make icon optional to support subItems without icons
|
||||
key: string;
|
||||
subItems?: MenuItem[];
|
||||
requiresSpecialPermission?: boolean; // Nova propriedade para menus que precisam de permissão especial
|
||||
}
|
||||
|
||||
export interface MenuGroup {
|
||||
id: string;
|
||||
name: string;
|
||||
color: string;
|
||||
items: MenuItem[];
|
||||
}
|
||||
Reference in New Issue
Block a user