mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Delete & View Notification Providers
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
import { useState } from 'react';
|
||||
import AddNotification from '@/components/dialogues/AddNotification';
|
||||
import DeleteNotification from '@/components/dialogues/DeleteNotification';
|
||||
import useNotifications from '@/hooks/useNotifications';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { Plus, Trash2, Play } from 'lucide-react';
|
||||
|
||||
export const NotificationSettings = ({ onError, onSuccess }: { onError: (message: string) => void, onSuccess: (message: string) => void }) => {
|
||||
const { loadNotifications } = useNotifications();
|
||||
const { loadNotifications, notifications } = useNotifications();
|
||||
const [deleteNotificationId, setDeleteNotificationId] = useState<number | null>(null);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -21,7 +23,37 @@ export const NotificationSettings = ({ onError, onSuccess }: { onError: (message
|
||||
Add Provider
|
||||
</button>
|
||||
</div>
|
||||
<div className='overflow-x-auto pt-4'>
|
||||
<table className='table table-zebra table-pin-cols'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th className='w-24 text-center'>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{notifications.map((notification: any) => (
|
||||
<tr key={notification.id}>
|
||||
<td>{notification.id}</td>
|
||||
<td>{notification.name}</td>
|
||||
<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-error' onClick={() => {setDeleteNotificationId(notification.id); (document.getElementById('delete_notification') as HTMLDialogElement)?.showModal()}}><Trash2 className='w-4 h-4' /></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<AddNotification onNotificationAdded={loadNotifications} onSuccess={onSuccess} onError={onError} />
|
||||
{deleteNotificationId && (
|
||||
<DeleteNotification notificationId={deleteNotificationId} onNotificationDeleted={loadNotifications} onError={onError} onSuccess={onSuccess} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user