diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsx index 98bf8ad..8e7d874 100644 --- a/frontend/src/pages/Settings.jsx +++ b/frontend/src/pages/Settings.jsx @@ -100,12 +100,15 @@ const Settings = () => { queryClient.invalidateQueries(['settings']); // Update form data with the returned data setFormData({ - serverProtocol: data.serverProtocol || 'http', - serverHost: data.serverHost || 'localhost', - serverPort: data.serverPort || 3001, - frontendUrl: data.frontendUrl || 'http://localhost:3000', - updateInterval: data.updateInterval || 60, - autoUpdate: data.autoUpdate || false + serverProtocol: data.settings?.serverProtocol || data.serverProtocol || 'http', + serverHost: data.settings?.serverHost || data.serverHost || 'localhost', + serverPort: data.settings?.serverPort || data.serverPort || 3001, + frontendUrl: data.settings?.frontendUrl || data.frontendUrl || 'http://localhost:3000', + updateInterval: data.settings?.updateInterval || data.updateInterval || 60, + autoUpdate: data.settings?.autoUpdate || data.autoUpdate || false, + githubRepoUrl: data.settings?.githubRepoUrl || data.githubRepoUrl || 'git@github.com:9technologygroup/patchmon.net.git', + sshKeyPath: data.settings?.sshKeyPath || data.sshKeyPath || '', + useCustomSshKey: !!(data.settings?.sshKeyPath || data.sshKeyPath) }); setIsDirty(false); setErrors({}); @@ -289,7 +292,16 @@ const Settings = () => { console.log('Saving settings:', formData); if (validateForm()) { console.log('Validation passed, calling mutation'); - updateSettingsMutation.mutate(formData); + + // Prepare data for submission + const dataToSubmit = { ...formData }; + if (!dataToSubmit.useCustomSshKey) { + dataToSubmit.sshKeyPath = ''; + } + // Remove the frontend-only field + delete dataToSubmit.useCustomSshKey; + + updateSettingsMutation.mutate(dataToSubmit); } else { console.log('Validation failed:', errors); } @@ -885,25 +897,40 @@ const Settings = () => { -
- +
+
+ +
+ {/* Save Button for Version Settings */}
@@ -925,6 +952,18 @@ const Settings = () => {
)} + + {/* Success Message for Version Settings */} + {updateSettingsMutation.isSuccess && ( +
+
+ +
+

Settings saved successfully!

+
+
+
+ )}