diff --git a/frontend/src/settings/APIKeys.tsx b/frontend/src/settings/APIKeys.tsx index b0f65aca..b039477c 100644 --- a/frontend/src/settings/APIKeys.tsx +++ b/frontend/src/settings/APIKeys.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; import userService from '../api/services/userService'; @@ -7,7 +7,6 @@ import CreateAPIKeyModal from '../modals/CreateAPIKeyModal'; import SaveAPIKeyModal from '../modals/SaveAPIKeyModal'; import { APIKeyData } from './types'; import SkeletonLoader from '../components/SkeletonLoader'; -import Input from '../components/Input'; export default function APIKeys() { const { t } = useTranslation(); @@ -16,9 +15,6 @@ export default function APIKeys() { const [newKey, setNewKey] = React.useState(''); const [apiKeys, setApiKeys] = React.useState([]); const [loading, setLoading] = useState(true); - const [searchTerm, setSearchTerm] = useState(''); // Added state for search term - const [filteredKeys, setFilteredKeys] = useState([]); // State for filtered API keys - const handleFetchKeys = async () => { setLoading(true); @@ -29,7 +25,6 @@ export default function APIKeys() { } const apiKeys = await response.json(); setApiKeys(apiKeys); - setFilteredKeys(apiKeys); // Initialize the filtered keys as the fetched ones } catch (error) { console.log(error); } finally { @@ -47,13 +42,8 @@ export default function APIKeys() { return response.json(); }) .then((data) => { - data.success === true && setApiKeys((previous) => previous.filter((elem) => elem.id !== id)); - setFilteredKeys((previous) => - previous.filter((elem) => elem.id !== id), - ); - } }) .catch((error) => { console.error(error); @@ -77,7 +67,6 @@ export default function APIKeys() { }) .then((data) => { setApiKeys([...apiKeys, data]); - setFilteredKeys([...apiKeys, data]); // Update filtered keys too setCreateModal(false); setNewKey(data.key); setSaveKeyModal(true); @@ -88,37 +77,14 @@ export default function APIKeys() { }); }; - useEffect(() => { + React.useEffect(() => { handleFetchKeys(); }, []); - // Filter API keys when the search term changes - useEffect(() => { - setFilteredKeys( - apiKeys.filter( - (key) => - key.name.toLowerCase().includes(searchTerm.toLowerCase()) || - key.source?.toLowerCase().includes(searchTerm.toLowerCase()) || - key.key.toLowerCase().includes(searchTerm.toLowerCase()), - ), - ); - }, [searchTerm, apiKeys]); - return (
-
-
- setSearchTerm(e.target.value)} // Update search term - /> -
+