"use client"; import { useState } from "react"; import useNotification from "@/hooks/useNotifications"; import { Bell, Text, BellRing, Braces } from "lucide-react"; interface AddNotificationProps { onNotificationAdded?: () => void; onError?: (message: string) => void; onSuccess?: (message: string) => void; } export default function AddNotification({ onNotificationAdded, onError, onSuccess }: AddNotificationProps) { const [name, setName] = useState(""); const [type, setType] = useState("Select a type"); const [telegramBotToken, setTelegramBotToken] = useState(""); const [telegramChatId, setTelegramChatId] = useState(""); const { addNotification } = useNotification(); 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) return } try { const successMessage = await response if (onSuccess && successMessage) { onSuccess('Notification Provider added successfully') onNotificationAdded && onNotificationAdded() } } catch (apiError: any) { onError && onError(apiError) } finally { setName("") setType("Select a type") setTelegramBotToken("") setTelegramChatId("") } } return (

Add Notification

setName(e.target.value)} />
{type === "TELEGRAM" && (
setTelegramBotToken(e.target.value)} /> setTelegramChatId(e.target.value)} />
)}
) }