fixing race conditions and such
This commit is contained in:
@@ -14,7 +14,12 @@ import {
|
|||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Team, TeamStatus } from "../../../models/team";
|
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 TeamService from "../../../services/teamService";
|
||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
import Moment from "react-moment";
|
import Moment from "react-moment";
|
||||||
@@ -201,7 +206,13 @@ function TeamAdmin() {
|
|||||||
className="flex flex-col space-y-5"
|
className="flex flex-col space-y-5"
|
||||||
>
|
>
|
||||||
{/* header */}
|
{/* 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>}
|
{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">
|
<span className="flex flex-row justify-end space-x-2">
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push("/teams")}
|
onClick={() => router.push("/teams/" + team.id)}
|
||||||
className="bg-gray-100 py-2 px-5 rounded text-gray-400"
|
className="bg-gray-100 py-2 px-5 rounded text-gray-400"
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
|
|||||||
@@ -59,16 +59,22 @@ function RouteHandler() {
|
|||||||
);
|
);
|
||||||
console.log(returnedTeamMembers);
|
console.log(returnedTeamMembers);
|
||||||
// if the user is deleted from a team, don't let them go there
|
// if the user is deleted from a team, don't let them go there
|
||||||
|
var teamId = "";
|
||||||
returnedTeamMembers.map((tm) => {
|
returnedTeamMembers.map((tm) => {
|
||||||
if (tm.status != TeamMemberStatus.deleted) {
|
if (tm.status != TeamMemberStatus.deleted) {
|
||||||
console.log(
|
console.log(
|
||||||
"in a team! going to the team dashboard of the first one!"
|
"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);
|
setLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user