"use client" import { dataGridFeatures, type DataGridFeatures } from "@/components/reui/data-grid" import { useMemo } from "react" import { type ColumnDef, useTable, } from "@tanstack/react-table" import type { Asn } from "@/lib/data" 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/data-grid-layout" import { DataGridSortHeader } from "@/components/data-grids/shared/data-grid-sort-header" import { EmptyState } from "@/components/empty-state" import { FilterIcon, NetworkIcon } from "lucide-react" interface AsnsDataGridProps { asns: Asn[] isLoading?: boolean emptyDescription?: string pagination?: boolean } function AsnsDataGrid({ asns, isLoading, pagination = false, emptyDescription }: AsnsDataGridProps) { const columns = useMemo[]>( () => [ { id: "asn", accessorKey: "asn", header: ({ column }) => , cell: ({ row }) => {row.original.asn}, meta: { headerTitle: "ASN", headerClassName: DATA_GRID_CELL_PAD_FIRST, cellClassName: DATA_GRID_CELL_PAD_FIRST, }, }, { id: "org", accessorKey: "org", header: ({ column }) => , cell: ({ row }) => ( {row.original.org} ), meta: { headerTitle: "Имя / организация", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD, }, }, { id: "prefixes", accessorKey: "prefixes", header: ({ column }) => , cell: ({ row }) => ( {row.original.prefixes?.toLocaleString("ru") ?? "—"} ), meta: { headerTitle: "Префиксов", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD, }, }, { id: "filter", accessorKey: "filter", header: ({ column }) => , cell: ({ row }) => ( {row.original.filter} ), meta: { headerTitle: "Фильтр", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD, }, }, { id: "updated", accessorKey: "updated", header: ({ column }) => , cell: ({ row }) => {row.original.updated}, meta: { headerTitle: "Обновлён", headerClassName: DATA_GRID_CELL_PAD, cellClassName: DATA_GRID_CELL_PAD, }, }, { id: "enabled", accessorKey: "enabled", header: ({ column }) => , cell: ({ row }) => ( {row.original.enabled ? "Активен" : "Отключён"} ), meta: { headerTitle: "Статус", headerClassName: DATA_GRID_CELL_PAD_LAST, cellClassName: DATA_GRID_CELL_PAD_LAST, }, }, ], [], ) const table = useTable({ features: dataGridFeatures, manualPagination: !pagination, data: asns, columns, getRowId: (row) => row.id, }) return ( } title="Нет ASN" description={emptyDescription ?? "Добавьте автономные системы или импортируйте каталог"} className="border-0 py-12" /> } /> ) } export { AsnsDataGrid, type AsnsDataGridProps }