'use client'; import { useEffect, useState, type ReactNode } from 'react'; import { useRouter } from 'next/navigation'; import { I18nProvider } from '@/lib/i18n'; import { ToastProvider } from '@/components/ui/Toast'; import { Navigation } from '@/components/Navigation'; import { isAuthenticated } from '@/lib/api'; export default function LocaleLayout({ children, params, }: { children: ReactNode; params: { locale: string }; }) { const router = useRouter(); const [checked, setChecked] = useState(false); // Auth guard: redirect to /login if no token is present useEffect(() => { if (!isAuthenticated()) { router.replace('/login'); return; } setChecked(true); }, [router]); // Show nothing while redirecting (avoids flashing protected content) if (!checked) { return (
Loading…
); } const locale = params.locale === 'en' ? 'en' : 'de'; return (
{/* Main content area — offset for sidebar on desktop */}
{children}
); }