import AdminAlertDismissal from '../../../models/adminAlertDismissal.js'
import { connectDB } from '../../../utils/mongoose.js'

export default defineEventHandler(async (event) => {
  const admin = await requireAdmin(event)
  const { alertTypes } = await validateBody(event, adminAlertRestoreSchema)
  await connectDB()

  const result = await AdminAlertDismissal.deleteMany({
    adminId: admin._id.toString(),
    alertType: { $in: alertTypes }
  })

  return { ok: true, restored: result.deletedCount ?? 0 }
})
