Skip to content

Commit

Permalink
ui bug bash fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jedan2506 committed Jul 19, 2023
1 parent 79a3c55 commit 49fc287
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions gui/pages/Dashboard/Settings/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ export default function Settings({organisationId}) {

function getKey(key) {
getOrganisationConfig(organisationId, key)
.then((response) => {
setKey(response.data.value);
})
.catch((error) => {
console.error('Error fetching project:', error);
});
.then((response) => {
setKey(response.data.value);
})
.catch((error) => {
console.error('Error fetching project:', error);
});
}

function getSource(key) {
getOrganisationConfig(organisationId, key)
.then((response) => {
setSource(response.data.value);
})
.catch((error) => {
console.error('Error fetching project:', error);
});
.then((response) => {
setSource(response.data.value);
})
.catch((error) => {
console.error('Error fetching project:', error);
});
}

useEffect(() => {
Expand All @@ -54,13 +54,13 @@ export default function Settings({organisationId}) {
function updateKey(key, value) {
const configData = { "key": key, "value": value };
return updateOrganisationConfig(organisationId, configData)
.then((response) => {
return response.data;
})
.catch((error) => {
console.error('Error updating settings:', error);
throw new Error('Failed to update settings');
});
.then((response) => {
return response.data;
})
.catch((error) => {
console.error('Error updating settings:', error);
throw new Error('Failed to update settings');
});
}

const handleModelApiKey = (event) => {
Expand All @@ -79,27 +79,27 @@ export default function Settings({organisationId}) {
}

validateLLMApiKey(source, modelApiKey)
.then((response) => {
if (response.data.status === "success") {
Promise.all([
updateKey("model_api_key", modelApiKey),
updateKey("model_source", source)
])
.then(() => {
toast.success("Settings updated", { autoClose: 1800 });
})
.catch((error) => {
console.error('Error updating settings:', error);
toast.error("Failed to update settings", { autoClose: 1800 });
});
} else {
toast.error("Invalid API key", { autoClose: 1800 });
}
})
.catch((error) => {
console.error('Error validating API key:', error);
toast.error("Failed to validate API key", { autoClose: 1800 });
});
.then((response) => {
if (response.data.status === "success") {
Promise.all([
updateKey("model_api_key", modelApiKey),
updateKey("model_source", source)
])
.then(() => {
toast.success("Settings updated", { autoClose: 1800 });
})
.catch((error) => {
console.error('Error updating settings:', error);
toast.error("Failed to update settings", { autoClose: 1800 });
});
} else {
toast.error("Invalid API key", { autoClose: 1800 });
}
})
.catch((error) => {
console.error('Error validating API key:', error);
toast.error("Failed to validate API key", { autoClose: 1800 });
});
};

const handleTemperatureChange = (event) => {
Expand Down

0 comments on commit 49fc287

Please sign in to comment.