import dayjs from "@calcom/dayjs"; import { classNames } from "@calcom/lib"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { RouterOutputs } from "@calcom/trpc/react"; import { trpc } from "@calcom/trpc/react"; import { Badge, Button, Dropdown, DropdownItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, showToast, } from "@calcom/ui"; import { MoreHorizontal, Edit2, Trash } from "@calcom/ui/components/icon"; export type TApiKeys = RouterOutputs["viewer"]["apiKeys"]["list"][number]; const ApiKeyListItem = ({ apiKey, lastItem, onEditClick, }: { apiKey: TApiKeys; lastItem: boolean; onEditClick: () => void; }) => { const { t } = useLocale(); const utils = trpc.useContext(); const isExpired = apiKey?.expiresAt ? apiKey.expiresAt < new Date() : null; const neverExpires = apiKey?.expiresAt === null; const deleteApiKey = trpc.viewer.apiKeys.delete.useMutation({ async onSuccess() { await utils.viewer.apiKeys.list.invalidate(); showToast(t("api_key_deleted"), "success"); }, onError(err) { console.log(err); showToast(t("something_went_wrong"), "error"); }, }); return (
{apiKey?.note ? apiKey.note : t("api_key_no_note")}
{!neverExpires && isExpired &&{neverExpires ? (