Cleaer Add Notification Provider from

This commit is contained in:
headlesdev 2025-05-25 01:03:45 +02:00
parent 947cec0d7a
commit cfc9bc5951

View File

@ -18,11 +18,19 @@ export default function AddNotification({ onNotificationAdded, onError, onSucces
const { addNotification } = useNotification(); const { addNotification } = useNotification();
const clearForm = () => {
setName("")
setType("Select a type")
setTelegramBotToken("")
setTelegramChatId("")
}
const addNotificationHandler = async () => { const addNotificationHandler = async () => {
const config = type === "TELEGRAM" ? `{ "token": "${telegramBotToken}", "chat_id": "${telegramChatId}" }` : ""; const config = type === "TELEGRAM" ? `{ "token": "${telegramBotToken}", "chat_id": "${telegramChatId}" }` : "";
const response = addNotification(name, type, config); const response = addNotification(name, type, config);
if (typeof response === "string") { if (typeof response === "string") {
onError && onError(response) onError && onError(response)
clearForm();
return return
} }
try { try {
@ -34,10 +42,7 @@ export default function AddNotification({ onNotificationAdded, onError, onSucces
} catch (apiError: any) { } catch (apiError: any) {
onError && onError(apiError) onError && onError(apiError)
} finally { } finally {
setName("") clearForm();
setType("Select a type")
setTelegramBotToken("")
setTelegramChatId("")
} }
} }