import { IconDotsVertical, IconEdit, IconPower, IconTrash } from "@tabler/icons-react"; import { createColumnHelper, getCoreRowModel, useReactTable } from "@tanstack/react-table"; import { useMemo } from "react"; import type { Certificate } from "src/api/backend"; import { DomainsFormatter, GravatarFormatter } from "src/components"; import { TableLayout } from "src/components/Table/TableLayout"; import { intl } from "src/locale"; import Empty from "./Empty"; interface Props { data: Certificate[]; isFetching?: boolean; } export default function Table({ data, isFetching }: Props) { const columnHelper = createColumnHelper(); const columns = useMemo( () => [ columnHelper.accessor((row: any) => row.owner, { id: "owner", cell: (info: any) => { const value = info.getValue(); return ; }, meta: { className: "w-1", }, }), columnHelper.accessor((row: any) => row, { id: "domainNames", header: intl.formatMessage({ id: "column.name" }), cell: (info: any) => { const value = info.getValue(); return ; }, }), columnHelper.accessor((row: any) => row.provider, { id: "provider", header: intl.formatMessage({ id: "column.provider" }), cell: (info: any) => { return info.getValue(); }, }), columnHelper.accessor((row: any) => row.expires_on, { id: "expires_on", header: intl.formatMessage({ id: "column.expires" }), cell: (info: any) => { return info.getValue(); }, }), columnHelper.accessor((row: any) => row, { id: "id", header: intl.formatMessage({ id: "column.status" }), cell: (info: any) => { return info.getValue(); }, }), columnHelper.display({ id: "id", // todo: not needed for a display? cell: (info: any) => { return (
{intl.formatMessage( { id: "certificates.actions-title", }, { id: info.row.original.id }, )} {intl.formatMessage({ id: "action.edit" })} {intl.formatMessage({ id: "action.disable" })} ); }, meta: { className: "text-end w-1", }, }), ], [columnHelper], ); const tableInstance = useReactTable({ columns, data, getCoreRowModel: getCoreRowModel(), rowCount: data.length, meta: { isFetching, }, enableSortingRemoval: false, }); return } />; }