diff --git a/frontend2/src/components/JoinTeam.tsx b/frontend2/src/components/JoinTeam.tsx new file mode 100644 index 000000000..843bd66e4 --- /dev/null +++ b/frontend2/src/components/JoinTeam.tsx @@ -0,0 +1,7 @@ +import React from "react"; + +const JoinTeam: React.FC = () => { + return
you have no team! this page is tbd
; +}; + +export default JoinTeam; diff --git a/frontend2/src/components/elements/DescriptiveCheckbox.tsx b/frontend2/src/components/elements/DescriptiveCheckbox.tsx index d929b1b78..f9045f352 100644 --- a/frontend2/src/components/elements/DescriptiveCheckbox.tsx +++ b/frontend2/src/components/elements/DescriptiveCheckbox.tsx @@ -20,7 +20,7 @@ const DescriptiveCheckbox: React.FC = ({ checked={checked} onChange={onChange} className={`flex w-full - flex-row items-center justify-between rounded-lg px-6 py-4 shadow ring-2 ring-inset + flex-row items-center justify-between gap-3 rounded-lg px-6 py-4 shadow ring-2 ring-inset ring-cyan-600/20 transition-all ui-checked:bg-cyan-900/80 ui-checked:ring-0`} >
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 ( +
+ {team !== undefined && } +
+ ); + }, [team]); + if (teamState !== TeamStateEnum.IN_TEAM || team === undefined) { + return ; + } return (
Team Settings @@ -22,17 +33,17 @@ const MyTeam: React.FC = () => {
- {team?.name} + {team.name}