require('dotenv').config();
const connectDB = require('../config/db');
const User      = require('../models/User');

async function run() {
  await connectDB();  

  const exists = await User.findOne({ email: 'dev@quantumens.com' });
  if (!exists) {
    await User.create({
      firstName: 'Othmane',
      lastName:  'Azzaf',
      email:     'dev@quantumens.com',
      password:  'SuperStrongPassword123',
      admin:     true
    });
    console.log('✅ Admin user created.');
  } else {
    console.log('ℹ️  Admin already exists.');
  }

  process.exit();
}

run().catch(err => {
  console.error('❌ Error creating admin:', err);
  process.exit(1);
});