import { redirect } from 'next/navigation' import Image from 'next/image' import { auth } from '@/lib/auth' export default async function AuthLayout({ children, }: { children: React.ReactNode }) { let session = null try { session = await auth() } catch (error) { // Auth check failed, continue as unauthenticated console.error('Auth check failed in auth layout:', error) } // Redirect logged-in users to their dashboard // But NOT if they still need to set their password if (session?.user && !session.user.mustSetPassword) { const role = session.user.role if (role === 'SUPER_ADMIN' || role === 'PROGRAM_ADMIN') { redirect('/admin') } else if (role === 'JURY_MEMBER') { redirect('/jury') } else if (role === 'OBSERVER') { redirect('/observer') } else if (role === 'MENTOR') { redirect('/mentor') } } return (