diff --git a/frontend/app/(protected)/alerts/page.tsx b/frontend/app/(protected)/alerts/page.tsx index 7db801b..4709ac1 100644 --- a/frontend/app/(protected)/alerts/page.tsx +++ b/frontend/app/(protected)/alerts/page.tsx @@ -109,6 +109,26 @@ const AlertsPage: React.FC = () => { } } + const handleAcknowledgeToggle = async (alertId: number) => { + try { + const res = await fetch(`/api/update-alert/${alertId}`, { method: 'PATCH' }) + const payload = await res.json().catch(() => null) + console.log('[AlertsPage] PATCH /api/update-alert', { id: alertId, status: res.status, payload }) + if (!res.ok) { + throw new Error(typeof payload?.error === 'string' ? payload.error : `Update failed (${res.status})`) + } + // Обновить алерты + const params = new URLSearchParams() + if (currentObject.id) params.set('objectId', currentObject.id) + const listRes = await fetch(`/api/get-alerts?${params.toString()}`, { cache: 'no-store' }) + const listPayload = await listRes.json().catch(() => null) + const data = Array.isArray(listPayload?.data) ? listPayload.data : (listPayload?.data?.alerts || []) + setAlerts(data as AlertItem[]) + } catch (e) { + console.error('Failed to update alert:', e) + } + } + return (