import mongoose from 'mongoose'

export const ADMIN_ALERT_TYPES = [
  'slack_invite_failed',
  'no_slack_handle_week',
  'stuck_pending_payment',
  'member_suspended',
  'preregistrant_selected_not_invited',
  'preregistrant_expired',
  'event_draft_imminent',
  'event_near_capacity',
  'tag_suggestions_pending'
]

const adminAlertDismissalSchema = new mongoose.Schema({
  adminId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Member',
    required: true
  },
  alertType: {
    type: String,
    enum: ADMIN_ALERT_TYPES,
    required: true
  },
  signature: {
    type: String,
    required: true
  },
  dismissedAt: {
    type: Date,
    default: Date.now
  }
})

adminAlertDismissalSchema.index({ adminId: 1, alertType: 1 }, { unique: true })

export default mongoose.models.AdminAlertDismissal ||
  mongoose.model('AdminAlertDismissal', adminAlertDismissalSchema)
