https://dev.kronoz.win/r/marzneshin.git
1import { ColumnDef } from "@tanstack/react-table"
2import { NodesStatusBadge, NodeType, NodesStatus } from "@marzneshin/features/nodes"
3import { DataTableColumnHeader } from "@marzneshin/components/data-table/column-header"
4import i18n from "@marzneshin/features/i18n"
5import { DataTableActionsCell } from "@marzneshin/components"
6
7interface ColumnAction {
8 onDelete: (node: NodeType) => void;
9 onOpen: (node: NodeType) => void;
10 onEdit: (node: NodeType) => void;
11}
12
13
14export const columns = (actions: ColumnAction): ColumnDef<NodeType>[] => ([
15 {
16 accessorKey: "name",
17 header: ({ column }) => <DataTableColumnHeader title={i18n.t('name')} column={column} />,
18 },
19 {
20 accessorKey: "status",
21 header: ({ column }) => <DataTableColumnHeader title={i18n.t('status')} column={column} />,
22 cell: ({ row }) => <NodesStatusBadge status={NodesStatus[row.original.status]} />,
23 },
24 {
25 accessorKey: "address",
26 header: ({ column }) => <DataTableColumnHeader title={i18n.t('address')} column={column} />,
27 cell: ({ row }) => `${row.original.address}:${row.original.port}`
28 },
29 {
30 accessorKey: "usage_coefficient",
31 header: ({ column }) => <DataTableColumnHeader title={i18n.t('page.nodes.usage_coefficient')} column={column} />,
32 },
33 {
34 id: "actions",
35 cell: ({ row }) => <DataTableActionsCell {...actions} row={row} />
36 },
37]);