import { Schema, model, Document, Types } from 'mongoose'

const AlertSchema = new Schema(
	{
		title: {
			type: String,
			required: true,
		},
		description: {
			type: String,
			required: true,
		},
		buttonLabel: {
			type: String,
			required: true,
		},
		photo: {
			type: String,
		},
		video: {
			type: String,
		},
		action: {
			type: String,
			enum: ['meetme', 'home', 'reel', 'study', 'event', 'explore', 'chats'],
			required: true,
		},
		event: {
			type: Types.ObjectId,
			ref: 'Event',
		},
		reel: {
			type: Types.ObjectId,
			ref: 'Reel',
		},
		link: {
			type: String,
		},
	},
	{ versionKey: false, timestamps: true }
)

export interface IAlert extends Document {
	_id: Types.ObjectId
	title: string
	description: string
	buttonLabel: string
	photo?: string
	video?: string
	action: 'meetme' | 'home' | 'reel' | 'study' | 'event' | 'explore' | 'chats'
	event?: Types.ObjectId
	reel?: Types.ObjectId
	link?: string
	createdAt: Date
	updatedAt: Date
}

export const Alert = model('Alert', AlertSchema, 'alerts')
