import React, { useEffect } from 'react'; import ContentBox from '@/components/elements/ContentBox'; import CreateApiKeyForm from '@/components/dashboard/forms/CreateApiKeyForm'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faKey } from '@fortawesome/free-solid-svg-icons'; import FlashMessageRender from '@/components/FlashMessageRender'; import { format } from 'date-fns'; import PageContentBlock from '@/components/elements/PageContentBlock'; import tw from 'twin.macro'; import GreyRowBox from '@/components/elements/GreyRowBox'; import { useAPIKeys } from '@/api/account/api-keys'; import { useFlashKey } from '@/plugins/useFlash'; import DeleteAPIKeyButton from '@/components/dashboard/security/DeleteAPIKeyButton'; export default () => { const { clearAndAddHttpError } = useFlashKey('account'); const { data: keys, isValidating, error } = useAPIKeys({ revalidateOnMount: true, revalidateOnFocus: false, }); useEffect(() => { clearAndAddHttpError(error); }, [ error ]); return (
{ !keys || !keys.length ?

{!keys ? 'Loading...' : 'No API keys exist for this account.'}

: keys.map((key, index) => ( 0 && tw`mt-2` ]} >

{key.description}

Last used:  {key.lastUsedAt ? format(key.lastUsedAt, 'MMM do, yyyy HH:mm') : 'Never'}

)) }
); };