fetching team data

This commit is contained in:
Arjun Patel
2022-01-15 13:02:44 -08:00
parent 39705c0493
commit 724b8c8e38
5 changed files with 115 additions and 7 deletions
+32
View File
@@ -14,11 +14,43 @@ import { Team } from "../../models/team";
import { TeamMemberStatus } from "../../models/teamMember";
import TeamService from "../../services/teamService";
// User has switched back to the tab
const onFocus = () => {
console.log("Tab is in focus");
};
// User has switched away from the tab (AKA tab is hidden)
const onBlur = () => {
console.log("Tab is blurred");
};
const onClose = (ev) => {
// change user status to offline
ev.preventDefault();
return (ev.returnValue = "are you sure?");
};
function TeamDashboard() {
const { currUser } = useAuth();
const router = useRouter();
const teamDashboardContext = useTeamDashboardContext();
useEffect(() => {
window.addEventListener("focus", onFocus);
window.addEventListener("blur", onBlur);
// Calls onFocus when the window first loads
onFocus();
// Specify how to clean up after this effect:
window.addEventListener("beforeunload", onClose);
return () => {
window.removeEventListener("focus", onFocus);
window.removeEventListener("blur", onBlur);
window.removeEventListener("beforeunload", onClose);
};
}, []);
console.log(teamDashboardContext);
return (
+4 -1
View File
@@ -112,7 +112,10 @@ export default function CreateTeam() {
<span className="flex flex-row justify-end space-x-2">
<button
onClick={() => router.push("/teams")}
onClick={(e) => {
e.preventDefault();
router.push("/teams");
}}
className="bg-gray-100 py-2 px-5 rounded text-gray-400"
>
Cancel