diff --git a/frontend2/src/contexts/CurrentTeamContext.ts b/frontend2/src/contexts/CurrentTeamContext.ts
index 567f02b28..a8e9db873 100644
--- a/frontend2/src/contexts/CurrentTeamContext.ts
+++ b/frontend2/src/contexts/CurrentTeamContext.ts
@@ -2,6 +2,8 @@ import { createContext, useContext } from "react";
import { type TeamPrivate } from "../utils/types";
export enum TeamStateEnum {
+ // the current team state is still loading
+ LOADING = "loading",
// the current user is not part of a team (or is not logged in)
NO_TEAM = "no_team",
// the current user is part of a team
diff --git a/frontend2/src/contexts/CurrentTeamProvider.tsx b/frontend2/src/contexts/CurrentTeamProvider.tsx
index d8f3172c1..f18a0b4be 100644
--- a/frontend2/src/contexts/CurrentTeamProvider.tsx
+++ b/frontend2/src/contexts/CurrentTeamProvider.tsx
@@ -8,11 +8,13 @@ import { retrieveTeam } from "../utils/api/team";
export const CurrentTeamProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
+ // invariant: team must be undefined when teamState is LOADING or NO_TEAM
+ // team must be defined when teamState is IN_TEAM
const [teamData, setTeamData] = useState<{
team?: TeamPrivate;
teamState: TeamStateEnum;
}>({
- teamState: TeamStateEnum.NO_TEAM,
+ teamState: TeamStateEnum.LOADING,
});
const { authState } = useCurrentUser();
const { episodeId } = useEpisodeId();
diff --git a/frontend2/src/views/MyTeam.tsx b/frontend2/src/views/MyTeam.tsx
index ff3829924..f7431cde9 100644
--- a/frontend2/src/views/MyTeam.tsx
+++ b/frontend2/src/views/MyTeam.tsx
@@ -1,17 +1,28 @@
-import React, { useState } from "react";
+import React, { useMemo, useState } from "react";
import { PageTitle } from "../components/elements/BattlecodeStyle";
import SectionCard from "../components/SectionCard";
import Input from "../components/elements/Input";
import TextArea from "../components/elements/TextArea";
-import { useCurrentTeam } from "../contexts/CurrentTeamContext";
+import { TeamStateEnum, useCurrentTeam } from "../contexts/CurrentTeamContext";
import Button from "../components/elements/Button";
import MemberList from "../components/team/MemberList";
import DescriptiveCheckbox from "../components/elements/DescriptiveCheckbox";
+import JoinTeam from "../components/JoinTeam";
const MyTeam: React.FC = () => {
const { team, teamState } = useCurrentTeam();
const [checked, setChecked] = useState(false);
- const [checked1, setChecked1] = useState(false);
+ const membersList = useMemo(() => {
+ return (
+