Merge branch 'develop' into chore/form-refactor
This commit is contained in:
15 files changed
+375
-6
No files matched your search
@@ -8,8 +8,6 @@ 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.
|
||||
return {
|
||||
type: data?.type ?? "email",
|
||||
notificationName: data?.notificationName || "",
|
||||
|
||||
@@ -3,6 +3,7 @@ export const NotificationChannels = [
|
||||
"slack",
|
||||
"discord",
|
||||
"webhook",
|
||||
"rocket_chat",
|
||||
"pager_duty",
|
||||
"matrix",
|
||||
"teams",
|
||||
|
||||
@@ -30,6 +30,14 @@ const webhookSchema = baseSchema.extend({
|
||||
address: z.string().min(1, "Webhook URL is required").url("Please enter a valid URL"),
|
||||
});
|
||||
|
||||
const rocketChatSchema = baseSchema.extend({
|
||||
type: z.literal("rocket_chat"),
|
||||
address: z
|
||||
.string()
|
||||
.min(1, "Webhook URL is required")
|
||||
.url({ protocol: /^https?$/, message: "Please enter a valid URL" }),
|
||||
});
|
||||
|
||||
const pagerDutySchema = baseSchema.extend({
|
||||
type: z.literal("pager_duty"),
|
||||
address: z.string().min(1, "Integration key is required"),
|
||||
@@ -81,6 +89,7 @@ export const notificationSchema = z.discriminatedUnion("type", [
|
||||
slackSchema,
|
||||
discordSchema,
|
||||
webhookSchema,
|
||||
rocketChatSchema,
|
||||
pagerDutySchema,
|
||||
matrixSchema,
|
||||
teamsSchema,
|
||||
|
||||
Reference in new issue
Block a user