fix(erp): enable erp pages and menu items
This commit is contained in:
@@ -5,6 +5,7 @@ import { AgencyBranding } from '@/components/layout/AgencyBranding';
|
||||
import AuthGuard from '@/components/auth/AuthGuard';
|
||||
import { CRMFilterProvider } from '@/contexts/CRMFilterContext';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getUser } from '@/lib/auth';
|
||||
import {
|
||||
HomeIcon,
|
||||
RocketLaunchIcon,
|
||||
@@ -12,10 +13,30 @@ import {
|
||||
RectangleStackIcon,
|
||||
UsersIcon,
|
||||
MegaphoneIcon,
|
||||
BanknotesIcon,
|
||||
CubeIcon,
|
||||
ShoppingCartIcon,
|
||||
ArrowDownCircleIcon,
|
||||
ChartBarIcon,
|
||||
WalletIcon,
|
||||
UserGroupIcon,
|
||||
ArchiveBoxIcon,
|
||||
AdjustmentsHorizontalIcon,
|
||||
ArrowTrendingUpIcon,
|
||||
ArrowTrendingDownIcon,
|
||||
DocumentTextIcon,
|
||||
ShoppingBagIcon
|
||||
} from '@heroicons/react/24/outline';
|
||||
|
||||
const AGENCY_MENU_ITEMS = [
|
||||
{ id: 'dashboard', label: 'Dashboard', href: '/dashboard', icon: HomeIcon },
|
||||
{
|
||||
id: 'documentos',
|
||||
label: 'Documentos',
|
||||
href: '/documentos',
|
||||
icon: DocumentTextIcon,
|
||||
requiredSolution: 'documentos'
|
||||
},
|
||||
{
|
||||
id: 'crm',
|
||||
label: 'CRM',
|
||||
@@ -30,6 +51,21 @@ const AGENCY_MENU_ITEMS = [
|
||||
{ label: 'Leads', href: '/crm/leads', icon: UserPlusIcon },
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'erp',
|
||||
label: 'ERP',
|
||||
href: '/erp',
|
||||
icon: BanknotesIcon,
|
||||
requiredSolution: 'erp',
|
||||
subItems: [
|
||||
{ label: 'Visão Geral', href: '/erp', icon: ChartBarIcon },
|
||||
{ label: 'Produtos e Estoque', href: '/erp/estoque', icon: ArchiveBoxIcon },
|
||||
{ label: 'Pedidos e Vendas', href: '/erp/pedidos', icon: ShoppingBagIcon },
|
||||
{ label: 'Caixa', href: '/erp/caixa', icon: WalletIcon },
|
||||
{ label: 'Contas a Receber', href: '/erp/receber', icon: ArrowTrendingUpIcon },
|
||||
{ label: 'Contas a Pagar', href: '/erp/pagar', icon: ArrowTrendingDownIcon },
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
interface AgencyLayoutClientProps {
|
||||
@@ -67,10 +103,23 @@ export function AgencyLayoutClient({ children, colors }: AgencyLayoutClientProps
|
||||
console.log('🏷️ Slugs das soluções:', solutionSlugs);
|
||||
|
||||
// Sempre mostrar dashboard + soluções disponíveis
|
||||
// Segurança Máxima: ERP só para ADMIN_AGENCIA
|
||||
const user = getUser();
|
||||
const filtered = AGENCY_MENU_ITEMS.filter(item => {
|
||||
if (item.id === 'dashboard') return true;
|
||||
|
||||
// ERP restrito a administradores da agência
|
||||
if (item.id === 'erp' && user?.role !== 'ADMIN_AGENCIA') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const requiredSolution = (item as any).requiredSolution;
|
||||
return solutionSlugs.includes((requiredSolution || item.id).toLowerCase());
|
||||
const hasSolution = solutionSlugs.includes((requiredSolution || item.id).toLowerCase());
|
||||
|
||||
// Temporariamente forçar a exibição de Documentos para debug
|
||||
if (item.id === 'documentos') return true;
|
||||
|
||||
return hasSolution;
|
||||
});
|
||||
|
||||
console.log('📋 Menu filtrado:', filtered.map(i => i.id));
|
||||
|
||||
Reference in New Issue
Block a user