fix(ui): перенести таблицы оптимизатора маршрутов на ReUI v9
This commit is contained in:
1 parent
1ea07f65b2
commit
bdba83b2b6
6 files changed
+132
-45
No files matched your search
@@ -1,20 +1,21 @@
|
||||
"use client"
|
||||
|
||||
import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid"
|
||||
|
||||
import { useMemo } from "react"
|
||||
import {
|
||||
type ColumnDef,
|
||||
getCoreRowModel,
|
||||
useReactTable,
|
||||
} from "@tanstack/react-table-v8"
|
||||
useTable,
|
||||
} from "@tanstack/react-table"
|
||||
import type { HomeRouter, JumpHost, WanJhLeg } from "@/lib/route-optimizer-data"
|
||||
import { Flag } from "@/components/flag"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { DataGridShell } from "@/components/data-grids/shared/legacy-data-grid-shell"
|
||||
import { DataGridShell } from "@/components/data-grids/shared/data-grid-shell"
|
||||
import {
|
||||
DATA_GRID_CELL_PAD,
|
||||
DATA_GRID_CELL_PAD_FIRST,
|
||||
DATA_GRID_CELL_PAD_LAST,
|
||||
} from "@/components/data-grids/shared/legacy-data-grid-layout"
|
||||
} from "@/components/data-grids/shared/data-grid-layout"
|
||||
import { WifiIcon } from "lucide-react"
|
||||
|
||||
function LossChip({ loss }: { loss: number }) {
|
||||
@@ -39,8 +40,8 @@ function RouteOptimizerWanMatrixDataGrid({
|
||||
}: RouteOptimizerWanMatrixDataGridProps) {
|
||||
const bestScore = legs.length ? Math.max(...legs.map((l) => l.score)) : 0
|
||||
|
||||
const columns = useMemo<ColumnDef<HomeRouter["wans"][number]>[]>(() => {
|
||||
const base: ColumnDef<HomeRouter["wans"][number]>[] = [
|
||||
const columns = useMemo<ColumnDef<DataGridFeatures, HomeRouter["wans"][number]>[]>(() => {
|
||||
const base: ColumnDef<DataGridFeatures, HomeRouter["wans"][number]>[] = [
|
||||
{
|
||||
id: "wan",
|
||||
accessorKey: "name",
|
||||
@@ -96,7 +97,7 @@ function RouteOptimizerWanMatrixDataGrid({
|
||||
},
|
||||
]
|
||||
|
||||
const jhCols: ColumnDef<HomeRouter["wans"][number]>[] = jumpHosts.map((jh) => ({
|
||||
const jhCols: ColumnDef<DataGridFeatures, HomeRouter["wans"][number]>[] = jumpHosts.map((jh) => ({
|
||||
id: `jh-${jh.id}`,
|
||||
header: () => (
|
||||
<div className="text-center">
|
||||
@@ -163,10 +164,12 @@ function RouteOptimizerWanMatrixDataGrid({
|
||||
return [...base, ...jhCols]
|
||||
}, [bestScore, jumpHosts, legs])
|
||||
|
||||
const table = useReactTable({
|
||||
const table = useTable({
|
||||
features: dataGridFeatures,
|
||||
manualPagination: true,
|
||||
manualSorting: true,
|
||||
data: home.wans,
|
||||
columns,
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getRowId: (row) => row.id,
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user