fixing race conditions and such

This commit is contained in:
Arjun Patel
2022-01-14 21:36:11 -08:00
parent f2ca1fe5e1
commit 0299543f02
2 changed files with 22 additions and 5 deletions
+14 -3
View File
@@ -14,7 +14,12 @@ import {
import { toast } from "react-hot-toast";
import { Team, TeamStatus } from "../../../models/team";
import { FaMoneyBillWave, FaTrash, FaPaperPlane } from "react-icons/fa";
import {
FaMoneyBillWave,
FaTrash,
FaPaperPlane,
FaArrowLeft,
} from "react-icons/fa";
import TeamService from "../../../services/teamService";
import Router from "next/router";
import Moment from "react-moment";
@@ -201,7 +206,13 @@ function TeamAdmin() {
className="flex flex-col space-y-5"
>
{/* header */}
<div className="text-lg">🙌Manage Team</div>
<div className="text-lg flex flex-row items-center space-x-2">
<FaArrowLeft
className="hover:cursor-pointer"
onClick={() => router.push("/teams/" + teamid)}
/>{" "}
<span>Manage Team</span>
</div>
{error && <span className="text-red-300 text-md">{error}</span>}
@@ -235,7 +246,7 @@ function TeamAdmin() {
<span className="flex flex-row justify-end space-x-2">
<button
onClick={() => router.push("/teams")}
onClick={() => router.push("/teams/" + team.id)}
className="bg-gray-100 py-2 px-5 rounded text-gray-400"
>
Cancel
+8 -2
View File
@@ -59,16 +59,22 @@ function RouteHandler() {
);
console.log(returnedTeamMembers);
// if the user is deleted from a team, don't let them go there
var teamId = "";
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;
teamId = returnedTeamMembers[0].teamId;
}
});
if (teamId) {
router.push("/teams/" + teamId);
return;
}
setLoading(false);
} catch (error) {
console.log(error);