feat: add a Team Panel
This commit is contained in:
@@ -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 = [
|
||||
|
Reference in New Issue
Block a user