add test notificaiton button and methods

This commit is contained in:
Alex Holliday committed 2025-06-10 12:07:31 +08:00
1 parent 1ed317d0cb
commit e6493df881
8 files changed
+135 -90

No files matched your search

+26
View File
@@ -152,10 +152,36 @@ const useEditNotification = () => {
return [editNotification, isLoading, error];
};
const useTestNotification = () => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
const { t } = useTranslation();
const testNotification = async (notification) => {
try {
setIsLoading(true);
await networkService.testNotification({ notification });
createToast({
body: t("notifications.test.success"),
});
} catch (error) {
setError(error);
createToast({
body: t("notifications.test.failed"),
});
} finally {
setIsLoading(false);
}
};
return [testNotification, isLoading, error];
};
export {
useCreateNotification,
useGetNotificationsByTeamId,
useDeleteNotification,
useGetNotificationById,
useEditNotification,
useTestNotification,
};