class RegistrationRepository {
  constructor(prisma) { this.prisma = prisma; }
  findByUserId(userId) { return this.prisma.registrationStatus.findUnique({ where: { userId } }); }
  upsert(userId, data) {
    return this.prisma.registrationStatus.upsert({
      where: { userId },
      update: data,
      create: { userId, ...data },
    });
  }
  listAll({ status, page = 1, limit = 10 }) {
    const where = {};
    if (status) where.status = status;
    return this.prisma.registrationStatus.findMany({
      where,
      include: { user: { include: { profile: true } } },
      skip: (page - 1) * limit,
      take: limit,
      orderBy: { updatedAt: 'desc' },
    });
  }
  count(status) {
    const where = {};
    if (status) where.status = status;
    return this.prisma.registrationStatus.count({ where });
  }
}

export default RegistrationRepository;
