2026-01-30 13:41:32 +01:00
|
|
|
import { redirect } from 'next/navigation'
|
|
|
|
|
import Image from 'next/image'
|
|
|
|
|
import { auth } from '@/lib/auth'
|
|
|
|
|
|
|
|
|
|
export default async function AuthLayout({
|
|
|
|
|
children,
|
|
|
|
|
}: {
|
|
|
|
|
children: React.ReactNode
|
|
|
|
|
}) {
|
2026-02-03 22:44:09 +01:00
|
|
|
let session = null
|
|
|
|
|
try {
|
|
|
|
|
session = await auth()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// Auth check failed, continue as unauthenticated
|
|
|
|
|
console.error('Auth check failed in auth layout:', error)
|
|
|
|
|
}
|
2026-01-30 13:41:32 +01:00
|
|
|
|
|
|
|
|
// Redirect logged-in users to their dashboard
|
|
|
|
|
if (session?.user) {
|
|
|
|
|
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')
|
2026-02-03 22:44:09 +01:00
|
|
|
} else if (role === 'MENTOR') {
|
|
|
|
|
redirect('/mentor')
|
2026-01-30 13:41:32 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="min-h-screen flex flex-col">
|
|
|
|
|
{/* Simple header with logo */}
|
|
|
|
|
<header className="border-b bg-card">
|
|
|
|
|
<div className="container-app py-4">
|
|
|
|
|
<Image
|
|
|
|
|
src="/images/MOPC-blue-long.png"
|
|
|
|
|
alt="MOPC - Monaco Ocean Protection Challenge"
|
|
|
|
|
width={160}
|
|
|
|
|
height={50}
|
|
|
|
|
className="h-12 w-auto"
|
|
|
|
|
priority
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
{/* Main content */}
|
|
|
|
|
<main className="flex-1 flex items-center justify-center p-4">
|
|
|
|
|
{children}
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
{/* Simple footer */}
|
|
|
|
|
<footer className="border-t bg-card py-4">
|
|
|
|
|
<div className="container-app text-center text-sm text-muted-foreground">
|
|
|
|
|
© {new Date().getFullYear()} Monaco Ocean Protection Challenge
|
|
|
|
|
</div>
|
|
|
|
|
</footer>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|