@@ -13,9 +13,9 @@ import { zodResolver } from "@hookform/resolvers/zod";
1313import { useGet , usePost , usePatch } from "@/Hooks/UseApi" ;
1414import { useNotificationForm } from "@/Hooks/useNotificationForm" ;
1515import type { NotificationFormData } from "@/Validation/notifications" ;
16- import type { Notification } from "@/Types/Notification" ;
16+ import { type Notification , NotificationChannels , AuthTypes } from "@/Types/Notification" ;
1717import { useTranslation } from "react-i18next" ;
18- import { NotificationChannels , AuthTypes } from "@/Types/Notification " ;
18+ import { normalizeNtfy } from "@/Utils/NotificationUtils " ;
1919
2020const NotificationsCreatePage = ( ) => {
2121 const { t } = useTranslation ( ) ;
@@ -78,9 +78,10 @@ const NotificationsCreatePage = () => {
7878 } , [ watchedType , t ] ) ;
7979
8080 const onSubmit = async ( data : NotificationFormData ) => {
81+ const payload = normalizeNtfy ( data ) ;
8182 const result = isEditMode
82- ? await patch ( `/notifications/${ notificationId } ` , data )
83- : await post ( "/notifications" , data ) ;
83+ ? await patch ( `/notifications/${ notificationId } ` , payload )
84+ : await post ( "/notifications" , payload ) ;
8485 if ( result ) {
8586 navigate ( "/notifications" ) ;
8687 }
@@ -352,6 +353,7 @@ const NotificationsCreatePage = () => {
352353 helperText = { fieldState . error ?. message ?? "" }
353354 />
354355 ) }
356+ shouldUnregister = { true }
355357 />
356358 < Controller
357359 name = "password"
@@ -370,6 +372,7 @@ const NotificationsCreatePage = () => {
370372 helperText = { fieldState . error ?. message ?? "" }
371373 />
372374 ) }
375+ shouldUnregister = { true }
373376 />
374377 </ >
375378 ) }
@@ -391,6 +394,7 @@ const NotificationsCreatePage = () => {
391394 helperText = { fieldState . error ?. message ?? "" }
392395 />
393396 ) }
397+ shouldUnregister = { true }
394398 />
395399 ) }
396400 </ Stack >
0 commit comments