Fix type safety and optimize mutation payload in network form

Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-04 15:22:26 +00:00
parent f6f0921560
commit 582f493f3f

View File

@@ -63,7 +63,7 @@ export const NetworkForm = ({ id, type }: NetworkFormProps) => {
? mutationMap[type]()
: api.mongo.update.useMutation();
const form = useForm<any>({
const form = useForm<z.infer<typeof networkFormSchema>>({
resolver: zodResolver(networkFormSchema),
defaultValues: {
networks: [],
@@ -101,15 +101,31 @@ export const NetworkForm = ({ id, type }: NetworkFormProps) => {
// If no networks, send null to clear the database
const networksToSend = networksArray.length > 0 ? networksArray : null;
await mutateAsync({
applicationId: id || "",
postgresId: id || "",
redisId: id || "",
mysqlId: id || "",
mariadbId: id || "",
mongoId: id || "",
networkSwarm: networksToSend,
});
const mutationPayload: any = { networkSwarm: networksToSend };
// Add the appropriate ID based on type
switch (type) {
case "application":
mutationPayload.applicationId = id;
break;
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");
refetch();