mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-04 19:44:47 +00:00
fix cant save form
This commit is contained in:
@@ -1156,6 +1156,7 @@ export function AlertRuleSourceFields({
|
||||
<FormField
|
||||
control={control}
|
||||
name="allSites"
|
||||
shouldUnregister={false}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<StrategySelect
|
||||
@@ -1198,6 +1199,7 @@ export function AlertRuleSourceFields({
|
||||
<FormField
|
||||
control={control}
|
||||
name="allResources"
|
||||
shouldUnregister={false}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<StrategySelect
|
||||
@@ -1240,6 +1242,7 @@ export function AlertRuleSourceFields({
|
||||
<FormField
|
||||
control={control}
|
||||
name="allHealthChecks"
|
||||
shouldUnregister={false}
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<StrategySelect
|
||||
|
||||
@@ -34,7 +34,7 @@ import { ChevronLeft, Cog, Flag, Zap } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMemo, useState, type ReactNode } from "react";
|
||||
import { useFieldArray, useForm } from "react-hook-form";
|
||||
import { useFieldArray, useForm, type Resolver } from "react-hook-form";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
||||
import { SwitchInput } from "@app/components/SwitchInput";
|
||||
@@ -116,7 +116,7 @@ export default function AlertRuleGraphEditor({
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const schema = useMemo(() => buildFormSchema(t), [t]);
|
||||
const form = useForm<AlertRuleFormValues>({
|
||||
resolver: zodResolver(schema),
|
||||
resolver: zodResolver(schema) as Resolver<AlertRuleFormValues>,
|
||||
defaultValues: initialValues ?? defaultFormValues()
|
||||
});
|
||||
|
||||
|
||||
@@ -142,12 +142,12 @@ export function buildFormSchema(t: (k: string) => string) {
|
||||
.min(1, { message: t("alertingErrorNameRequired") }),
|
||||
enabled: z.boolean(),
|
||||
sourceType: z.enum(["site", "health_check", "resource"]),
|
||||
allSites: z.boolean(),
|
||||
siteIds: z.array(z.number()),
|
||||
allHealthChecks: z.boolean(),
|
||||
healthCheckIds: z.array(z.number()),
|
||||
allResources: z.boolean(),
|
||||
resourceIds: z.array(z.number()),
|
||||
allSites: z.boolean().default(true),
|
||||
siteIds: z.array(z.number()).default([]),
|
||||
allHealthChecks: z.boolean().default(true),
|
||||
healthCheckIds: z.array(z.number()).default([]),
|
||||
allResources: z.boolean().default(true),
|
||||
resourceIds: z.array(z.number()).default([]),
|
||||
trigger: z.enum([
|
||||
"site_online",
|
||||
"site_offline",
|
||||
@@ -332,8 +332,8 @@ export function apiResponseToFormValues(
|
||||
const sourceType = rule.eventType.startsWith("site_")
|
||||
? "site"
|
||||
: rule.eventType.startsWith("resource_")
|
||||
? "resource"
|
||||
: "health_check";
|
||||
? "resource"
|
||||
: "health_check";
|
||||
|
||||
// Collect notify recipients into a single notify action (if any)
|
||||
const userTags = rule.recipients
|
||||
|
||||
Reference in New Issue
Block a user