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