import { PrismaClient } from '../lib/generated/prisma/index.js';

const prisma = new PrismaClient();

async function main() {
  console.log('🔍 Checking contact_submissions in Prisma database...\n');

  const contacts = await prisma.contact_submissions.findMany({
    orderBy: { created_at: 'desc' },
    take: 10,
  });

  console.log(`📊 Found ${contacts.length} contacts in Prisma PostgreSQL database\n`);

  if (contacts.length > 0) {
    console.log('✅ Sample contacts:');
    contacts.forEach((c, i) => {
      console.log(`  ${i + 1}. ${c.name} (${c.email}) - ${c.status} - ${c.created_at.toISOString()}`);
    });
  } else {
    console.log('⚠️  No contacts found in Prisma database!');
    console.log('\n💡 The data exists in Supabase but not in Prisma.');
    console.log('   This is the issue - the API queries Prisma, not Supabase.');
    console.log('\n🔧 Solution: Copy data from Supabase to Prisma:');
    console.log('   node scripts/sync-supabase-to-prisma-contacts.mjs');
  }

  await prisma.$disconnect();
}

main().catch((e) => {
  console.error(e);
  process.exit(1);
});
