diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsx index 424ddfcec..cc3df26f9 100644 --- a/ui/litellm-dashboard/src/app/page.tsx +++ b/ui/litellm-dashboard/src/app/page.tsx @@ -5,14 +5,16 @@ import Navbar from "../components/navbar"; import UserDashboard from "../components/user_dashboard"; import ModelDashboard from "@/components/model_dashboard"; import ViewUserDashboard from "@/components/view_users"; +import Teams from "@/components/teams"; import ChatUI from "@/components/chat_ui"; import Sidebar from "../components/leftnav"; import Usage from "../components/usage"; import { jwtDecode } from "jwt-decode"; const CreateKeyPage = () => { - const [userRole, setUserRole] = useState(''); + const [userRole, setUserRole] = useState(""); const [userEmail, setUserEmail] = useState(null); + const [teams, setTeams] = useState(null); const searchParams = useSearchParams(); const userID = searchParams.get("userID"); @@ -74,14 +76,20 @@ const CreateKeyPage = () => {
- + {page == "api-keys" ? ( ) : page == "models" ? ( { token={token} accessToken={accessToken} /> - ) - : page == "users" ? ( + ) : page == "users" ? ( - ) - : ( + ) : page == "teams" ? ( + + ) : ( { + const [userRole, setUserRole] = useState(""); + const [userEmail, setUserEmail] = useState(null); + const [teams, setTeams] = useState(null); + const searchParams = useSearchParams(); + + const userID = searchParams.get("userID"); + const token = searchParams.get("token"); + + const [page, setPage] = useState("team"); + const [accessToken, setAccessToken] = useState(null); + + useEffect(() => { + if (token) { + const decoded = jwtDecode(token) as { [key: string]: any }; + if (decoded) { + // cast decoded to dictionary + console.log("Decoded token:", decoded); + + console.log("Decoded key:", decoded.key); + // set accessToken + setAccessToken(decoded.key); + + // check if userRole is defined + if (decoded.user_role) { + const formattedUserRole = formatUserRole(decoded.user_role); + console.log("Decoded user_role:", formattedUserRole); + setUserRole(formattedUserRole); + } else { + console.log("User role not defined"); + } + + if (decoded.user_email) { + setUserEmail(decoded.user_email); + } else { + console.log(`User Email is not set ${decoded}`); + } + } + } + }, [token]); + + function formatUserRole(userRole: string) { + if (!userRole) { + return "Undefined Role"; + } + console.log(`Received user role: ${userRole}`); + switch (userRole.toLowerCase()) { + case "app_owner": + return "App Owner"; + case "demo_app_owner": + return "App Owner"; + case "app_admin": + return "Admin"; + case "app_user": + return "App User"; + default: + return "Unknown Role"; + } + } + + return ( + Loading...
}> +
+ +
+ + + + + + + Team Name + Spend (USD) + Budget (USD) + TPM / RPM Limits + Settings + + + + + + Wilhelm Tell + 1 + Uri, Schwyz, Unterwalden + National Hero + + + + + + The Witcher + 129 + Kaedwen + Legend + + + + + + Mizutsune + 82 + Japan + N/A + + + + + +
+
+ + + + + + +
+
+
+ + ); +}; +export default TeamSettingsPage; diff --git a/ui/litellm-dashboard/src/components/leftnav.tsx b/ui/litellm-dashboard/src/components/leftnav.tsx index da7e9f432..59c0897bf 100644 --- a/ui/litellm-dashboard/src/components/leftnav.tsx +++ b/ui/litellm-dashboard/src/components/leftnav.tsx @@ -1,5 +1,6 @@ import { Layout, Menu } from "antd"; import Link from "next/link"; +import { List } from "postcss/lib/list"; const { Sider } = Layout; @@ -7,15 +8,20 @@ const { Sider } = Layout; interface SidebarProps { setPage: React.Dispatch>; userRole: string; + defaultSelectedKey: string[] | null; } -const Sidebar: React.FC = ({ setPage, userRole }) => { +const Sidebar: React.FC = ({ + setPage, + userRole, + defaultSelectedKey, +}) => { return ( setPage("api-keys")}> diff --git a/ui/litellm-dashboard/src/components/navbar.tsx b/ui/litellm-dashboard/src/components/navbar.tsx index 3546bcc5f..bb13d100f 100644 --- a/ui/litellm-dashboard/src/components/navbar.tsx +++ b/ui/litellm-dashboard/src/components/navbar.tsx @@ -29,14 +29,19 @@ const Navbar: React.FC = ({ userID, userRole, userEmail }) => { const isLocal = process.env.NODE_ENV === "development"; const imageUrl = isLocal ? "http://localhost:4000/get_image" : "/get_image"; - return (