const mongoose = require('mongoose');
const { tenantFields, applyPlatformPlugins } = require('../platformFields');

const schema = new mongoose.Schema({
  ...tenantFields,
  admin: { type: mongoose.Schema.ObjectId, ref: 'Admin', required: true, index: true },
  inApp: { type: Boolean, default: true },
  email: { type: Boolean, default: true },
  whatsapp: { type: Boolean, default: false },
  eventPreferences: mongoose.Schema.Types.Mixed,
});

schema.index({ tenant: 1, admin: 1 }, { unique: true });

module.exports = mongoose.model('NotificationPreference', applyPlatformPlugins(schema));
