import { Injectable } from '@nestjs/common';
import { PrismaService } from '../../infrastructure/database/prisma.service';

@Injectable()
export class WaitlistRepository {
  constructor(private readonly prisma: PrismaService) {}

  async findAll() {
    return this.prisma.waitlistEntry.findMany({ orderBy: { createdAt: 'desc' } });
  }

  async create(data: {
    nickname: string;
    email: string;
    devices?: string[];
    interests?: string[];
    painpoint?: string;
    willingBeta?: boolean;
  }) {
    return this.prisma.waitlistEntry.create({
      data: {
        nickname: data.nickname,
        email: data.email,
        devices: data.devices as any,
        interests: data.interests as any,
        painpoint: data.painpoint ?? '',
        willingBeta: data.willingBeta ?? false,
      },
    });
  }
}
