import { ActionIcon, Group, Menu, Table, Text } from "@mantine/core"; import { IconDots, IconEdit, IconTrash } from "@tabler/icons-react"; import { format } from "date-fns"; import { useTranslation } from "react-i18next"; import { CustomAvatar } from "@/components/ui/custom-avatar.tsx"; import React from "react"; import NoTableResults from "@/components/common/no-table-results"; import { IScimToken } from "@/ee/scim/types/scim-token.types"; interface ScimTokenTableProps { tokens: IScimToken[]; isLoading?: boolean; onUpdate?: (token: IScimToken) => void; onRevoke?: (token: IScimToken) => void; } export function ScimTokenTable({ tokens, isLoading, onUpdate, onRevoke, }: ScimTokenTableProps) { const { t } = useTranslation(); const formatDate = (date: Date | string | null) => { if (!date) return t("Never"); return format(new Date(date), "MMM dd, yyyy"); }; return ( {t("Name")} {t("Token")} {t("Created by")} {t("Last used")} {t("Created")} {tokens && tokens.length > 0 ? ( tokens.map((token) => ( {token.name} ••••{token.tokenLastFour} {token.creator ? ( {token.creator.name} ) : ( )} {formatDate(token.lastUsedAt)} {formatDate(token.createdAt)} {onUpdate && ( } onClick={() => onUpdate(token)} > {t("Rename")} )} {onRevoke && ( } color="red" onClick={() => onRevoke(token)} > {t("Revoke")} )} )) ) : ( )}
); }