import { NextResponse } from 'next/server';
import { withAuth } from '@/lib/api-guards';

/**
 * Test API route to verify JWT authentication, RBAC, and RLS behavior.
 */
export const GET = withAuth(async (req, { session, prisma }) => {
  // Fetch users and salesResults using the context-bound client
  const users = await prisma.user.findMany({
    select: {
      id: true,
      username: true,
      role: true,
      hotelId: true
    }
  });

  const sales = await prisma.salesResult.findMany({
    select: {
      id: true,
      userId: true,
      hotelId: true,
      period: true,
      amount: true
    }
  });

  return NextResponse.json({
    session,
    users,
    sales
  });
});
