remove duplicates

This commit is contained in:
Alex Holliday committed 2026-08-11 17:26:15 -07:00
1 parent a7fb235c56
commit 7dd378f085
1 file changed
+9 -92
+9 -92
View File
@@ -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 || "",
};
}