mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Test Notifications client
This commit is contained in:
@@ -3,14 +3,21 @@
|
||||
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 } = useNotifications();
|
||||
const { loadNotifications, notifications, loading, testNotification } = useNotifications();
|
||||
const [deleteNotificationId, setDeleteNotificationId] = useState<number | null>(null);
|
||||
|
||||
|
||||
const testNotificationHandler = async (notificationProviderId: number) => {
|
||||
(document.getElementById('test_notification') as HTMLDialogElement)?.showModal();
|
||||
await testNotification(notificationProviderId);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="w-full bg-base-200 p-4 rounded-2xl border border-stone-800">
|
||||
@@ -48,7 +55,7 @@ export const NotificationSettings = ({ onError, onSuccess }: { onError: (message
|
||||
<td>{notification.type}</td>
|
||||
<td>
|
||||
<div className='flex items-center gap-2'>
|
||||
<button className='btn btn-sm btn-success'><Play className='w-4 h-4' /></button>
|
||||
<button className='btn btn-sm btn-success' onClick={() => testNotificationHandler(notification.id)}><Play className='w-4 h-4' /></button>
|
||||
<button className='btn btn-sm btn-error' onClick={() => {setDeleteNotificationId(notification.id); (document.getElementById('delete_notification') as HTMLDialogElement)?.showModal()}}><Trash2 className='w-4 h-4' /></button>
|
||||
</div>
|
||||
</td>
|
||||
@@ -72,6 +79,7 @@ export const NotificationSettings = ({ onError, onSuccess }: { onError: (message
|
||||
{deleteNotificationId && (
|
||||
<DeleteNotification notificationId={deleteNotificationId} onNotificationDeleted={loadNotifications} onError={onError} onSuccess={onSuccess} />
|
||||
)}
|
||||
<TestNotification />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user