Files
Horux360/apps/web/app/(dashboard)/layout.tsx
Consultoria AS c3ce7199af feat: bulk XML upload, period selector, and session persistence
- Add bulk XML CFDI upload support (up to 300MB)
- Add period selector component for month/year navigation
- Fix session persistence on page refresh (Zustand hydration)
- Fix income/expense classification based on tenant RFC
- Fix IVA calculation from XML (correct Impuestos element)
- Add error handling to reportes page
- Support multiple CORS origins
- Update reportes service with proper Decimal/BigInt handling
- Add RFC to tenant view store for proper CFDI classification
- Update README with changelog and new features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 06:51:53 +00:00

87 lines
2.4 KiB
TypeScript

'use client';
import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useAuthStore } from '@/stores/auth-store';
import { useThemeStore } from '@/stores/theme-store';
import { themes } from '@/themes';
import { Sidebar } from '@/components/layouts/sidebar';
import { TopNav } from '@/components/layouts/topnav';
import { SidebarCompact } from '@/components/layouts/sidebar-compact';
import { SidebarFloating } from '@/components/layouts/sidebar-floating';
import { cn } from '@/lib/utils';
export default function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
const router = useRouter();
const { isAuthenticated, _hasHydrated } = useAuthStore();
const { theme } = useThemeStore();
const currentTheme = themes[theme];
const layout = currentTheme.layout;
useEffect(() => {
// Solo verificar autenticación después de que el store se rehidrate
if (_hasHydrated && !isAuthenticated) {
router.push('/login');
}
}, [isAuthenticated, _hasHydrated, router]);
// Mostrar loading mientras se rehidrata el store
if (!_hasHydrated) {
return (
<div className="min-h-screen flex items-center justify-center bg-background">
<div className="animate-pulse text-muted-foreground">Cargando...</div>
</div>
);
}
if (!isAuthenticated) {
return null;
}
// Render layout based on theme
const renderNavigation = () => {
switch (layout) {
case 'topnav':
return <TopNav />;
case 'sidebar-compact':
return <SidebarCompact />;
case 'sidebar-floating':
return <SidebarFloating />;
case 'sidebar-standard':
default:
return <Sidebar />;
}
};
const getContentClasses = () => {
switch (layout) {
case 'topnav':
return 'pt-16'; // Top padding for fixed top nav
case 'sidebar-compact':
return 'pl-16'; // Small left padding for compact sidebar
case 'sidebar-floating':
return 'pl-72 pr-4 py-4'; // Padding for floating sidebar
case 'sidebar-standard':
default:
return 'pl-64'; // Standard sidebar width
}
};
return (
<div className={cn(
'min-h-screen bg-background',
layout === 'sidebar-floating' && 'bg-gradient-to-br from-background via-background to-muted/20'
)}>
{renderNavigation()}
<div className={getContentClasses()}>
{children}
</div>
</div>
);
}