// app/(auth)/vendors/[id]/page.tsx
import { notFound } from 'next/navigation'
import { prisma } from '@/lib/prisma'
import { VendorDetailPage } from '@/components/vendor/VendorDetailPage'

interface PageProps {
  params: {
    id: string
  }
}

export default async function Page({ params }: PageProps) {
    const { id } = params

    const vendor = await prisma.vendor.findUnique({
        where: { id },
        include: {
            address: true,
            events: {
                select: {
                id: true,
                name: true,
                date: true,
                },
                orderBy: {
                date: 'asc',
                },
            },
        },
    })

    if (!vendor) {
        notFound()
    }

    return <VendorDetailPage vendor={vendor} />
}