mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user