From 830318edc3b43aced1da45edb0b09b21703376af Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 29 Jan 2026 20:55:02 +0000 Subject: [PATCH] put -> patch --- client/src/Pages/Notifications/create/index.tsx | 15 +++++++++++---- client/src/Utils/NetworkService.js | 2 +- client/src/locales/en.json | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/src/Pages/Notifications/create/index.tsx b/client/src/Pages/Notifications/create/index.tsx index b5b98a7a0..550a5ee96 100644 --- a/client/src/Pages/Notifications/create/index.tsx +++ b/client/src/Pages/Notifications/create/index.tsx @@ -10,7 +10,7 @@ import { useParams } from "react-router-dom"; import { useNavigate } from "react-router-dom"; import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useGet, usePost } from "@/Hooks/UseApi"; +import { useGet, usePost, usePatch } from "@/Hooks/UseApi"; import { useNotificationForm } from "@/Hooks/useNotificationForm"; import type { NotificationFormData } from "@/Validation/notifications"; import type { Notification } from "@/Types/Notification"; @@ -29,6 +29,7 @@ const NotificationsCreatePage = () => { ); const { post, loading: isSubmitting } = usePost(); + const { patch, loading: isPatching } = usePatch(); const { schema, defaults } = useNotificationForm({ data: existingNotification }); @@ -37,7 +38,7 @@ const NotificationsCreatePage = () => { defaultValues: defaults, }); - const { control, watch, reset, handleSubmit } = form; + const { control, watch, reset, handleSubmit, clearErrors } = form; useEffect(() => { reset(defaults); @@ -45,6 +46,10 @@ const NotificationsCreatePage = () => { const watchedType = watch("type"); + useEffect(() => { + clearErrors(); + }, [watchedType, clearErrors]); + const addressConfig = useMemo(() => { if (watchedType === "pager_duty") { return { @@ -71,7 +76,9 @@ const NotificationsCreatePage = () => { }, [watchedType, t]); const onSubmit = async (data: NotificationFormData) => { - const result = await post("/notifications", data); + const result = isEditMode + ? await patch(`/notifications/${notificationId}`, data) + : await post("/notifications", data); if (result) { navigate("/notifications"); } @@ -234,7 +241,7 @@ const NotificationsCreatePage = () => { {t("common.buttons.test")}