From 30add0e64c6d446c7943371aa94794ea757d909a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 17 Mar 2025 17:11:16 -0700 Subject: [PATCH] update internal user settings on ui --- .../src/components/SSOSettings.tsx | 5 ++- .../src/components/networking.tsx | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/src/components/SSOSettings.tsx b/ui/litellm-dashboard/src/components/SSOSettings.tsx index 21d44c93d8d..21c10b7cec7 100644 --- a/ui/litellm-dashboard/src/components/SSOSettings.tsx +++ b/ui/litellm-dashboard/src/components/SSOSettings.tsx @@ -43,10 +43,9 @@ const SSOSettings: React.FC = ({ accessToken }) => { setSaving(true); try { - await updateInternalUserSettings(accessToken, editedValues); - setSettings({...settings, values: editedValues}); + const updatedSettings = await updateInternalUserSettings(accessToken, editedValues); + setSettings({...settings, values: updatedSettings.settings}); setIsEditing(false); - message.success("Settings updated successfully"); } catch (error) { console.error("Error updating SSO settings:", error); message.error("Failed to update settings"); diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 255a72fca26..1079b5b2787 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -4006,3 +4006,37 @@ export const getInternalUserSettings = async (accessToken: string) => { } }; + +export const updateInternalUserSettings = async (accessToken: string, settings: Record) => { + try { + // Construct base URL + let url = proxyBaseUrl + ? `${proxyBaseUrl}/update/internal_user_settings` + : `/update/internal_user_settings`; + + console.log("Updating internal user settings:", settings); + + const response = await fetch(url, { + method: "PATCH", + headers: { + [globalLitellmHeaderName]: `Bearer ${accessToken}`, + "Content-Type": "application/json", + }, + body: JSON.stringify(settings), + }); + + if (!response.ok) { + const errorData = await response.text(); + handleError(errorData); + throw new Error("Network response was not ok"); + } + + const data = await response.json(); + console.log("Updated internal user settings:", data); + message.success("Internal user settings updated successfully"); + return data; + } catch (error) { + console.error("Failed to update internal user settings:", error); + throw error; + } +};