mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Check Notification Test Status
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user