diff --git a/apps/dokploy/components/dashboard/application/environment/show-enviroment.tsx b/apps/dokploy/components/dashboard/application/environment/show-enviroment.tsx
index cc208d9bf..8a78c2745 100644
--- a/apps/dokploy/components/dashboard/application/environment/show-enviroment.tsx
+++ b/apps/dokploy/components/dashboard/application/environment/show-enviroment.tsx
@@ -71,15 +71,19 @@ export const ShowEnvironment = ({ id, type }: Props) => {
resolver: zodResolver(addEnvironmentSchema),
});
+ // Watch form value
+ const currentEnvironment = form.watch("environment");
+ const hasChanges = currentEnvironment !== (data?.env || "");
+
useEffect(() => {
if (data) {
form.reset({
environment: data.env || "",
});
}
- }, [form.reset, data, form]);
+ }, [data, form]);
- const onSubmit = async (data: EnvironmentSchema) => {
+ const onSubmit = async (formData: EnvironmentSchema) => {
mutateAsync({
mongoId: id || "",
postgresId: id || "",
@@ -87,7 +91,7 @@ export const ShowEnvironment = ({ id, type }: Props) => {
mysqlId: id || "",
mariadbId: id || "",
composeId: id || "",
- env: data.environment,
+ env: formData.environment,
})
.then(async () => {
toast.success("Environments Added");
@@ -98,6 +102,12 @@ export const ShowEnvironment = ({ id, type }: Props) => {
});
};
+ const handleCancel = () => {
+ form.reset({
+ environment: data?.env || "",
+ });
+ };
+
return (
@@ -106,6 +116,11 @@ export const ShowEnvironment = ({ id, type }: Props) => {
Environment Settings
You can add environment variables to your resource.
+ {hasChanges && (
+
+ (You have unsaved changes)
+
+ )}
@@ -155,8 +170,22 @@ PORT=3000
)}
/>
-
-