adding check to make sure someone is active in the team

This commit is contained in:
Arjun Patel
2022-01-14 20:27:36 -08:00
parent 72faf33dd6
commit e2388359e9
+11 -7
View File
@@ -11,6 +11,7 @@ import { FaPeopleCarry, FaArrowRight, FaBullhorn } from "react-icons/fa";
import BackgroundLayout from "../../components/Layouts/BackgroundLayout";
import TeamService from "../../services/teamService";
import Loading from "../../components/Loading";
import { TeamMemberStatus } from "../../models/teamMember";
/**
* figure out where to take the user based on everything
@@ -58,13 +59,16 @@ function RouteHandler() {
const returnedTeamMembers = await teamService.getTeamMembersByUserId(
currUser.uid
);
if (returnedTeamMembers.length > 0) {
console.log(
"in a team! going to the team dashboard of the first one!"
);
router.push("/teams/" + returnedTeamMembers[0].teamId);
return;
}
// if the user is deleted from a team, don't let them go there
returnedTeamMembers.map((tm) => {
if (tm.status != TeamMemberStatus.deleted) {
console.log(
"in a team! going to the team dashboard of the first one!"
);
router.push("/teams/" + returnedTeamMembers[0].teamId);
return;
}
});
} catch (error) {
console.log(error);
router.push("/teams/login");