feat: add a Team Panel

This commit is contained in:
2025-03-23 15:01:26 +01:00
parent 8c938a7ebc
commit 691b99daa8
6 changed files with 157 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ import {
useState,
} from "react";
import { ReactSortable, ReactSortableProps } from "react-sortablejs";
import { apiAuth, User } from "./api";
import { apiAuth, loadPlayers, User } from "./api";
import { TeamState, useSession } from "./Session";
import { Chemistry, MVPRanking } from "./types";
import TabController from "./TabController";
@@ -307,23 +307,10 @@ export default function Rankings() {
const { user, teams } = useSession();
const [players, setPlayers] = useState<User[] | null>(null);
async function loadPlayers() {
if (teams) {
try {
const data = await apiAuth(
`player/list/${teams?.activeTeam}`,
null,
"GET"
);
setPlayers(data as User[]);
} catch (error) {
console.error(error);
}
}
}
useEffect(() => {
loadPlayers();
if (teams) {
loadPlayers(teams.activeTeam).then((data) => setPlayers(data));
}
}, [user, teams]);
const tabs = [