import { setRequestLocale, getTranslations } from 'next-intl/server'; import { signOut } from '@/auth'; import { getSafeSession } from '@/lib/safeAuth'; import { Link } from '@/i18n/routing'; import { LanguageSwitcher } from '@/components/LanguageSwitcher'; export default async function AdminLayout({ children, params, }: { children: React.ReactNode; params: Promise<{ locale: string }>; }) { const { locale } = await params; setRequestLocale(locale); const session = await getSafeSession(); const t = await getTranslations('admin'); const tr = await getTranslations('adminReplacements'); // Public login page is handled in admin/login/page.tsx — but layout still wraps it. // For non-login admin routes we redirect when not signed in via a route segment guard. // Here we expose `session` to the rendered children via a server util; simpler: // we redirect from this layout only when path is NOT /admin/login. Since segment // info isn't easily accessible, we let each page check itself. Login page will not redirect. // We do the protection by rendering the nav only when signed in; pages must call requireAdmin(). return (