diff --git a/components/cards/settings/NotificationProviderSettings.tsx b/components/cards/settings/NotificationProviderSettings.tsx index aa2ba8b..8fa0b91 100644 --- a/components/cards/settings/NotificationProviderSettings.tsx +++ b/components/cards/settings/NotificationProviderSettings.tsx @@ -1,90 +1,220 @@ -'use client'; +"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'; +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, Settings, CheckCircle, AlertCircle } from "lucide-react" +import Loading from "@/components/Loading" -export const NotificationProviderSettings = ({ 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); +export const NotificationProviderSettings = ({ + 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) + } - const testNotificationHandler = async (notificationProviderId: number) => { - (document.getElementById('test_notification') as HTMLDialogElement)?.showModal(); - const notificationTest = await testNotification(notificationProviderId); - setNotificationTestId(notificationTest); + const getTypeIcon = (type: string) => { + switch (type.toLowerCase()) { + case "email": + return "📧" + case "slack": + return "💬" + case "discord": + return "🎮" + case "webhook": + return "🔗" + case "telegram": + return "✈️" + default: + return "🔔" } + } + + const getTypeBadgeColor = (type: string) => { + switch (type.toLowerCase()) { + case "email": + return "badge-primary" + case "slack": + return "badge-secondary" + case "discord": + return "badge-accent" + case "webhook": + return "badge-info" + case "telegram": + return "badge-success" + default: + return "badge-neutral" + } + } return ( -
-
-
-
-

Notification Provider Settings

-

Manage your notification providers

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

No notification providers have been added yet.

-
-
- )} - - {deleteNotificationId && ( - - )} - {notificationTestId && ( - - )} +
+ {/* Header */} +
+
+
+ +
+
+

Notification Providers

+

Manage your notification providers and test connections

+
+ +
+ + {/* Content */} + {loading ? ( +
+ +
+ ) : notifications && notifications.length > 0 ? ( +
+
+ + {/* Table Content */} +
+ + + + + + + + + + + + {notifications.map((notification: any, index: number) => ( + + + + + + + + ))} + +
+ ID + + + Provider + + + Type + + + Status + + + + Actions + +
+
+
+ {notification.id} +
+
+
+
+
{getTypeIcon(notification.type)}
+
+
{notification.name}
+
Provider #{notification.id}
+
+
+
+
+ {notification.type} +
+
+
+ + Active +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ ) : ( +
+
+
+
+
+ +
+
+ +
+
+

No Providers Configured

+

+ Get started by adding your first notification provider. You can configure email, Slack, Discord, + webhooks, and more. +

+ +
+
+
+ )} + + {/* Dialogs */} + + {deleteNotificationId && ( + + )} + {notificationTestId && }
- ); -}; \ No newline at end of file + ) +} diff --git a/components/cards/settings/NotificationSettings.tsx b/components/cards/settings/NotificationSettings.tsx index ad0990a..8bc3074 100644 --- a/components/cards/settings/NotificationSettings.tsx +++ b/components/cards/settings/NotificationSettings.tsx @@ -202,7 +202,7 @@ export const NotificationSettings = ({ onError, onSuccess }: NotificationSetting

Monitor server resources and performance

@@ -419,7 +419,7 @@ export const NotificationSettings = ({ onError, onSuccess }: NotificationSetting

Configure application monitoring notifications