From add72ef0bc5256a6bd60a0dc768b473fd9ee19c5 Mon Sep 17 00:00:00 2001
From: Amy <45153739+amtang325@users.noreply.github.com>
Date: Wed, 4 Sep 2024 21:59:42 -0400
Subject: [PATCH 1/3] made get invites request execute conditionally based on
user registration
---
src/components/outline/Display.tsx | 56 ++++--------------------------
1 file changed, 6 insertions(+), 50 deletions(-)
diff --git a/src/components/outline/Display.tsx b/src/components/outline/Display.tsx
index 52363c9..69cc24c 100644
--- a/src/components/outline/Display.tsx
+++ b/src/components/outline/Display.tsx
@@ -67,62 +67,16 @@ const Display: React.FC = () => {
method: "GET",
});
- const [{ data: inviteData, loading: inviteLoading }] = useAxios({
+ const [{ data: inviteData, loading: inviteLoading }, getInvites] = useAxios({
url: apiUrl(
Service.HEXATHONS,
`/teams/get-invites?hexathon=${process.env.REACT_APP_HEXATHON_ID}`
),
method: "GET",
+ }, {
+ manual: true,
});
- // const teamRequests = [
- // {
- // members: [],
- // public: false,
- // hexathon: "647fee51768e521dc8ef88e0",
- // name: "Team A",
- // sentInvites: [
- // {
- // member: "65c7e7afe487b453d90d579c",
- // message: "You are invited to join our team!",
- // id: "65c80369a5a1e7bac212161d"
- // },
- // {
- // member: "65c7e716e487b453d90d5799",
- // message: "You are invited to join our team!",
- // id: "65c80369a5a1e7bac212161e"
- // }
- // ],
- // memberRequests: [],
- // id: "65c7e559e487b453d90d5794"
- // },
- // {
- // members: [],
- // public: false,
- // hexathon: "647fee51768e521dc8ef88e0",
- // name: "Team C",
- // sentInvites: [
- // {
- // member: "65c7e753e487b453d90d579a",
- // message: "Hi there",
- // id: "65c80369a5a1e7bac212161f"
- // },
- // {
- // member: "65c7e786e487b453d90d579b",
- // message: "Hello there",
- // id: "65c80369a5a1e7bac2121620"
- // },
- // {
- // member: "65c7e7afe487b453d90d579c",
- // message: "You are invited to join our team!",
- // id: "65c80369a5a1e7bac2121621"
- // }
- // ],
- // memberRequests: [],
- // id: "65c7e5f7e487b453d90d5796"
- // }
- // ]
-
useEffect(() => {
setCommitmentSelectValue(
commitmentOptions.filter(
@@ -137,9 +91,11 @@ const Display: React.FC = () => {
);
}, [searchParams, commitmentOptions, skillOptions, schoolOptions]);
- if (loading || userLoading || inviteLoading) return ;
+ if (loading || userLoading) return ;
// Display not registered screen if an unregistered non-member tries to access the portal
if (!data && !userData.roles.member) return ;
+ if (data) getInvites();
+ if (inviteLoading) return ;
const onSearchTextChange = (event: any) => {
setSearchText(event.target.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
From 96228c75f261febf21b5c5ea3365a3163fdc5092 Mon Sep 17 00:00:00 2001
From: Amy <45153739+amtang325@users.noreply.github.com>
Date: Wed, 4 Sep 2024 22:00:15 -0400
Subject: [PATCH 2/3] added comment
---
src/components/outline/Display.tsx | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/components/outline/Display.tsx b/src/components/outline/Display.tsx
index 69cc24c..b648538 100644
--- a/src/components/outline/Display.tsx
+++ b/src/components/outline/Display.tsx
@@ -94,6 +94,8 @@ const Display: React.FC = () => {
if (loading || userLoading) return ;
// Display not registered screen if an unregistered non-member tries to access the portal
if (!data && !userData.roles.member) return ;
+
+ // Only gets invites for a user if they are registered
if (data) getInvites();
if (inviteLoading) return ;
From e5c3a81a744167302f06f231f898a27a3fab0284 Mon Sep 17 00:00:00 2001
From: Amy <45153739+amtang325@users.noreply.github.com>
Date: Sun, 22 Sep 2024 14:49:51 -0400
Subject: [PATCH 3/3] wrapped getInvites in useEffect
---
src/components/outline/Display.tsx | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/components/outline/Display.tsx b/src/components/outline/Display.tsx
index b648538..f868ea7 100644
--- a/src/components/outline/Display.tsx
+++ b/src/components/outline/Display.tsx
@@ -91,14 +91,16 @@ const Display: React.FC = () => {
);
}, [searchParams, commitmentOptions, skillOptions, schoolOptions]);
- if (loading || userLoading) return ;
+ useEffect(() => {
+ if (data) {
+ getInvites();
+ }
+ }, [data, getInvites]);
+
+ if (loading || userLoading || inviteLoading) return ;
// Display not registered screen if an unregistered non-member tries to access the portal
if (!data && !userData.roles.member) return ;
- // Only gets invites for a user if they are registered
- if (data) getInvites();
- if (inviteLoading) return ;
-
const onSearchTextChange = (event: any) => {
setSearchText(event.target.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
displayMode === DisplayType.USERS ? setUsersOffset(0) : setTeamsOffset(0);