Fix type safety and optimize mutation payload in network form

Co-authored-by: Siumauricio <[email protected]>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-04 15:22:26 +00:00
co-authored by Siumauricio
parent f6f0921560
commit 582f493f3f
@@ -63,7 +63,7 @@ export const NetworkForm = ({ id, type }: NetworkFormProps) => {
? mutationMap[type]() ? mutationMap[type]()
: api.mongo.update.useMutation(); : api.mongo.update.useMutation();
const form = useForm<any>({ const form = useForm<z.infer<typeof networkFormSchema>>({
resolver: zodResolver(networkFormSchema), resolver: zodResolver(networkFormSchema),
defaultValues: { defaultValues: {
networks: [], networks: [],
@@ -101,15 +101,31 @@ export const NetworkForm = ({ id, type }: NetworkFormProps) => {
// If no networks, send null to clear the database // If no networks, send null to clear the database
const networksToSend = networksArray.length > 0 ? networksArray : null; const networksToSend = networksArray.length > 0 ? networksArray : null;
await mutateAsync({ const mutationPayload: any = { networkSwarm: networksToSend };
applicationId: id || "",
postgresId: id || "", // Add the appropriate ID based on type
redisId: id || "", switch (type) {
mysqlId: id || "", case "application":
mariadbId: id || "", mutationPayload.applicationId = id;
mongoId: id || "", break;
networkSwarm: networksToSend, case "postgres":
}); mutationPayload.postgresId = id;
break;
case "redis":
mutationPayload.redisId = id;
break;
case "mysql":
mutationPayload.mysqlId = id;
break;
case "mariadb":
mutationPayload.mariadbId = id;
break;
case "mongo":
mutationPayload.mongoId = id;
break;
}
await mutateAsync(mutationPayload);
toast.success("Network configuration updated successfully"); toast.success("Network configuration updated successfully");
refetch(); refetch();