mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-22 18:06:36 +00:00
Cleaer Add Notification Provider from
This commit is contained in:
parent
947cec0d7a
commit
cfc9bc5951
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user