import { requireAdmin } from '@/lib/auth-guard'
import { prisma } from '@/lib/prisma'
import { UsersTable } from '@/components/admin/users-table'

export default async function AdminUsersPage() {
  const session = await requireAdmin()

  const users = await prisma.user.findMany({
    include: { roles: { select: { role: true } } },
    orderBy: { created_at: 'desc' },
  })

  return (
    <div className="space-y-4">
      <h1 className="text-xl font-semibold text-foreground">Gebruikers</h1>
      <UsersTable users={users} currentUserId={session.userId} />
    </div>
  )
}
