team page added, uses data from previous page so that the team isn't loaded again if it's clicked from the team list
This commit is contained in:
parent
091634161f
commit
0e98d7329f
7 changed files with 63 additions and 23 deletions
|
|
@ -11,7 +11,7 @@ import {
|
|||
IconButton,
|
||||
} from "@mui/material";
|
||||
import { pond } from "protobuf-ts/pond";
|
||||
import { useGlobalState, useTeamAPI, useUserAPI } from "providers";
|
||||
import { useGlobalState, useSnackbar, useTeamAPI, useUserAPI } from "providers";
|
||||
import { Team, teamScope } from "models";
|
||||
import { useNavigate } from "react-router";
|
||||
import { cloneDeep } from "lodash";
|
||||
|
|
@ -57,6 +57,7 @@ export default function TeamList() {
|
|||
const userAPI = useUserAPI();
|
||||
const history = useNavigate();
|
||||
const isMobile = useMobile()
|
||||
const snackbar = useSnackbar();
|
||||
const [{ user, as }] = useGlobalState();
|
||||
const [teamPerms, setTeamPerms] = useState<Map<string | number, pond.Permission[]>>(new Map());
|
||||
const [teamPrefs, setTeamPrefs] = useState<Map<string | number, pond.TeamPreferences> >(new Map());
|
||||
|
|
@ -91,13 +92,17 @@ export default function TeamList() {
|
|||
.then(resp => {
|
||||
newTeamPerms.set(t.key(), resp.permissions)
|
||||
newTeamPrefs.set(t.key(), resp.preferences)
|
||||
t.preferences = cloneDeep(resp.preferences)
|
||||
t.permissions = cloneDeep(resp.permissions)
|
||||
}).catch(() => {
|
||||
snackbar.error("Error loading teams.")
|
||||
})
|
||||
.finally(() => {
|
||||
setTeamPerms(newTeamPerms);
|
||||
setTeamPrefs(newTeamPrefs);
|
||||
});
|
||||
}
|
||||
newTeams.push(Team.create(team))
|
||||
newTeams.push(t)
|
||||
});
|
||||
setTeams(newTeams);
|
||||
})
|
||||
|
|
@ -158,7 +163,7 @@ export default function TeamList() {
|
|||
>
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
if (team.settings) history(team.settings.key);
|
||||
if (team.settings) history(team.settings.key, { state: {team: team} });
|
||||
}}
|
||||
>
|
||||
<ListItemAvatar sx={{ marginLeft: isMobile ? -2 : 0 }}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue