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

const TeamSettings = sequelize.define('TeamSettings', {
  id: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    primaryKey: true
  },
  teamId: {
    type: DataTypes.UUID,
    allowNull: false,
    references: {
      model: 'teams',
      key: 'id'
    },
    unique: true
  },
  allowMemberInvites: {
    type: DataTypes.BOOLEAN,
    defaultValue: false
  },
  requireApprovalForProjects: {
    type: DataTypes.BOOLEAN,
    defaultValue: false
  },
  defaultRole: {
    type: DataTypes.ENUM('admin', 'editor', 'viewer'),
    defaultValue: 'viewer'
  },
  features: {
    type: DataTypes.JSON,
    defaultValue: {
      analytics: true,
      integrations: true,
      apiAccess: false,
      customBranding: false
    }
  },
  notificationPreferences: {
    type: DataTypes.JSON,
    defaultValue: {
      emailOnMemberJoin: true,
      emailOnProjectCreation: true,
      slackWebhook: null
    }
  }
}, {
  tableName: 'team_settings',
  timestamps: true
});

export default TeamSettings;
