diff --git a/ui/litellm-dashboard/src/components/teams.tsx b/ui/litellm-dashboard/src/components/teams.tsx index 8a8d0b037..ed853d8d1 100644 --- a/ui/litellm-dashboard/src/components/teams.tsx +++ b/ui/litellm-dashboard/src/components/teams.tsx @@ -1,6 +1,8 @@ import React, { useState, useEffect } from "react"; import Link from "next/link"; import { Typography } from "antd"; +import { teamDeleteCall } from "./networking"; +import { InformationCircleIcon, PencilAltIcon, PencilIcon, StatusOnlineIcon, TrashIcon } from "@heroicons/react/outline"; import { Button as Button2, Modal, @@ -56,6 +58,8 @@ const Team: React.FC = ({ const [isTeamModalVisible, setIsTeamModalVisible] = useState(false); const [isAddMemberModalVisible, setIsAddMemberModalVisible] = useState(false); const [userModels, setUserModels] = useState([]); + const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [teamToDelete, setTeamToDelete] = useState(null); const handleOk = () => { setIsTeamModalVisible(false); @@ -77,6 +81,40 @@ const Team: React.FC = ({ memberForm.resetFields(); }; + const handleDelete = async (team_id: string) => { + // Set the team to delete and open the confirmation modal + setTeamToDelete(team_id); + setIsDeleteModalOpen(true); + }; + + const confirmDelete = async () => { + if (teamToDelete == null || teams == null || accessToken == null) { + return; + } + + try { + await teamDeleteCall(accessToken, teamToDelete); + // Successfully completed the deletion. Update the state to trigger a rerender. + const filteredData = teams.filter((item) => item.team_id !== teamToDelete); + setTeams(filteredData); + } catch (error) { + console.error("Error deleting the team:", error); + // Handle any error situations, such as displaying an error message to the user. + } + + // Close the confirmation modal and reset the teamToDelete + setIsDeleteModalOpen(false); + setTeamToDelete(null); + }; + + const cancelDelete = () => { + // Close the confirmation modal and reset the teamToDelete + setIsDeleteModalOpen(false); + setTeamToDelete(null); + }; + + + useEffect(() => { const fetchUserModels = async () => { try { @@ -115,7 +153,7 @@ const Team: React.FC = ({ setIsTeamModalVisible(false); } } catch (error) { - console.error("Error creating the key:", error); + console.error("Error creating the team:", error); message.error("Error creating the team: " + error); } }; @@ -153,7 +191,7 @@ const Team: React.FC = ({ setIsAddMemberModalVisible(false); } } catch (error) { - console.error("Error creating the key:", error); + console.error("Error creating the team:", error); } }; console.log(`received teams ${teams}`); @@ -208,14 +246,66 @@ const Team: React.FC = ({ {team.rpm_limit ? team.rpm_limit : "Unlimited"} - {/* - - */} + + + handleDelete(team.team_id)} + icon={TrashIcon} + size="sm" + /> + )) : null} + {isDeleteModalOpen && ( +
+
+ + + {/* Modal Panel */} + + + {/* Confirmation Modal Content */} +
+
+
+
+

+ Delete Team +

+
+

+ Are you sure you want to delete this team ? +

+
+
+
+
+
+ + +
+
+
+
+ )}