forked from phoenix/litellm-mirror
uo fixes for default team (#6134)
This commit is contained in:
parent
4b4bb9296f
commit
74ae7deee3
2 changed files with 19 additions and 0 deletions
|
@ -1,13 +1,16 @@
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import { Select, SelectItem, Text, Title } from "@tremor/react";
|
import { Select, SelectItem, Text, Title } from "@tremor/react";
|
||||||
import { ProxySettings, UserInfo } from "./user_dashboard";
|
import { ProxySettings, UserInfo } from "./user_dashboard";
|
||||||
|
import { getProxyBaseUrlAndLogoutUrl } from "./networking"
|
||||||
|
|
||||||
interface DashboardTeamProps {
|
interface DashboardTeamProps {
|
||||||
teams: Object[] | null;
|
teams: Object[] | null;
|
||||||
setSelectedTeam: React.Dispatch<React.SetStateAction<any | null>>;
|
setSelectedTeam: React.Dispatch<React.SetStateAction<any | null>>;
|
||||||
userRole: string | null;
|
userRole: string | null;
|
||||||
proxySettings: ProxySettings | null;
|
proxySettings: ProxySettings | null;
|
||||||
|
setProxySettings: React.Dispatch<React.SetStateAction<ProxySettings | null>>;
|
||||||
userInfo: UserInfo | null;
|
userInfo: UserInfo | null;
|
||||||
|
accessToken: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TeamInterface = {
|
type TeamInterface = {
|
||||||
|
@ -22,7 +25,9 @@ const DashboardTeam: React.FC<DashboardTeamProps> = ({
|
||||||
setSelectedTeam,
|
setSelectedTeam,
|
||||||
userRole,
|
userRole,
|
||||||
proxySettings,
|
proxySettings,
|
||||||
|
setProxySettings,
|
||||||
userInfo,
|
userInfo,
|
||||||
|
accessToken
|
||||||
}) => {
|
}) => {
|
||||||
console.log(`userInfo: ${JSON.stringify(userInfo)}`)
|
console.log(`userInfo: ${JSON.stringify(userInfo)}`)
|
||||||
const defaultTeam: TeamInterface = {
|
const defaultTeam: TeamInterface = {
|
||||||
|
@ -32,10 +37,22 @@ const DashboardTeam: React.FC<DashboardTeamProps> = ({
|
||||||
max_budget: userInfo?.max_budget || null,
|
max_budget: userInfo?.max_budget || null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getProxySettings = async () => {
|
||||||
|
if (proxySettings === null && accessToken) {
|
||||||
|
const proxy_settings: ProxySettings = await getProxyBaseUrlAndLogoutUrl(accessToken);
|
||||||
|
setProxySettings(proxy_settings);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getProxySettings();
|
||||||
|
}, [proxySettings]);
|
||||||
|
|
||||||
const [value, setValue] = useState(defaultTeam);
|
const [value, setValue] = useState(defaultTeam);
|
||||||
|
|
||||||
let updatedTeams;
|
let updatedTeams;
|
||||||
|
console.log(`userRole: ${userRole}`)
|
||||||
|
console.log(`proxySettings: ${JSON.stringify(proxySettings)}`)
|
||||||
if (userRole === "App User") {
|
if (userRole === "App User") {
|
||||||
// Non-Admin SSO users should only see their own team - they should not see "Default Team"
|
// Non-Admin SSO users should only see their own team - they should not see "Default Team"
|
||||||
updatedTeams = teams;
|
updatedTeams = teams;
|
||||||
|
|
|
@ -349,7 +349,9 @@ const UserDashboard: React.FC<UserDashboardProps> = ({
|
||||||
setSelectedTeam={setSelectedTeam}
|
setSelectedTeam={setSelectedTeam}
|
||||||
userRole={userRole}
|
userRole={userRole}
|
||||||
proxySettings={proxySettings}
|
proxySettings={proxySettings}
|
||||||
|
setProxySettings={setProxySettings}
|
||||||
userInfo={userSpendData}
|
userInfo={userSpendData}
|
||||||
|
accessToken={accessToken}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue