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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user