From 7dd378f0854d885db4dc7614ce02bcf24796ba9a Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 11 Aug 2026 17:26:15 -0700 Subject: [PATCH] remove duplicates --- client/src/Hooks/useNotificationForm.ts | 101 +++--------------------- 1 file changed, 9 insertions(+), 92 deletions(-) diff --git a/client/src/Hooks/useNotificationForm.ts b/client/src/Hooks/useNotificationForm.ts index b4b3fad7d..fdd8204d3 100644 --- a/client/src/Hooks/useNotificationForm.ts +++ b/client/src/Hooks/useNotificationForm.ts @@ -10,100 +10,17 @@ interface UseNotificationFormOptions { function buildDefaults(data: Notification | null): NotificationFormData { // Every channel field defaults to "" (not undefined) so untouched required // fields fail zod with their custom messages instead of a type error. - const base = { - notificationName: data?.notificationName || "", - address: "", - accessToken: "", - accountSid: "", - phone: "", - twilioPhoneNumber: "", - homeserverUrl: "", - roomId: "", - topic: "", - }; - if (data?.type === "matrix") { - return { - ...base, - type: "matrix", - homeserverUrl: data.homeserverUrl || "", - roomId: data.roomId || "", - accessToken: data.accessToken || "", - }; - } - if (data?.type === "telegram") { - return { - ...base, - type: "telegram", - address: data.address || "", - accessToken: data.accessToken || "", - }; - } - if (data?.type === "slack") { - return { - ...base, - type: "slack", - address: data.address || "", - }; - } - if (data?.type === "discord") { - return { - ...base, - type: "discord", - address: data.address || "", - }; - } - if (data?.type === "webhook") { - return { - ...base, - type: "webhook", - address: data.address || "", - }; - } - if (data?.type === "pager_duty") { - return { - ...base, - type: "pager_duty", - address: data.address || "", - }; - } - if (data?.type === "teams") { - return { - ...base, - type: "teams", - address: data.address || "", - }; - } - if (data?.type === "twilio") { - return { - ...base, - type: "twilio", - accountSid: data.accountSid || "", - accessToken: data.accessToken || "", - phone: data.phone || "", - twilioPhoneNumber: data.twilioPhoneNumber || "", - }; - } - if (data?.type === "pushover") { - return { - ...base, - type: "pushover", - address: data.address || "", - accessToken: data.accessToken || "", - }; - } - if (data?.type === "ntfy") { - return { - ...base, - type: "ntfy", - address: data.address || "", - topic: data.topic || "", - }; - } - // Default: email (covers both data === null and data.type === "email") return { - ...base, - type: "email", + type: data?.type ?? "email", + notificationName: data?.notificationName || "", address: data?.address || "", + accessToken: data?.accessToken || "", + accountSid: data?.accountSid || "", + phone: data?.phone || "", + twilioPhoneNumber: data?.twilioPhoneNumber || "", + homeserverUrl: data?.homeserverUrl || "", + roomId: data?.roomId || "", + topic: data?.topic || "", }; }