сортировка алертов

This commit is contained in:
dv 2026-05-06 15:34:43 +03:00
parent 8115324988
commit 50dc75b35f

View file

@ -85,9 +85,11 @@ export function AlertsPage() {
}
map.get(key)!.alerts.push(a)
}
return Array.from(map.values()).sort((a, b) =>
(a.object_name ?? '').localeCompare(b.object_name ?? '', 'ru')
)
return Array.from(map.values()).sort((a, b) => {
const latestA = Math.max(...a.alerts.map((x) => new Date(x.created_at).getTime()))
const latestB = Math.max(...b.alerts.map((x) => new Date(x.created_at).getTime()))
return latestB - latestA
})
}, [alerts])
const handleAcknowledge = async (id: number) => {