add test all hook
This commit is contained in:
1 parent
55ea81c46a
commit
6f133ed7a0
1 file changed
+25
@@ -174,6 +174,30 @@ const useTestNotification = () => {
|
|||||||
return [testNotification, isLoading, error];
|
return [testNotification, isLoading, error];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const useTestAllNotifications = () => {
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [error, setError] = useState(undefined);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const testAllNotifications = async ({ monitorId }) => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
await networkService.testAllNotifications({ monitorId });
|
||||||
|
createToast({
|
||||||
|
body: t("notifications.test.success"),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
createToast({
|
||||||
|
body: error.response?.data?.msg || error.message,
|
||||||
|
});
|
||||||
|
setError(error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return [testAllNotifications, isLoading, error];
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
useCreateNotification,
|
useCreateNotification,
|
||||||
useGetNotificationsByTeamId,
|
useGetNotificationsByTeamId,
|
||||||
@@ -181,4 +205,5 @@ export {
|
|||||||
useGetNotificationById,
|
useGetNotificationById,
|
||||||
useEditNotification,
|
useEditNotification,
|
||||||
useTestNotification,
|
useTestNotification,
|
||||||
|
useTestAllNotifications,
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user