
import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import { authOptions } from '@/lib/auth';
import { HomePageClient } from '@/components/home-page-client';

export default async function HomePage() {
  const session = await getServerSession(authOptions);

  if (session?.user) {
    // Redirect authenticated users to appropriate dashboard
    if (session.user.role === 'CUSTOMER') {
      redirect('/customer/dashboard');
    } else {
      redirect('/dashboard');
    }
  }

  return <HomePageClient />;
}
