feat: check whether user has necessary scope
This commit is contained in:
		| @@ -3,6 +3,7 @@ import { apiAuth } from "./api"; | ||||
| import { PlayerRanking } from "./types"; | ||||
| import RaceChart from "./RaceChart"; | ||||
| import { useSession } from "./Session"; | ||||
| import { useNavigate } from "react-router"; | ||||
|  | ||||
| const MVPChart = () => { | ||||
|   let initialData = {} as PlayerRanking[]; | ||||
| @@ -10,7 +11,12 @@ const MVPChart = () => { | ||||
|   const [loading, setLoading] = useState(true); | ||||
|   const [error, setError] = useState(""); | ||||
|   const [showStd, setShowStd] = useState(false); | ||||
|   const { teams } = useSession(); | ||||
|   const { user, teams } = useSession(); | ||||
|   const navigate = useNavigate(); | ||||
|   useEffect(() => { | ||||
|     user?.scopes.includes(`team:${teams?.activeTeam}`) || | ||||
|       navigate("/", { replace: true }); | ||||
|   }, [user]); | ||||
|  | ||||
|   async function loadData() { | ||||
|     setLoading(true); | ||||
|   | ||||
| @@ -11,6 +11,7 @@ import { | ||||
| } from "reagraph"; | ||||
| import { customTheme } from "./NetworkTheme"; | ||||
| import { useSession } from "./Session"; | ||||
| import { useNavigate } from "react-router"; | ||||
|  | ||||
| interface NetworkData { | ||||
|   nodes: GraphNode[]; | ||||
| @@ -45,7 +46,12 @@ export const GraphComponent = () => { | ||||
|   const [likes, setLikes] = useState(2); | ||||
|   const [popularity, setPopularity] = useState(false); | ||||
|   const [mutuality, setMutuality] = useState(false); | ||||
|   const { teams } = useSession(); | ||||
|   const { user, teams } = useSession(); | ||||
|   const navigate = useNavigate(); | ||||
|   useEffect(() => { | ||||
|     user?.scopes.includes(`team:${teams?.activeTeam}`) || | ||||
|       navigate("/", { replace: true }); | ||||
|   }, [user]); | ||||
|  | ||||
|   async function loadData() { | ||||
|     setLoading(true); | ||||
|   | ||||
| @@ -2,9 +2,15 @@ import { FormEvent, useEffect, useState } from "react"; | ||||
| import { apiAuth, loadPlayers, User } from "./api"; | ||||
| import { useSession } from "./Session"; | ||||
| import { ErrorState } from "./types"; | ||||
| import { useNavigate } from "react-router"; | ||||
|  | ||||
| const TeamPanel = () => { | ||||
|   const { teams } = useSession(); | ||||
|   const { user, teams } = useSession(); | ||||
|   const navigate = useNavigate(); | ||||
|   useEffect(() => { | ||||
|     user?.scopes.includes(`team:${teams?.activeTeam}`) || | ||||
|       navigate("/", { replace: true }); | ||||
|   }, [user]); | ||||
|   const newPlayerTemplate = { | ||||
|     id: 0, | ||||
|     username: "", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user