import { Prisma } from '@prisma/client';
import { prisma } from '../db/prisma';

export type CarteAvecUtilisateur = Prisma.CarteEtudianteGetPayload<{
  include: { utilisateur: { include: { role: true; campus: true } } };
}>;

export function findByQrCode(qrCode: string): Promise<CarteAvecUtilisateur | null> {
  return prisma.carteEtudiante.findFirst({
    where: { qrCode },
    include: { utilisateur: { include: { role: true, campus: true } } },
  });
}
