import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

function hashPassword(password: string): string {
  return Buffer.from(password).toString('base64');
}

async function main() {
  // Create super admin
  const admin = await prisma.user.upsert({
    where: { email: 'admin@needyfy.com' },
    update: {},
    create: {
      name: 'Super Admin',
      email: 'admin@needyfy.com',
      password: hashPassword('Needyfy@2025'),
      roles: 'admin',
      isVerified: true,
    },
  });
  console.log('Admin created:', admin.email);

  // Also create superadmin
  const superAdmin = await prisma.user.upsert({
    where: { email: 'superadmin@needyfy.com' },
    update: {},
    create: {
      name: 'Super Admin',
      email: 'superadmin@needyfy.com',
      password: hashPassword('SuperAdmin@2025'),
      roles: 'admin',
      isVerified: true,
    },
  });
  console.log('Super Admin created:', superAdmin.email);
}

main()
  .catch(console.error)
  .finally(() => prisma.$disconnect());
