https://dev.kronoz.win/r/marzneshin.git
1import { ColumnDef } from "@tanstack/react-table"
2import { HostType } from "@marzneshin/features/hosts"
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: (host: HostType) => void;
9 onOpen: (host: HostType) => void;
10 onEdit: (host: HostType) => void;
11}
12
13
14export const columns = (actions: ColumnAction): ColumnDef<HostType>[] => ([
15 {
16 accessorKey: "remark",
17 header: ({ column }) => <DataTableColumnHeader title={i18n.t('name')} column={column} />,
18 },
19 {
20 accessorKey: "address",
21 header: ({ column }) => <DataTableColumnHeader title={i18n.t('address')} column={column} />,
22 cell: ({ row }) => `${row.original.address}:${row.original.port}`
23 },
24 {
25 accessorKey: "port",
26 header: ({ column }) => <DataTableColumnHeader title={i18n.t('page.nodes.usage_coefficient')} column={column} />,
27 },
28 {
29 id: "actions",
30 cell: ({ row }) => <DataTableActionsCell {...actions} row={row} />
31 },
32]);