"use client"; import { Row } from "@tanstack/react-table"; import { Pencil, Trash2 } from "lucide-react"; import { ActionDropdown, ActionDropdownDangerZone, ActionDropdownItem, } from "@/components/shadcn/dropdown"; import { EnrichedApiKey } from "./types"; interface DataTableRowActionsProps { row: Row; onEdit: (apiKey: EnrichedApiKey) => void; onRevoke: (apiKey: EnrichedApiKey) => void; } export function DataTableRowActions({ row, onEdit, onRevoke, }: DataTableRowActionsProps) { const apiKey = row.original; const isRevoked = apiKey.attributes.revoked; const isExpired = new Date(apiKey.attributes.expires_at) < new Date(); const canRevoke = !isRevoked && !isExpired; return (
} label="Edit API Key" onSelect={() => onEdit(apiKey)} /> {canRevoke && ( } label="Revoke API Key" destructive onSelect={() => onRevoke(apiKey)} /> )}
); }