diff --git a/src/components/organisms/ApiKey.tsx b/src/components/organisms/ApiKey.tsx index d999ce76..e11b78c3 100644 --- a/src/components/organisms/ApiKey.tsx +++ b/src/components/organisms/ApiKey.tsx @@ -2,18 +2,14 @@ import React, { useState, useEffect } from 'react'; import { Box, Button, + TextField, Typography, IconButton, - CircularProgress, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, + InputAdornment, Tooltip, + CircularProgress, } from '@mui/material'; -import { ContentCopy, Visibility, Delete } from '@mui/icons-material'; +import { ContentCopy } from '@mui/icons-material'; import styled from 'styled-components'; import axios from 'axios'; import { useGlobalInfoStore } from '../../context/globalInfo'; @@ -25,12 +21,29 @@ const Container = styled(Box)` margin-top: 50px; `; +const ApiKeyField = styled(TextField)` + width: 400px; + margin: 20px 0; +`; + +const HiddenText = styled(Typography)` + color: #888; + font-style: italic; +`; + +const CenteredContent = styled(Box)` + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + margin-top: 50px; /* Add top margin for spacing */ +`; + const ApiKeyManager = () => { const [apiKey, setApiKey] = useState(null); - const [apiKeyName, setApiKeyName] = useState('Maxun API Key'); const [loading, setLoading] = useState(true); - const [showKey, setShowKey] = useState(false); const [copySuccess, setCopySuccess] = useState(false); + const { notify } = useGlobalInfoStore(); useEffect(() => { @@ -61,19 +74,6 @@ const ApiKeyManager = () => { } }; - const deleteApiKey = async () => { - setLoading(true); - try { - await axios.delete('http://localhost:8080/auth/delete-api-key'); - setApiKey(null); - notify('success', 'API Key deleted successfully'); - } catch (error) { - console.error('Error deleting API key', error); - } finally { - setLoading(false); - } - }; - const copyToClipboard = () => { if (apiKey) { navigator.clipboard.writeText(apiKey); @@ -89,55 +89,47 @@ const ApiKeyManager = () => { Manage Your API Key {apiKey ? ( - - - - - API Key Name - API Key - Actions - - - - - {apiKeyName} - {showKey ? apiKey : '****************'} - - - - - - - - setShowKey(!showKey)}> - - - - - - - - - - - -
- {copySuccess && ( - - Copied to Clipboard - - )} -
- ) : ( <> - You haven't generated an API key yet. - - + )} ); }; export default ApiKeyManager; +