Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions apps/admin/src/sections/nodes/node-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ const buildSchema = (t: TFunction) =>
.int()
.min(1, t("errors.portRange", "Port must be between 1 and 65535"))
.max(65_535, t("errors.portRange", "Port must be between 1 and 65535")),
tags: z.array(z.string()),
tags: z.preprocess((v) => (Array.isArray(v) ? v : []), z.array(z.string())),
});

export type NodeFormValues = z.infer<ReturnType<typeof buildSchema>>;

function normalizeValues(v?: Partial<NodeFormValues>): Partial<NodeFormValues> {
if (!v) return {};
return { ...v, tags: Array.isArray(v.tags) ? v.tags : [] };
}

export default function NodeForm(props: {
trigger: string;
title: string;
Expand Down Expand Up @@ -112,7 +117,7 @@ export default function NodeForm(props: {
address: "",
port: 0,
tags: [],
...initialValues,
...normalizeValues(initialValues),
},
});

Expand All @@ -134,7 +139,7 @@ export default function NodeForm(props: {
address: "",
port: 0,
tags: [],
...initialValues,
...normalizeValues(initialValues),
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down