'use client'; import { useState } from 'react'; import AddNotification from '@/components/dialogues/AddNotification'; import DeleteNotification from '@/components/dialogues/DeleteNotification'; import TestNotification from '@/components/dialogues/TestNotification'; import useNotifications from '@/hooks/useNotifications'; import { Plus, Trash2, Play, Bell } from 'lucide-react'; import Loading from '@/components/Loading'; export const NotificationSettings = ({ onError, onSuccess }: { onError: (message: string) => void, onSuccess: (message: string) => void }) => { const { loadNotifications, notifications, loading, testNotification } = useNotifications(); const [deleteNotificationId, setDeleteNotificationId] = useState(null); const [notificationTestId, setNotificationTestId] = useState(null); const testNotificationHandler = async (notificationProviderId: number) => { (document.getElementById('test_notification') as HTMLDialogElement)?.showModal(); const notificationTest = await testNotification(notificationProviderId); setNotificationTestId(notificationTest); } return (

Notification Provider Settings

Manage your notification providers

{loading ? (
) : notifications && notifications.length > 0 ? (
{notifications.map((notification: any) => ( ))}
# Name Type Actions
{notification.id} {notification.name} {notification.type}
) : (

No notification providers have been added yet.

)} {deleteNotificationId && ( )} {notificationTestId && ( )}
); };