chore(release): snapshot 1.4.2
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { DashboardLayout } from '@/components/layout/DashboardLayout';
|
||||
import { AgencyBranding } from '@/components/layout/AgencyBranding';
|
||||
import AuthGuard from '@/components/auth/AuthGuard';
|
||||
import { useState, useEffect } from 'react';
|
||||
import {
|
||||
HomeIcon,
|
||||
RocketLaunchIcon,
|
||||
@@ -119,10 +120,60 @@ interface AgencyLayoutClientProps {
|
||||
}
|
||||
|
||||
export function AgencyLayoutClient({ children, colors }: AgencyLayoutClientProps) {
|
||||
const [filteredMenuItems, setFilteredMenuItems] = useState(AGENCY_MENU_ITEMS);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchTenantSolutions = async () => {
|
||||
try {
|
||||
console.log('🔍 Buscando soluções do tenant...');
|
||||
const response = await fetch('/api/tenant/solutions', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${localStorage.getItem('token')}`,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('📡 Response status:', response.status);
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log('📦 Dados recebidos:', data);
|
||||
const solutions = data.solutions || [];
|
||||
console.log('✅ Soluções:', solutions);
|
||||
|
||||
// Mapear slugs de solutions para IDs de menu
|
||||
const solutionSlugs = solutions.map((s: any) => s.slug.toLowerCase());
|
||||
console.log('🏷️ Slugs das soluções:', solutionSlugs);
|
||||
|
||||
// Sempre mostrar dashboard + soluções disponíveis
|
||||
const filtered = AGENCY_MENU_ITEMS.filter(item => {
|
||||
if (item.id === 'dashboard') return true;
|
||||
return solutionSlugs.includes(item.id);
|
||||
});
|
||||
|
||||
console.log('📋 Menu filtrado:', filtered.map(i => i.id));
|
||||
setFilteredMenuItems(filtered);
|
||||
} else {
|
||||
console.error('❌ Erro na resposta:', response.status);
|
||||
// Em caso de erro, mostrar todos (fallback)
|
||||
setFilteredMenuItems(AGENCY_MENU_ITEMS);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Error fetching solutions:', error);
|
||||
// Em caso de erro, mostrar todos (fallback)
|
||||
setFilteredMenuItems(AGENCY_MENU_ITEMS);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchTenantSolutions();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AuthGuard>
|
||||
<AgencyBranding colors={colors} />
|
||||
<DashboardLayout menuItems={AGENCY_MENU_ITEMS}>
|
||||
<DashboardLayout menuItems={loading ? [AGENCY_MENU_ITEMS[0]] : filteredMenuItems}>
|
||||
{children}
|
||||
</DashboardLayout>
|
||||
</AuthGuard>
|
||||
|
||||
Reference in New Issue
Block a user