<?php

session_start();

require_once __DIR__ . '/../core/functions.php';
require_once __DIR__ . '/../services/UserAlertService.php';

$userId = (int)($_SESSION['user_id'] ?? 0);
$alertId = (int)($_POST['alert_id'] ?? 0);

if ($userId > 0 && $alertId > 0) {
    UserAlertService::toggleAlert($alertId, $userId);
}

header('Location: my_alerts.php?updated=1');
exit;
