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