,
+ notificationName: data?.notificationName || "",
+ address: data?.address || "",
+ };
+
+ return { schema: notificationSchema, defaults };
+ }, [data]);
+};
diff --git a/client/src/Pages/Notifications/create/index.tsx b/client/src/Pages/Notifications/create/index.tsx
index 82cee4861..58b14a426 100644
--- a/client/src/Pages/Notifications/create/index.tsx
+++ b/client/src/Pages/Notifications/create/index.tsx
@@ -1,5 +1,78 @@
+import { BasePage, ConfigBox } from "@/Components/v2/design-elements";
+import { TextField } from "@/Components/v2/inputs";
+
+import { useEffect } from "react";
+import { useParams } from "react-router-dom";
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { useGet } from "@/Hooks/UseApi";
+import { useNotificationForm } from "@/Hooks/useNotificationForm";
+import type { NotificationFormData } from "@/Validation/notifications";
+import type { Notification } from "@/Types/Notification";
+import { useTranslation } from "react-i18next";
+
const NotificationsCreatePage = () => {
- return Create Notifications Page
;
+ const { t } = useTranslation();
+ const { notificationId } = useParams<{ notificationId: string }>();
+ const isEditMode = Boolean(notificationId);
+
+ const { data: existingNotification, isLoading: notificationIsLoading } =
+ useGet(isEditMode ? `/notifications/${notificationId}` : null);
+
+ const { schema, defaults } = useNotificationForm({ data: existingNotification });
+
+ const form = useForm({
+ resolver: zodResolver(schema),
+ defaultValues: defaults,
+ });
+
+ const {
+ register,
+ control,
+ watch,
+ reset,
+ formState: { errors },
+ } = form;
+
+ // Reset form when defaults change (i.e., when data is fetched)
+ useEffect(() => {
+ reset(defaults);
+ }, [defaults, reset]);
+
+ const watchedType = watch("type");
+
+ // Suppress unused variable warnings - these will be used when UI is built
+ void register;
+ void control;
+
+ return (
+
+ (
+
+ )}
+ />
+ }
+ />
+
+ );
};
export default NotificationsCreatePage;
diff --git a/client/src/Validation/notifications.ts b/client/src/Validation/notifications.ts
new file mode 100644
index 000000000..c78cf1ef9
--- /dev/null
+++ b/client/src/Validation/notifications.ts
@@ -0,0 +1,51 @@
+import { z } from "zod";
+
+const baseSchema = z.object({
+ notificationName: z
+ .string()
+ .min(1, "Notification name is required")
+ .max(100, "Notification name must be at most 100 characters"),
+});
+
+const emailSchema = baseSchema.extend({
+ type: z.literal("email"),
+ address: z.string().min(1, "Email is required").email("Please enter a valid email address"),
+});
+
+const slackSchema = baseSchema.extend({
+ type: z.literal("slack"),
+ address: z.string().min(1, "Webhook URL is required").url("Please enter a valid URL"),
+});
+
+const discordSchema = baseSchema.extend({
+ type: z.literal("discord"),
+ address: z.string().min(1, "Webhook URL is required").url("Please enter a valid URL"),
+});
+
+const webhookSchema = baseSchema.extend({
+ type: z.literal("webhook"),
+ address: z.string().min(1, "Webhook URL is required").url("Please enter a valid URL"),
+});
+
+const pagerDutySchema = baseSchema.extend({
+ type: z.literal("pager_duty"),
+ address: z.string().min(1, "Integration key is required"),
+});
+
+const matrixSchema = baseSchema.extend({
+ type: z.literal("matrix"),
+ homeserverUrl: z.string().min(1, "Homeserver URL is required").url("Please enter a valid URL"),
+ roomId: z.string().min(1, "Room ID is required"),
+ accessToken: z.string().min(1, "Access token is required"),
+});
+
+export const notificationSchema = z.discriminatedUnion("type", [
+ emailSchema,
+ slackSchema,
+ discordSchema,
+ webhookSchema,
+ pagerDutySchema,
+ matrixSchema,
+]);
+
+export type NotificationFormData = z.infer;
diff --git a/client/src/locales/en.json b/client/src/locales/en.json
index 960397021..b98b43b7d 100644
--- a/client/src/locales/en.json
+++ b/client/src/locales/en.json
@@ -342,6 +342,14 @@
"headers": {
"destination": "Destination"
}
+ },
+ "form": {
+ "notificationName": {
+ "description": "A descriptive name for the notification channel",
+ "optionName": "Channel name",
+ "placeholder": "e.g. Production Alerts",
+ "title": "Channel name"
+ }
}
}
},