import { Model, DataTypes, Sequelize } from 'sequelize';

export interface InterviewFeedbackAttributes {
    id: string;
    evaluationId: string;
    feedbackType: string;
    comments: string;
}

export interface InterviewFeedbackInstance extends Model<InterviewFeedbackAttributes>, InterviewFeedbackAttributes { }

export default (sequelize: Sequelize) => {
    const InterviewFeedback = sequelize.define<InterviewFeedbackInstance>('InterviewFeedback', {
        id: {
            type: DataTypes.UUID,
            defaultValue: DataTypes.UUIDV4,
            primaryKey: true
        },
        evaluationId: {
            type: DataTypes.UUID,
            allowNull: false,
            references: {
                model: 'interview_evaluations',
                key: 'id'
            }
        },
        feedbackType: {
            type: DataTypes.STRING,
            allowNull: false
        },
        comments: {
            type: DataTypes.TEXT,
            allowNull: false
        }
    }, {
        tableName: 'interview_feedback',
        timestamps: true,
        updatedAt: false
    });

    (InterviewFeedback as any).associate = (models: any) => {
        InterviewFeedback.belongsTo(models.InterviewEvaluation, { foreignKey: 'evaluationId', as: 'evaluation' });
    };

    return InterviewFeedback;
};
