From ef5615788806b1138eec1af6a715033c3668dfcc Mon Sep 17 00:00:00 2001 From: amhsirak Date: Tue, 3 Feb 2026 11:19:46 +0530 Subject: [PATCH] feat: confirmation dialog before deleting the API key --- src/components/api/ApiKey.tsx | 81 +++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/src/components/api/ApiKey.tsx b/src/components/api/ApiKey.tsx index 73f95dc7..ab633fe7 100644 --- a/src/components/api/ApiKey.tsx +++ b/src/components/api/ApiKey.tsx @@ -13,6 +13,11 @@ import { TableRow, Tooltip, Paper, + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + DialogActions, } from '@mui/material'; import { ContentCopy, Visibility, VisibilityOff, Delete } from '@mui/icons-material'; import styled from 'styled-components'; @@ -38,6 +43,9 @@ const ApiKeyManager = () => { const [loading, setLoading] = useState(true); const [showKey, setShowKey] = useState(false); const [copySuccess, setCopySuccess] = useState(false); + + const [confirmDeleteOpen, setConfirmDeleteOpen] = useState(false); + const { notify } = useGlobalInfoStore(); useEffect(() => { @@ -54,7 +62,6 @@ const ApiKeyManager = () => { }; fetchApiKey(); - }, []); const generateApiKey = async () => { @@ -82,6 +89,7 @@ const ApiKeyManager = () => { notify('error', t('apikey.notifications.delete_error', { error: error.message })); } finally { setLoading(false); + setConfirmDeleteOpen(false); } }; @@ -94,6 +102,18 @@ const ApiKeyManager = () => { } }; + const handleDeleteClick = () => { + setConfirmDeleteOpen(true); + }; + + const handleDeleteCancel = () => { + setConfirmDeleteOpen(false); + }; + + const handleDeleteConfirm = () => { + deleteApiKey(); + }; + if (loading) { return ( { Start by creating an API key below. Then, - + test your API - or read the + or read the{' '} + API documentation - for setup instructions. + {' '} + for setup instructions. + { > {t('apikey.title')} + {apiKey ? ( @@ -137,7 +171,9 @@ const ApiKeyManager = () => { {t('apikey.table.name')}{t('apikey.table.key')} {apiKeyCreatedAt && Created On} - {t('apikey.table.actions')} + + {t('apikey.table.actions')} + @@ -163,13 +199,15 @@ const ApiKeyManager = () => { + setShowKey(!showKey)}> {showKey ? : } + - + @@ -181,12 +219,37 @@ const ApiKeyManager = () => { ) : ( <> {t('apikey.no_key_message')} - )} + + {/* Delete confirmation dialog */} + + Delete API Key + + + Are you sure you want to delete this API key? This action cannot be undone and + will immediately invalidate the key. + + + + + + + ); -} -export default ApiKeyManager; \ No newline at end of file +}; + +export default ApiKeyManager;