<?php
require_once __DIR__.'/../../_bootstrap.php';
$u=apiUsuario($pdo);$uid=(int)$u['id'];
if($_SERVER['REQUEST_METHOD']==='GET')jsonResponse(['ok'=>true,'alerts'=>afGuardianDashboardAlerts($pdo,$uid,80,!empty($_GET['unread']))]);
if($_SERVER['REQUEST_METHOD']==='POST'){$d=requestJson();$id=(int)($d['alert_id']??0);if($id<=0)jsonResponse(['ok'=>false,'erro'=>'Alerta inválido.'],422);afGuardianDashboardMarkAlert($pdo,$uid,$id,!empty($d['resolve']));jsonResponse(['ok'=>true]);}
jsonResponse(['ok'=>false,'erro'=>'Método não permitido.'],405);
