diff --git a/apps/dokploy/components/dashboard/compose/general/randomize-deployable.tsx b/apps/dokploy/components/dashboard/compose/general/randomize-deployable.tsx index 6ed936055..db0c5242f 100644 --- a/apps/dokploy/components/dashboard/compose/general/randomize-deployable.tsx +++ b/apps/dokploy/components/dashboard/compose/general/randomize-deployable.tsx @@ -3,21 +3,21 @@ import { CodeEditor } from "@/components/shared/code-editor"; import { Button } from "@/components/ui/button"; import { CardTitle } from "@/components/ui/card"; import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, } from "@/components/ui/dialog"; import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; @@ -30,166 +30,166 @@ import { toast } from "sonner"; import { z } from "zod"; interface Props { - composeId: string; + composeId: string; } const schema = z.object({ - deployable: z.boolean().optional(), + deployable: z.boolean().optional(), }); type Schema = z.infer; export const RandomizeDeployable = ({ composeId }: Props) => { - const utils = api.useUtils(); - const [compose, setCompose] = useState(""); - const [isOpen, setIsOpen] = useState(false); - const { mutateAsync, error, isError } = - api.compose.randomizeDeployableCompose.useMutation(); + const utils = api.useUtils(); + const [compose, setCompose] = useState(""); + const [isOpen, setIsOpen] = useState(false); + const { mutateAsync, error, isError } = + api.compose.randomizeDeployableCompose.useMutation(); - const { mutateAsync: updateCompose } = api.compose.update.useMutation(); + const { mutateAsync: updateCompose } = api.compose.update.useMutation(); - const { data, refetch } = api.compose.one.useQuery( - { composeId }, - { enabled: !!composeId } - ); + const { data, refetch } = api.compose.one.useQuery( + { composeId }, + { enabled: !!composeId }, + ); - const form = useForm({ - defaultValues: { - deployable: false, - }, - resolver: zodResolver(schema), - }); + const form = useForm({ + defaultValues: { + deployable: false, + }, + resolver: zodResolver(schema), + }); - useEffect(() => { - if (data) { - form.reset({ - deployable: data?.deployable || false, - }); - } - }, [form, form.reset, form.formState.isSubmitSuccessful, data]); + useEffect(() => { + if (data) { + form.reset({ + deployable: data?.deployable || false, + }); + } + }, [form, form.reset, form.formState.isSubmitSuccessful, data]); - const onSubmit = async (formData: Schema) => { - await updateCompose({ - composeId, - deployable: formData?.deployable || false, - }) - .then(async (data) => { - randomizeCompose(); - refetch(); - toast.success("Compose updated"); - }) - .catch(() => { - toast.error("Error randomizing the compose"); - }); - }; + const onSubmit = async (formData: Schema) => { + await updateCompose({ + composeId, + deployable: formData?.deployable || false, + }) + .then(async (data) => { + randomizeCompose(); + refetch(); + toast.success("Compose updated"); + }) + .catch(() => { + toast.error("Error randomizing the compose"); + }); + }; - const randomizeCompose = async () => { - await mutateAsync({ - composeId, - suffix: data?.appName || "", - }) - .then(async (data) => { - await utils.project.all.invalidate(); - setCompose(data); - toast.success("Compose randomized"); - }) - .catch(() => { - toast.error("Error randomizing the compose"); - }); - }; + const randomizeCompose = async () => { + await mutateAsync({ + composeId, + suffix: data?.appName || "", + }) + .then(async (data) => { + await utils.project.all.invalidate(); + setCompose(data); + toast.success("Compose randomized"); + }) + .catch(() => { + toast.error("Error randomizing the compose"); + }); + }; - return ( - - randomizeCompose()}> - - - - - Randomize Deployable (Experimental) - - Use this in case you want to deploy the same compose file twice. - - -
- - This will randomize the compose file and will add a suffix to the - property to avoid conflicts - -
    -
  • volumes
  • -
  • networks
  • -
- - When you activate this option, we will include a env - `DOKPLOY_SUFFIX` variable to the compose file so you can use it in - your compose file, also we don't include the{" "} - dokploy-network to any of the services by default. - -
- {isError && {error?.message}} -
- - {isError && ( -
- - - {error?.message} - -
- )} + return ( + + randomizeCompose()}> + + + + + Randomize Deployable (Experimental) + + Use this in case you want to deploy the same compose file twice. + + +
+ + This will randomize the compose file and will add a suffix to the + property to avoid conflicts + +
    +
  • volumes
  • +
  • networks
  • +
+ + When you activate this option, we will include a env + `DOKPLOY_SUFFIX` variable to the compose file so you can use it in + your compose file, also we don't include the{" "} + dokploy-network to any of the services by default. + +
+ {isError && {error?.message}} + + + {isError && ( +
+ + + {error?.message} + +
+ )} -
-
- ( - -
- Apply Randomize ({data?.appName}) - - Apply randomize to the compose file. - -
- - - -
- )} - /> -
+
+
+ ( + +
+ Apply Randomize ({data?.appName}) + + Apply randomize to the compose file. + +
+ + + +
+ )} + /> +
-
- -
-
-
-              
-            
- - - -
- ); +
+ +
+ +
+							
+						
+ + +
+
+ ); };