import type { Metadata } from 'next'
import Link from 'next/link'
import Image from 'next/image'
import { auth } from '@/lib/auth'
import { redirect } from 'next/navigation'
import type { Route } from 'next'
import type { UserRole } from '@prisma/client'
export const metadata: Metadata = { title: 'Monaco Ocean Protection Challenge' }
export default async function HomePage() {
const session = await auth()
// Redirect authenticated users to their appropriate dashboard.
// Reads the multi-role array (roles[]) so a user who is e.g. JURY_MEMBER+MENTOR
// lands on /jury (their highest-priority role) rather than always falling
// through on the singular `role` field. The context-aware variant —
// user.getDefaultDashboard tRPC procedure — exists for surfaces that can call
// tRPC; page.tsx uses static priority for simplicity.
if (session?.user) {
const roles = (session.user.roles as UserRole[] | undefined) ?? [session.user.role as UserRole]
if (roles.includes('SUPER_ADMIN') || roles.includes('PROGRAM_ADMIN')) redirect('/admin')
if (roles.includes('JURY_MEMBER')) redirect('/jury')
if (roles.includes('MENTOR')) redirect('/mentor' as Route)
if (roles.includes('APPLICANT')) redirect('/applicant' as Route)
if (roles.includes('OBSERVER')) redirect('/observer')
}
return (
{/* Header */}
{/* Hero Section */}
Monaco Ocean Protection Challenge
Supporting innovative solutions for ocean conservation through fair
and transparent project evaluation.
{/* Features Section */}
Platform Features
Secure Evaluation
Jury members access only their assigned projects with complete
confidentiality.
Real-time Progress
Track evaluation progress and manage voting windows with
comprehensive dashboards.
Mobile First
Evaluate projects anywhere with a fully responsive design
optimized for all devices.
{/* Footer */}
)
}