diff --git a/components/Dashboard/Header.tsx b/components/Dashboard/Header.tsx index a6c37cf..e38ccda 100644 --- a/components/Dashboard/Header.tsx +++ b/components/Dashboard/Header.tsx @@ -10,6 +10,8 @@ import { FaCalendarDay, FaClock, FaPeopleCarry, + FaAngleDown, + FaCheck, } from "react-icons/fa"; import { useTeamDashboardContext } from "../../contexts/teamDashboardContext"; import router from "next/router"; @@ -35,8 +37,6 @@ export default function Header() { const { teamid } = router.query; const [usersTeams, setUserTeams] = useState(null); - console.log("rendering"); - console.log(usersTeams); useEffect(() => { (async function () { @@ -44,7 +44,7 @@ export default function Header() { // get all the teams that this user is part of const newTeams: Team[] = await teamService.getActiveOrInvitedTeamsbyUser(currUser.uid); - console.log(newTeams); + setUserTeams(newTeams); } catch (error) { console.log("problem getting teams of this user"); @@ -75,45 +75,66 @@ export default function Header() { toast.error("You are not a team admin!"); } + const TeamsMenu = ( + + {/* all current teams that this person is a part of */} + {usersTeams && + usersTeams.map((uteam, i) => { + return ( + : <>} + > + + + ); + })} + + + + }> + + + + ); const UserMenu = ( - + - + - - {/* all current teams that this person is a part of */} - {usersTeams && - usersTeams.map((team, i) => { - return ( - - - - ); - })} + - }> - - - + + + + + - + ); @@ -145,7 +166,6 @@ export default function Header() { return (
{/* welcome message */} - {usersTeams && usersTeams.length} 👋Hey {user.firstName}, {periodOfDay}! @@ -153,17 +173,12 @@ export default function Header() { {/* Date and time */} - - - {team.name} - - - + @@ -179,6 +194,17 @@ export default function Header() { + {/* teams menu */} + + + + + {/* avatar */} diff --git a/services/teamService.tsx b/services/teamService.tsx index aca0e73..1b1ed2a 100644 --- a/services/teamService.tsx +++ b/services/teamService.tsx @@ -254,13 +254,14 @@ export default class TeamService implements IService { const userTeamMembers = await this.getTeamMembersByUserId(userId); // traverse through and get the teams for each - var teams: Team[] = []; - userTeamMembers.map(async (tm) => { - if (tm.status != TeamMemberStatus.deleted) { - let team = await this.getTeam(tm.teamId); - teams.push(team); - } - }); + const teams = await Promise.all( + userTeamMembers.map(async (tm) => { + if (tm.status != TeamMemberStatus.deleted) { + let team = await this.getTeam(tm.teamId); + return team; + } + }) + ); return teams; }