import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import BookingsTable from '@/components/BookingsTable';
import DashboardSidebar from '@/components/DashboardSidebar';

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

  const bookings = await prisma.booking.findMany({
    include: {
      location: true,
      photobox: true,
    },
    orderBy: {
      createdAt: 'desc',
    },
  });

  const locations = await prisma.location.findMany({
    where: { active: true },
    orderBy: { name: 'asc' },
  });

  return (
    <div className="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
      <div className="flex">
        <DashboardSidebar user={session?.user} />
        <main className="flex-1 p-8">
          <BookingsTable 
            bookings={bookings}
            locations={locations}
            user={session?.user}
          />
        </main>
      </div>
    </div>
  );
}
