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