From a25ff03b71d9f0e16476c71c3804bfdf7d049869 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 29 Jan 2026 20:12:50 +0000 Subject: [PATCH] remaining fields --- .../src/Pages/Notifications/create/index.tsx | 143 ++++++++++++++++-- client/src/locales/en.json | 31 ++++ 2 files changed, 163 insertions(+), 11 deletions(-) diff --git a/client/src/Pages/Notifications/create/index.tsx b/client/src/Pages/Notifications/create/index.tsx index 1c4d586a9..29a6ea2f6 100644 --- a/client/src/Pages/Notifications/create/index.tsx +++ b/client/src/Pages/Notifications/create/index.tsx @@ -3,7 +3,7 @@ import { TextField, Select } from "@/Components/v2/inputs"; import MenuItem from "@mui/material/MenuItem"; import Typography from "@mui/material/Typography"; -import { useEffect } from "react"; +import { useEffect, useMemo } from "react"; import { useParams } from "react-router-dom"; import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -19,8 +19,9 @@ const NotificationsCreatePage = () => { const { notificationId } = useParams<{ notificationId: string }>(); const isEditMode = Boolean(notificationId); - const { data: existingNotification, isLoading: notificationIsLoading } = - useGet(isEditMode ? `/notifications/${notificationId}` : null); + const { data: existingNotification } = useGet( + isEditMode ? `/notifications/${notificationId}` : null + ); const { schema, defaults } = useNotificationForm({ data: existingNotification }); @@ -34,7 +35,7 @@ const NotificationsCreatePage = () => { control, watch, reset, - formState: { errors }, + formState: {}, } = form; // Reset form when defaults change (i.e., when data is fetched) @@ -44,6 +45,32 @@ const NotificationsCreatePage = () => { const watchedType = watch("type"); + const addressConfig = useMemo(() => { + if (watchedType === "pager_duty") { + return { + title: t("pages.notifications.form.pagerDuty.title"), + description: t("pages.notifications.form.pagerDuty.description"), + fieldLabel: t("pages.notifications.form.pagerDuty.optionIntegrationKey"), + placeholder: t("pages.notifications.form.pagerDuty.placeholder"), + }; + } + if (watchedType === "email") { + return { + title: t("pages.notifications.form.address.title"), + description: t("pages.notifications.form.address.description"), + fieldLabel: t("pages.notifications.form.address.optionAddress"), + placeholder: t("pages.notifications.form.address.placeholderEmail"), + }; + } + return { + title: t("pages.notifications.form.address.title"), + description: t("pages.notifications.form.address.description"), + fieldLabel: t("pages.notifications.form.address.optionAddress"), + placeholder: t("pages.notifications.form.address.placeholderWebhook"), + }; + }, [watchedType, t]); + + // Suppress unused variable warnings - these will be used when UI is built void register; void control; @@ -58,17 +85,15 @@ const NotificationsCreatePage = () => { name="notificationName" control={control} defaultValue={defaults.notificationName} - render={({ field }) => ( + render={({ field, fieldState }) => ( )} /> @@ -82,12 +107,12 @@ const NotificationsCreatePage = () => { name="type" control={control} defaultValue={defaults.type} - render={({ field }) => { + render={({ field, fieldState }) => { return (