import { DataTypes } from 'sequelize';
import sequelize from '../database.js';

const ClubCommunicationTemplate = sequelize.define('ClubCommunicationTemplate', {
  id: {
    type: DataTypes.BIGINT,
    primaryKey: true,
    autoIncrement: true,
    allowNull: false,
  },
  clubId: {
    type: DataTypes.BIGINT,
    allowNull: false,
    field: 'club_id',
  },
  name: {
    type: DataTypes.STRING(160),
    allowNull: false,
  },
  category: {
    type: DataTypes.STRING(64),
    allowNull: false,
    defaultValue: 'general',
  },
  subjectTemplate: {
    type: DataTypes.STRING(255),
    allowNull: true,
    field: 'subject_template',
  },
  bodyTemplate: {
    type: DataTypes.TEXT,
    allowNull: false,
    field: 'body_template',
  },
  variablesHint: {
    type: DataTypes.TEXT,
    allowNull: true,
    field: 'variables_hint',
  },
  isSystemTemplate: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false,
    field: 'is_system_template',
  },
  sortOrder: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 0,
    field: 'sort_order',
  },
}, {
  underscored: true,
  tableName: 'club_communication_templates',
  timestamps: true,
});

export default ClubCommunicationTemplate;
