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

const TrainingGroup = sequelize.define('TrainingGroup', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
    },
    clubId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
            model: Club,
            key: 'id',
        },
        onDelete: 'CASCADE',
    },
    name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    isPreset: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: false,
        comment: 'True if this is a preset group (Anfänger, Fortgeschrittene, etc.)'
    },
    presetType: {
        type: DataTypes.ENUM('anfaenger', 'fortgeschrittene', 'erwachsene', 'nachwuchs', 'leistungsgruppe'),
        allowNull: true,
        comment: 'Type of preset group'
    },
    sortOrder: {
        type: DataTypes.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: 'Order for displaying groups'
    },
    excludeFromQuickDiaryCreate: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: false,
        comment: 'If true, group is skipped when suggesting/creating diary dates via quick-create'
    },
}, {
    tableName: 'training_group',
    underscored: true,
    timestamps: true,
});

export default TrainingGroup;



