diff --git a/src/components/api/ApiKey.tsx b/src/components/api/ApiKey.tsx index 27897169..73916d1e 100644 --- a/src/components/api/ApiKey.tsx +++ b/src/components/api/ApiKey.tsx @@ -34,6 +34,7 @@ const ApiKeyManager = () => { const { t } = useTranslation(); const [apiKey, setApiKey] = useState(null); const [apiKeyName, setApiKeyName] = useState(t('apikey.default_name')); + const [apiKeyCreatedAt, setApiKeyCreatedAt] = useState(null); const [loading, setLoading] = useState(true); const [showKey, setShowKey] = useState(false); const [copySuccess, setCopySuccess] = useState(false); @@ -44,6 +45,7 @@ const ApiKeyManager = () => { try { const { data } = await axios.get(`${apiUrl}/auth/api-key`); setApiKey(data.api_key); + setApiKeyCreatedAt(data.api_key_created_at); } catch (error: any) { notify('error', t('apikey.notifications.fetch_error', { error: error.message })); } finally { @@ -60,7 +62,7 @@ const ApiKeyManager = () => { try { const { data } = await axios.post(`${apiUrl}/auth/generate-api-key`); setApiKey(data.api_key); - + setApiKeyCreatedAt(data.api_key_created_at); notify('success', t('apikey.notifications.generate_success')); } catch (error: any) { notify('error', t('apikey.notifications.generate_error', { error: error.message })); @@ -74,6 +76,7 @@ const ApiKeyManager = () => { try { await axios.delete(`${apiUrl}/auth/delete-api-key`); setApiKey(null); + setApiKeyCreatedAt(null); notify('success', t('apikey.notifications.delete_success')); } catch (error: any) { notify('error', t('apikey.notifications.delete_error', { error: error.message })); @@ -133,6 +136,7 @@ const ApiKeyManager = () => { {t('apikey.table.name')} {t('apikey.table.key')} + Created On {t('apikey.table.actions')} @@ -144,6 +148,15 @@ const ApiKeyManager = () => { {showKey ? `${apiKey?.substring(0, 10)}...` : '**********'} + {apiKeyCreatedAt && ( + + {new Date(apiKeyCreatedAt).toLocaleDateString('en-US', { + month: 'short', + day: 'numeric', + year: 'numeric', + })} + + )}