fix(map): sort scheme queries by time

This commit is contained in:
2026-07-16 14:29:29 +08:00
parent dfaee645ff
commit 209da0d295
9 changed files with 90 additions and 22 deletions
@@ -128,6 +128,9 @@ const AnalysisParameters: React.FC<Props> = ({
});
const burstSchemes = (response.data as SchemeItem[]).filter(
(scheme) => scheme.scheme_type === "burst_analysis",
).sort(
(a, b) =>
dayjs(b.create_time).valueOf() - dayjs(a.create_time).valueOf(),
);
setFormField("schemes", burstSchemes);
@@ -1,6 +1,6 @@
"use client";
import React, { useState } from "react";
import React, { useMemo, useState } from "react";
import {
Box,
Button,
@@ -70,6 +70,16 @@ const SchemeQuery: React.FC<Props> = ({
const [loading, setLoading] = useState(false);
const schemes = externalSchemes !== undefined ? externalSchemes : internalSchemes;
const setSchemes = onSchemesChange || setInternalSchemes;
const sortedSchemes = useMemo(
() =>
schemes
.slice()
.sort(
(a, b) =>
dayjs(b.create_time).valueOf() - dayjs(a.create_time).valueOf(),
),
[schemes],
);
const buildDisplayResult = (
scheme: Pick<BurstSchemeRecord, "scheme_name" | "username" | "create_time">,
@@ -211,7 +221,7 @@ const SchemeQuery: React.FC<Props> = ({
</Box>
</Box>
<Box className="flex-1 overflow-auto">
{schemes.length === 0 ? (
{sortedSchemes.length === 0 ? (
<Box className="flex flex-col items-center justify-center h-full text-gray-400">
<Box className="mb-4">
<svg
@@ -248,9 +258,9 @@ const SchemeQuery: React.FC<Props> = ({
) : (
<Box className="space-y-2 p-2">
<Typography variant="caption" className="text-gray-500 px-2">
{schemes.length}
{sortedSchemes.length}
</Typography>
{schemes.map((scheme) => {
{sortedSchemes.map((scheme) => {
const summary = scheme.scheme_detail?.result_summary;
const payload = scheme.scheme_detail?.result_payload;
const locatedPipe = payload?.located_pipe ?? summary?.located_pipe ?? "-";