import { AdminApiKeyResponse } from "@medusajs/types" import { Badge } from "@medusajs/ui" import { createColumnHelper } from "@tanstack/react-table" import { useMemo } from "react" import { useTranslation } from "react-i18next" import { DateCell } from "../../../../../components/table/table-cells/common/date-cell" import { StatusCell } from "../../../../../components/table/table-cells/common/status-cell" import { TextCell } from "../../../../../components/table/table-cells/common/text-cell" import { getApiKeyStatusProps, getApiKeyTypeProps, prettifyRedactedToken, } from "../../../common/utils" import { ApiKeyRowActions } from "./api-key-row-actions" const columnHelper = createColumnHelper() export const useApiKeyManagementTableColumns = () => { const { t } = useTranslation() return useMemo( () => [ columnHelper.accessor("title", { header: t("fields.title"), cell: ({ getValue }) => (
{getValue()}
), }), columnHelper.accessor("redacted", { header: "Token", cell: ({ getValue }) => { const token = getValue() return {prettifyRedactedToken(token)} }, }), columnHelper.accessor("type", { header: t("fields.type"), cell: ({ getValue }) => { const { label } = getApiKeyTypeProps(getValue(), t) return }, }), columnHelper.accessor("revoked_at", { header: t("fields.status"), cell: ({ getValue }) => { const { color, label } = getApiKeyStatusProps(getValue(), t) return {label} }, }), columnHelper.accessor("last_used_at", { header: t("apiKeyManagement.table.lastUsedAtHeader"), cell: ({ getValue }) => { const date = getValue() return }, }), columnHelper.accessor("created_at", { header: t("fields.created"), cell: ({ getValue }) => { const date = getValue() return }, }), columnHelper.display({ id: "actions", cell: ({ row }) => { return }, }), ], [t] ) }