From 9d475001ee0ae001bf3bf4c9cfd5e76e5370b1b0 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Thu, 23 Jan 2025 02:50:24 +0530 Subject: [PATCH] (feat:chatbots) confirm before deletion --- frontend/src/locale/en.json | 3 ++- frontend/src/locale/es.json | 3 ++- frontend/src/locale/jp.json | 5 +++-- frontend/src/locale/ru.json | 3 ++- frontend/src/locale/zh-TW.json | 5 +++-- frontend/src/locale/zh.json | 3 ++- frontend/src/settings/APIKeys.tsx | 25 ++++++++++++++++++++++++- 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/frontend/src/locale/en.json b/frontend/src/locale/en.json index 8a8d645b..2f6d2617 100644 --- a/frontend/src/locale/en.json +++ b/frontend/src/locale/en.json @@ -79,7 +79,8 @@ "key": "API Key", "sourceDoc": "Source Document", "createNew": "Create New", - "noData": "No existing Chatbots" + "noData": "No existing Chatbots", + "deleteConfirmation": "Are you sure you want to delete the API key '{{name}}'?" }, "analytics": { "label": "Analytics", diff --git a/frontend/src/locale/es.json b/frontend/src/locale/es.json index 41b8fd96..6437dead 100644 --- a/frontend/src/locale/es.json +++ b/frontend/src/locale/es.json @@ -79,7 +79,8 @@ "key": "Clave de API", "sourceDoc": "Documento Fuente", "createNew": "Crear Nuevo", - "noData": "No hay chatbots existentes" + "noData": "No hay chatbots existentes", + "deleteConfirmation": "¿Estás seguro de que quieres eliminar la clave API '{{name}}'?" }, "analytics": { "label": "Analítica", diff --git a/frontend/src/locale/jp.json b/frontend/src/locale/jp.json index 0098807a..199f83e8 100644 --- a/frontend/src/locale/jp.json +++ b/frontend/src/locale/jp.json @@ -73,12 +73,13 @@ "actions": "アクション" }, "apiKeys": { - "label": "APIキー", + "label": "チャットボット", "name": "名前", "key": "APIキー", "sourceDoc": "ソースドキュメント", "createNew": "新規作成", - "noData": "既存のAPIキーがありません" + "noData": "既存のチャットボットはありません", + "deleteConfirmation": "APIキー '{{name}}' を削除してもよろしいですか?" }, "analytics": { "label": "分析", diff --git a/frontend/src/locale/ru.json b/frontend/src/locale/ru.json index cd9f2f44..3621aafc 100644 --- a/frontend/src/locale/ru.json +++ b/frontend/src/locale/ru.json @@ -79,7 +79,8 @@ "key": "API ключ", "sourceDoc": "Источник документа", "createNew": "Создать новый", - "noData": "Нет существующих API ключей" + "noData": "Нет существующих чатботов", + "deleteConfirmation": "Вы уверены, что хотите удалить API ключ '{{name}}'?" }, "analytics": { "label": "Аналитика", diff --git a/frontend/src/locale/zh-TW.json b/frontend/src/locale/zh-TW.json index eb7ab9ef..8dbd550d 100644 --- a/frontend/src/locale/zh-TW.json +++ b/frontend/src/locale/zh-TW.json @@ -78,8 +78,9 @@ "name": "名稱", "key": "API 金鑰", "sourceDoc": "來源文件", - "createNew": "新增", - "noData": "沒有現有的聊天機器人" + "createNew": "建立新的", + "noData": "沒有現有的聊天機器人", + "deleteConfirmation": "您確定要刪除 API 金鑰 '{{name}}' 嗎?" }, "analytics": { "label": "分析", diff --git a/frontend/src/locale/zh.json b/frontend/src/locale/zh.json index b73a8c54..0e53a257 100644 --- a/frontend/src/locale/zh.json +++ b/frontend/src/locale/zh.json @@ -79,7 +79,8 @@ "key": "API 密钥", "sourceDoc": "源文档", "createNew": "创建新的", - "noData": "没有现有的聊天机器人" + "noData": "没有现有的聊天机器人", + "deleteConfirmation": "您确定要删除 API 密钥 '{{name}}' 吗?" }, "analytics": { "label": "分析", diff --git a/frontend/src/settings/APIKeys.tsx b/frontend/src/settings/APIKeys.tsx index 038e4bbb..44242cda 100644 --- a/frontend/src/settings/APIKeys.tsx +++ b/frontend/src/settings/APIKeys.tsx @@ -5,6 +5,7 @@ import userService from '../api/services/userService'; import Trash from '../assets/trash.svg'; import CreateAPIKeyModal from '../modals/CreateAPIKeyModal'; import SaveAPIKeyModal from '../modals/SaveAPIKeyModal'; +import ConfirmationModal from '../modals/ConfirmationModal'; import { APIKeyData } from './types'; import SkeletonLoader from '../components/SkeletonLoader'; @@ -15,6 +16,10 @@ export default function APIKeys() { const [newKey, setNewKey] = React.useState(''); const [apiKeys, setApiKeys] = React.useState([]); const [loading, setLoading] = useState(true); + const [keyToDelete, setKeyToDelete] = useState<{ + id: string; + name: string; + } | null>(null); const handleFetchKeys = async () => { setLoading(true); @@ -44,6 +49,7 @@ export default function APIKeys() { .then((data) => { data.success === true && setApiKeys((previous) => previous.filter((elem) => elem.id !== id)); + setKeyToDelete(null); }) .catch((error) => { console.error(error); @@ -104,6 +110,18 @@ export default function APIKeys() { close={() => setSaveKeyModal(false)} /> )} + {keyToDelete && ( + setKeyToDelete(null)} + submitLabel={t('modals.deleteConv.delete')} + handleSubmit={() => handleDeleteKey(keyToDelete.id)} + handleCancel={() => setKeyToDelete(null)} + /> + )}
{loading ? ( @@ -157,7 +175,12 @@ export default function APIKeys() { alt={`Delete ${element.name}`} className="h-4 w-4 cursor-pointer hover:opacity-50" id={`img-${index}`} - onClick={() => handleDeleteKey(element.id)} + onClick={() => + setKeyToDelete({ + id: element.id, + name: element.name, + }) + } />