fix(ui): обозначить расчёт и симуляцию оптимизатора

This commit is contained in:
Denozordec committed 2026-09-30 22:29:46 +07:00
1 parent e58604c3c0
commit 59f0f82176
7 files changed
+104 -62

No files matched your search

@@ -41,7 +41,7 @@ function ProbChip({ prob, best }: { prob: number; best?: boolean }) {
: "bg-muted text-muted-foreground border-border"
}
>
{prob}%
{prob} б.
</Chip>
)
}
@@ -53,6 +53,7 @@ interface RouteOptimizerCommRecsDataGridProps {
applied: Set<string>
applying: Set<string>
onPin: (key: string) => void
simulation?: boolean
onApply: (community: string, homeId: string) => void
}
@@ -64,6 +65,7 @@ function RouteOptimizerCommRecsDataGrid({
applying,
onPin,
onApply,
simulation = false,
}: RouteOptimizerCommRecsDataGridProps) {
const rows = useMemo(
() => recs.map((r, idx) => ({ ...r, _rowKey: `${homeId}::${r.community}::${idx}` })),
@@ -94,7 +96,7 @@ function RouteOptimizerCommRecsDataGrid({
id: "current",
header: () => (
<span className="text-[11px] font-medium text-muted-foreground">
Текущий (WAN → JH → Exit)
Базовый расчёт (WAN → JH → Exit)
</span>
),
enableSorting: false,
@@ -141,7 +143,7 @@ function RouteOptimizerCommRecsDataGrid({
<span>{r.recommended.exit}</span>
{r.shouldSwitch && !isPinned && (
<span className="ml-1 text-[10px] font-bold bg-amber-500/10 border border-amber-500/20 px-1.5 py-0.5 rounded">
+{(r.recommended.prob ?? 0) - (r.current?.prob ?? 0)}%
+{(r.recommended.prob ?? 0) - (r.current?.prob ?? 0)} б.
</span>
)}
</div>
@@ -153,7 +155,7 @@ function RouteOptimizerCommRecsDataGrid({
id: "probability",
header: () => (
<span className="text-[11px] font-medium text-muted-foreground block text-center">
P(тек / рек)
Индекс (баз / рек)
</span>
),
enableSorting: false,
@@ -185,9 +187,9 @@ function RouteOptimizerCommRecsDataGrid({
const r = row.original
const pinKey = `${homeId}::${r.community}`
const isPinned = pinned.has(pinKey)
const isApplied = applied.has(pinKey)
const isApplying = applying.has(pinKey)
const canApply = r.shouldSwitch && !isPinned && !isApplied
const isApplied = simulation && applied.has(pinKey)
const isApplying = simulation && applying.has(pinKey)
const canApply = simulation && r.shouldSwitch && !isPinned && !isApplied
return (
<div className="flex items-center justify-end gap-1.5" onClick={(e) => e.stopPropagation()}>
{isPinned && <PinIcon className="size-3 text-sky-500 fill-sky-500" />}
@@ -210,13 +212,13 @@ function RouteOptimizerCommRecsDataGrid({
{isApplying ? (
<RefreshCwIcon className="size-3 animate-spin" />
) : (
"Применить"
"Симулировать"
)}
</Button>
)}
{isApplied && (
<span className="text-[10px] text-emerald-600 dark:text-emerald-400 font-medium">
✓ применено
✓ симуляция завершена
</span>
)}
</div>
@@ -228,7 +230,7 @@ function RouteOptimizerCommRecsDataGrid({
},
},
],
[applied, applying, homeId, onApply, onPin, pinned],
[applied, applying, homeId, onApply, onPin, pinned, simulation],
)
const table = useTable({
@@ -41,7 +41,7 @@ function ProbChip({ prob, best }: { prob: number; best?: boolean }) {
: "bg-muted text-muted-foreground border-border"
}
>
{prob}%
{prob} б.
</Chip>
)
}
@@ -211,7 +211,7 @@ function RouteOptimizerFullRoutesDataGrid({
id: "prob",
accessorKey: "probabilityOptimal",
header: ({ column }) => (
<DataGridSortHeader column={column} title="P(opt)" className="mx-auto" />
<DataGridSortHeader column={column} title="Индекс" className="mx-auto" />
),
cell: ({ row }) => {
const isBest = row.original.id === bestId || row.original._index === 0
@@ -222,7 +222,7 @@ function RouteOptimizerFullRoutesDataGrid({
)
},
meta: {
headerTitle: "P(opt)",
headerTitle: "Индекс",
headerClassName: cn(DATA_GRID_CELL_PAD, "text-center"),
cellClassName: cn(DATA_GRID_CELL_PAD, "text-center"),
},