import React, { useState, useEffect } from "react"; import { Select, SelectItem, Text, Title } from "@tremor/react"; import { ProxySettings, UserInfo } from "./user_dashboard"; import { getProxyUISettings } from "./networking" interface DashboardTeamProps { teams: Object[] | null; setSelectedTeam: React.Dispatch>; userRole: string | null; proxySettings: ProxySettings | null; setProxySettings: React.Dispatch>; userInfo: UserInfo | null; accessToken: string | null; setKeys: React.Dispatch>; } type TeamInterface = { models: any[]; team_id: null; team_alias: String; max_budget: number | null; } const DashboardTeam: React.FC = ({ teams, setSelectedTeam, userRole, proxySettings, setProxySettings, userInfo, accessToken, setKeys }) => { console.log(`userInfo: ${JSON.stringify(userInfo)}`) const defaultTeam: TeamInterface = { models: userInfo?.models || [], team_id: null, team_alias: "Default Team", max_budget: userInfo?.max_budget || null, } const getProxySettings = async () => { if (proxySettings === null && accessToken) { const proxy_settings: ProxySettings = await getProxyUISettings(accessToken); setProxySettings(proxy_settings); } }; useEffect(() => { getProxySettings(); }, [proxySettings]); const [value, setValue] = useState(defaultTeam); let updatedTeams; console.log(`userRole: ${userRole}`) console.log(`proxySettings: ${JSON.stringify(proxySettings)}`) if (userRole === "App User") { // Non-Admin SSO users should only see their own team - they should not see "Default Team" updatedTeams = teams; } else if (proxySettings && proxySettings.DEFAULT_TEAM_DISABLED === true) { updatedTeams = teams ? [...teams] : [defaultTeam]; } else { updatedTeams = teams ? [...teams, defaultTeam] : [defaultTeam]; } return (
Select Team If you belong to multiple teams, this setting controls which team is used by default when creating new API Keys. Default Team: If no team_id is set for a key, it will be grouped under here. {updatedTeams && updatedTeams.length > 0 ? ( ) : ( No team created. Defaulting to personal account. )}
); }; export default DashboardTeam;