/** * User API Keys Manager Component */ import React, { useState } from 'react'; import { APIKey } from '../types'; import { useApiKeysStore } from '../store'; interface UserApiKeysManagerProps { apiKeys: APIKey[]; } export const UserApiKeysManager: React.FC = ({ apiKeys }) => { const createMyApiKey = useApiKeysStore((state) => state.createMyApiKey); const revokeMyApiKey = useApiKeysStore((state) => state.revokeMyApiKey); const [keyName, setKeyName] = useState(''); const [createdKey, setCreatedKey] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); const handleCreate = async (event: React.FormEvent) => { event.preventDefault(); if (!keyName.trim()) { return; } setIsSubmitting(true); try { const created = await createMyApiKey(keyName.trim()); setCreatedKey(created.api_key); setKeyName(''); } finally { setIsSubmitting(false); } }; return (

Your access key

Create API key

Keys are shown once. Copy it now and store it securely.

setKeyName(event.target.value)} />
{createdKey && (

New API key

{createdKey}

)}

Your keys

API keys

{apiKeys.length === 0 ? (

No API keys yet

Create a key to use the recognition API.

) : (
{apiKeys.map((key) => ( ))}
Name Status Last Used Created Actions
{key.key_name} {key.is_active ? 'Active' : 'Revoked'} {key.last_used_at ? new Date(key.last_used_at).toLocaleString() : 'Never'} {new Date(key.created_at).toLocaleDateString()} {key.is_active ? ( ) : ( Revoked )}
)}
); };