const { DataTypes } = require("sequelize");
const sequelize = require("../db");

const TrainingCourse = sequelize.define("TrainingCourse", {
  title: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  description: {
    type: DataTypes.TEXT,
  },
  category: {
    type: DataTypes.STRING(100),
    comment: 'e.g., "Construction Safety", "Electrical Safety"',
  },
  standard: {
    type: DataTypes.STRING(100),
    comment: 'e.g., "OSHA 1926 Subpart P", "ISO 45001"',
  },
  level: {
    type: DataTypes.ENUM("foundation", "intermediate", "advanced"),
    defaultValue: "foundation",
  },
  thumbnailUrl: {
    type: DataTypes.TEXT,
  },
  estimatedDuration: {
    type: DataTypes.INTEGER,
    comment: "Total estimated minutes",
  },
  isActive: {
    type: DataTypes.BOOLEAN,
    defaultValue: true,
  },
  order: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
  },
  passScore: {
    type: DataTypes.INTEGER,
    defaultValue: 75,
    comment: "Minimum quiz % required to pass a module (0-100)",
  },
}, {
  freezeTableName: true,
  tableName: 'TrainingCourses'
});

module.exports = TrainingCourse;
