'use strict';

const bcrypt = require('bcryptjs');

module.exports = {
  async up(queryInterface, Sequelize) {
    const hashedPassword = await bcrypt.hash('password123', 10);
    const hashedPin = await bcrypt.hash('1234', 10);

    await queryInterface.bulkInsert('users', [
      {
        firstName: 'Francis',
        lastName: 'Mbatha',
        username: 'admin',
        email: 'admin@frankcodepos.com',
        password: hashedPassword,
        phone: '+254700000001',
        role: 'admin',
        pin: hashedPin,
        storeId: 1,
        lastLogin: new Date(),
        isActive: true,
        createdAt: new Date(),
        updatedAt: new Date()
      },
      {
        firstName: 'Sarah',
        lastName: 'Kamau',
        username: 'manager',
        email: 'sarah@frankcodepos.com',
        password: hashedPassword,
        phone: '+254700000002',
        role: 'manager',
        pin: hashedPin,
        storeId: 1,
        lastLogin: new Date(),
        isActive: true,
        createdAt: new Date(),
        updatedAt: new Date()
      },
      {
        firstName: 'John',
        lastName: 'Omondi',
        username: 'cashier1',
        email: 'john@frankcodepos.com',
        password: hashedPassword,
        phone: '+254700000003',
        role: 'cashier',
        pin: hashedPin,
        storeId: 1,
        lastLogin: new Date(),
        isActive: true,
        createdAt: new Date(),
        updatedAt: new Date()
      }
    ], {});
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.bulkDelete('users', null, {});
  }
};
