import { queryClient } from "../../App"; import { useRef } from "react"; import { useMutation, useQuery } from "react-query"; import { KeyField } from "../../components/fields/text"; import { DeleteModal } from "../../components/modals"; import APIKeyAddForm from "../../forms/settings/APIKeyAddForm"; import Toast from "../../components/notifications/Toast"; import { APIClient } from "../../api/APIClient"; import { useToggle } from "../../hooks/hooks"; import { toast } from "react-hot-toast"; import { classNames } from "../../utils"; import { TrashIcon } from "@heroicons/react/24/outline"; import { EmptySimple } from "../../components/emptystates"; function APISettings() { const [addFormIsOpen, toggleAddForm] = useToggle(false); const { data } = useQuery( ["apikeys"], () => APIClient.apikeys.getAll(), { retry: false, refetchOnWindowFocus: false, onError: err => console.log(err) } ); return (

API keys

Manage API keys.

{data && data.length > 0 ?
  1. Name
    Key
  2. {data && data.map((k) => ( ))}
: }
); } interface ApiKeyItemProps { apikey: APIKey } function APIListItem({ apikey }: ApiKeyItemProps) { const cancelModalButtonRef = useRef(null); const [deleteModalIsOpen, toggleDeleteModal] = useToggle(false); const deleteMutation = useMutation( (key: string) => APIClient.apikeys.delete(key), { onSuccess: () => { queryClient.invalidateQueries(["apikeys"]); queryClient.invalidateQueries(["apikeys", apikey.key]); toast.custom((t) => ); } } ); return (
  • { deleteMutation.mutate(apikey.key); toggleDeleteModal(); }} title={`Remove API key: ${apikey.name}`} text="Are you sure you want to remove this API key? This action cannot be undone." />
    {apikey.name}
  • ); } export default APISettings;