import { PrismaClient, Role } from '@prisma/client';
import * as bcrypt from 'bcryptjs';

const prisma = new PrismaClient();

async function main() {
  const password = await bcrypt.hash('Admin123!', 10);
  await prisma.user.upsert({
    where: { email: 'md@worldshine.co.tz' },
    update: {},
    create: {
      email: 'md@worldshine.co.tz',
      password_hash: password,
      full_name: 'Managing Director',
      role: Role.MD,
    },
  });
  await prisma.user.upsert({
    where: { email: 'legal@worldshine.co.tz' },
    update: {},
    create: {
      email: 'legal@worldshine.co.tz',
      password_hash: password,
      full_name: 'Legal Officer',
      role: Role.LEGAL_OFFICER,
    },
  });
  console.log('Seed: users created (md@ / legal@ worldshine.co.tz, password Admin123!)');
}

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(() => prisma.$disconnect());
