Cập nhật thứ tự cảnh báo trong tab cảnh báo, sửa lại reload danh sách chuyến đi ( vuốt lên )

This commit is contained in:
2025-12-30 14:52:46 +07:00
parent bf261e70e4
commit 499bd76f5e
2 changed files with 14 additions and 35 deletions

View File

@@ -85,11 +85,11 @@ const WarningScreen = () => {
const slice = resp.data?.alarms ?? [];
// Sort alarms by level descending (higher level first: SOS > Danger > Warning > Info)
const sortedSlice = [...slice].sort(
(a, b) => (b.level ?? 0) - (a.level ?? 0)
);
setAlarms((prev) => (append ? [...prev, ...sortedSlice] : sortedSlice));
// When appending, we need to sort the entire combined list, not just the new slice
setAlarms((prev) => {
const combined = append ? [...prev, ...slice] : slice;
return combined.sort((a, b) => (b.level ?? 0) - (a.level ?? 0));
});
setOffset(nextOffset);
setHasMore(nextOffset + PAGE_SIZE < resp.data?.total!);
} catch (error) {