const { PrismaClient } = require('@prisma/client');
const p = new PrismaClient({ datasourceUrl: 'postgresql://mopc:devpassword@localhost:5433/mopc' });

(async () => {
  // R2 - AI Screening round ID
  const roundId = 'cmmafe7et00ldy53kxpdhhvf0';

  // Check existing
  const existing = await p.fileRequirement.count({ where: { roundId } });
  if (existing > 0) {
    console.log(`Round already has ${existing} file requirements, skipping.`);
    await p.$disconnect();
    return;
  }

  const requirements = [
    {
      roundId,
      name: 'Executive Summary',
      description: 'A 2-page executive summary of your project (PDF format, max 10MB)',
      acceptedMimeTypes: ['application/pdf'],
      maxSizeMB: 10,
      isRequired: true,
      sortOrder: 0,
    },
    {
      roundId,
      name: 'Business Plan',
      description: 'Full business plan or project proposal (PDF format, max 25MB)',
      acceptedMimeTypes: ['application/pdf'],
      maxSizeMB: 25,
      isRequired: true,
      sortOrder: 1,
    },
    {
      roundId,
      name: 'Pitch Presentation',
      description: 'Slide deck presenting your project (PDF or PowerPoint, max 50MB)',
      acceptedMimeTypes: ['application/pdf', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
      maxSizeMB: 50,
      isRequired: true,
      sortOrder: 2,
    },
    {
      roundId,
      name: 'Video Pitch',
      description: 'A short video (max 3 minutes) explaining your project (MP4, max 200MB). Optional but recommended.',
      acceptedMimeTypes: ['video/mp4', 'video/quicktime', 'video/webm'],
      maxSizeMB: 200,
      isRequired: false,
      sortOrder: 3,
    },
    {
      roundId,
      name: 'Supporting Documents',
      description: 'Any additional supporting documents such as research papers, letters of support, etc. (PDF, max 20MB)',
      acceptedMimeTypes: ['application/pdf'],
      maxSizeMB: 20,
      isRequired: false,
      sortOrder: 4,
    },
  ];

  for (const req of requirements) {
    const created = await p.fileRequirement.create({ data: req });
    console.log('Created:', created.name, '| required:', created.isRequired, '| id:', created.id);
  }

  console.log('\nDone! Created', requirements.length, 'file requirements for R2.');
  await p.$disconnect();
})();
