Check Notification Test Status

This commit is contained in:
headlesdev
2025-05-25 21:43:42 +02:00
parent 78f1d54fc3
commit fb13c2bfce
4 changed files with 101 additions and 8 deletions

View File

@@ -1,9 +1,17 @@
import { useState, useEffect, useCallback } from "react";
import axios from "axios";
interface NotificationTest {
id: number;
notificationProviderId: number;
sent: boolean;
success: boolean;
}
const useNotifications = () => {
const [notifications, setNotifications] = useState([]);
const [loading, setLoading] = useState(false);
const [notificationTest, setNotificationTest] = useState<NotificationTest | null>(null);
const loadNotifications = useCallback(() => {
setLoading(true);
@@ -51,13 +59,26 @@ const useNotifications = () => {
});
}
const getNotificationTest = (notificationTestId: number): Promise<string> | string => {
return axios.get('/api/notifications/test/get', { params: { notificationTestId } })
.then((response) => {
setNotificationTest(response.data.notificationTest);
return response.data.notificationTest;
})
.catch(err => {
throw err.response?.data?.error || 'An error occurred';
});
}
return {
notifications,
loading,
addNotification,
deleteNotification,
loadNotifications,
testNotification
testNotification,
getNotificationTest,
notificationTest
};
}