Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 8ff883f

Browse files
committed
Merge branch 'develop' into issue-17
2 parents cc4b75c + 9efd0bd commit 8ff883f

File tree

16 files changed

+137
-105
lines changed

16 files changed

+137
-105
lines changed

client/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 74 deletions
Loading

client/src/components/AddToGroupModal/index.jsx

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useEffect } from "react";
22
import PT from "prop-types";
33

44
import Button from "../Button";
@@ -10,6 +10,7 @@ import { useAuth0 } from "../../react-auth0-spa";
1010
import * as groupLib from "../../lib/groups";
1111

1212
import style from "./style.module.scss";
13+
import Axios from "axios";
1314

1415
export default function AddToGroupModal({ onCancel, updateUser, user }) {
1516
const apiClient = api();
@@ -21,34 +22,50 @@ export default function AddToGroupModal({ onCancel, updateUser, user }) {
2122
const [updatingGroups, setUpdatingGroups] = React.useState(false);
2223
const [userGroups, setUserGroups] = React.useState(user.groups);
2324
const [creatingGroup, setCreatingGroup] = React.useState(false);
25+
const cancelTokenSource = Axios.CancelToken.source();
26+
27+
/**
28+
* Component unmount trigger
29+
*/
30+
useEffect(() => {
31+
return () => {
32+
cancelTokenSource.cancel();
33+
};
34+
});
2435

2536
React.useEffect(() => {
2637
if (isLoading || !isAuthenticated) {
2738
return;
2839
}
2940

3041
(async () => {
31-
const groups = await groupLib.getGroups(apiClient, auth0User.nickname);
32-
33-
groups.myGroups.forEach((g, i, a) => {
34-
userGroups.forEach((ug, iug, aug) => {
35-
if (g.id === ug.id && !ug.isDeleted) {
36-
a[i] = { ...g, isSelected: true };
37-
}
42+
const groups = await groupLib.getGroups(
43+
apiClient,
44+
auth0User.nickname,
45+
cancelTokenSource.token
46+
);
47+
48+
if (groups) {
49+
groups.myGroups.forEach((g, i, a) => {
50+
userGroups.forEach((ug, iug, aug) => {
51+
if (g.id === ug.id && !ug.isDeleted) {
52+
a[i] = { ...g, isSelected: true };
53+
}
54+
});
3855
});
39-
});
4056

41-
groups.otherGroups.forEach((g, i, a) => {
42-
userGroups.forEach((ug, iug, aug) => {
43-
if (g.id === ug.id && !ug.isDeleted) {
44-
a[i] = { ...g, isSelected: true };
45-
}
57+
groups.otherGroups.forEach((g, i, a) => {
58+
userGroups.forEach((ug, iug, aug) => {
59+
if (g.id === ug.id && !ug.isDeleted) {
60+
a[i] = { ...g, isSelected: true };
61+
}
62+
});
4663
});
47-
});
4864

49-
setMyGroups(groups.myGroups);
50-
setOtherGroups(groups.otherGroups);
51-
setIsLoadingGroups(false);
65+
setMyGroups(groups.myGroups);
66+
setOtherGroups(groups.otherGroups);
67+
setIsLoadingGroups(false);
68+
}
5269
})();
5370
// eslint-disable-next-line react-hooks/exhaustive-deps
5471
}, [isLoading, isAuthenticated, auth0User]);
@@ -195,6 +212,10 @@ export default function AddToGroupModal({ onCancel, updateUser, user }) {
195212
))}
196213
</div>
197214
</div>
215+
{otherGroups.filter((g) =>
216+
g.name.toLowerCase().includes(filter.toLowerCase())
217+
).length === 0 &&
218+
!loadingGroups && <div className={style.message}>No results found</div>}
198219
<div className={style.buttons}>
199220
<Button onClick={onCancel} disabled={updatingGroups || creatingGroup}>
200221
Cancel

client/src/components/AddToGroupModal/style.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,8 @@
8686
left: 10px;
8787
top: 10px;
8888
}
89+
90+
.message {
91+
color: $textColor2;
92+
font: 400 12pt/1.25 Inter;
93+
}

client/src/components/FiltersSideMenu/filters.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export default function SearchTabFilters({ locations, achievements }) {
3131
*/
3232
useEffect(() => {
3333
return () => {
34-
console.log("filters unmounted...");
3534
handleReset();
3635
};
3736
// eslint-disable-next-line react-hooks/exhaustive-deps

client/src/components/GroupsSideMenu/filters.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export default function GroupTabFilters({
9090
)}
9191
onItemClicked={handleGroupItemClicked}
9292
selectedItemId={selectedGroup === "My Groups" ? selectedItemId : -1}
93+
loadingGroups={loadingGroups}
9394
/>
9495
<GroupsSection
9596
title={loadingGroups ? "Other Groups (Loading...)" : "Other Groups"}
@@ -100,6 +101,7 @@ export default function GroupTabFilters({
100101
selectedItemId={
101102
selectedGroup === "Other Groups" ? selectedItemId : -1
102103
}
104+
loadingGroups={loadingGroups}
103105
/>
104106
</div>
105107
</div>
@@ -116,7 +118,7 @@ GroupTabFilters.propTypes = {
116118
onCreateNewGroup: PT.func,
117119
};
118120

119-
function GroupsSection({ title, items, onItemClicked, selectedItemId }) {
121+
function GroupsSection({ title, items, onItemClicked, selectedItemId, loadingGroups }) {
120122
return (
121123
<>
122124
<div className={styles.sectionTitle}>{title}</div>
@@ -135,6 +137,7 @@ function GroupsSection({ title, items, onItemClicked, selectedItemId }) {
135137
);
136138
})}
137139
</div>
140+
{items.length === 0 && !loadingGroups && <div className={styles.message}>No results found</div>}
138141
</>
139142
);
140143
}
@@ -144,6 +147,7 @@ GroupsSection.propTypes = {
144147
items: PT.array.isRequired,
145148
onItemClicked: PT.func,
146149
selectedIndex: PT.number,
150+
loadingGroups: PT.bool,
147151
};
148152

149153
function SectionRow({ title, badge, selected = false, action }) {

client/src/components/GroupsSideMenu/filters.module.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* importing colors */
22
@value colors: "../../styles/colors.module.css";
3-
@value gray1, gray2, gray1_025, white, blue from colors;
3+
@value gray1, gray2, gray1_025, lightGray2, white, blue from colors;
44

55
/* Group Tab filters (lett col) styles */
66
.groupTabFilters {
@@ -140,3 +140,8 @@
140140
.sectionItemChevron {
141141
margin-left: 13px;
142142
}
143+
144+
.message {
145+
color: lightGray2;
146+
font: 400 12pt/1.25 Inter;
147+
}

client/src/components/Header/style.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
.logo {
44
display: flex;
55
align-items: center;
6+
7+
img {
8+
width: 80px;
9+
height: auto;
10+
}
611
}
712

813
.accountMenu {

client/src/components/Input/style.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
font: 400 12pt/1.25 Inter;
2020
height: 36px;
2121
outline: none;
22+
23+
&::-ms-clear {
24+
display: none;
25+
}
2226
}
2327

2428
.label {

client/src/components/Upload/Initial/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ export default function Initial({ onError, onUpload, templateId }) {
3232
const { data } = await apiClient.get(url);
3333
window.location = data.url;
3434
} catch (error) {
35-
if (onError) onError(error.toJSON());
35+
if (onError) onError(error);
3636
}
3737
};
3838

3939
const upload = (files) => {
4040
const allowedMineTypes = [
4141
"application/vnd.ms-excel",
4242
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
43+
"text/csv",
4344
];
4445
if (files && files[0] && allowedMineTypes.indexOf(files[0].type) !== -1)
4546
onUpload(files[0]);

client/src/lib/groups.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
import config from "../config";
22
import * as OrgService from "../services/user-org";
3+
import Axios from "axios";
34

45
/**
56
* Returns the groups for the logged in user
67
* @param {Object} apiClient The api client
78
* @param {Object} handle The logged in user's handle
89
*/
9-
export async function getGroups(apiClient, handle) {
10+
export async function getGroups(apiClient, handle, cancelToken) {
1011
let myGroups = [];
1112
let otherGroups = [];
1213
let response;
1314

1415
// First, we get the userId of the current user
1516
try {
16-
response = await apiClient.get(`${config.API_URL}/users?handle=${handle}`);
17+
response = await apiClient.get(`${config.API_URL}/users?handle=${handle}`, {
18+
cancelToken,
19+
});
1720
} catch (error) {
21+
if (Axios.isCancel(error)) {
22+
return undefined;
23+
}
1824
console.log(error);
1925
// TODO - handle error
2026
return { myGroups, otherGroups };
@@ -33,9 +39,13 @@ export async function getGroups(apiClient, handle) {
3339
// Now, get my groups first
3440
try {
3541
response = await apiClient.get(
36-
`${config.GROUPS_API_URL}?universalUID=${userId}&membershipType=user`
42+
`${config.GROUPS_API_URL}?universalUID=${userId}&membershipType=user`,
43+
{ cancelToken }
3744
);
3845
} catch (error) {
46+
if (Axios.isCancel(error)) {
47+
return undefined;
48+
}
3949
console.log(error);
4050
// TODO - handle error
4151
return { myGroups, otherGroups };
@@ -56,9 +66,13 @@ export async function getGroups(apiClient, handle) {
5666
// Fetch all groups in the org
5767
try {
5868
response = await apiClient.get(
59-
`${config.GROUPS_API_URL}?organizationId=${organizationId}`
69+
`${config.GROUPS_API_URL}?organizationId=${organizationId}`,
70+
{ cancelToken }
6071
);
6172
} catch (error) {
73+
if (Axios.isCancel(error)) {
74+
return undefined;
75+
}
6276
console.log(error);
6377
// TODO - handle error
6478
return { myGroups, otherGroups };
@@ -86,9 +100,13 @@ export async function getGroups(apiClient, handle) {
86100
// Now, get member counts
87101
try {
88102
response = await apiClient.get(
89-
`${config.GROUPS_API_URL}/memberGroups/groupMembersCount?universalUID=${userId}`
103+
`${config.GROUPS_API_URL}/memberGroups/groupMembersCount?universalUID=${userId}`,
104+
{ cancelToken }
90105
);
91106
} catch (error) {
107+
if (Axios.isCancel(error)) {
108+
return undefined;
109+
}
92110
console.log(error);
93111
// TODO - handle error
94112
return { myGroups, otherGroups };
@@ -105,9 +123,13 @@ export async function getGroups(apiClient, handle) {
105123
// Fetch all groups in the org
106124
try {
107125
response = await apiClient.get(
108-
`${config.GROUPS_API_URL}/memberGroups/groupMembersCount?organizationId=${organizationId}`
126+
`${config.GROUPS_API_URL}/memberGroups/groupMembersCount?organizationId=${organizationId}`,
127+
{ cancelToken }
109128
);
110129
} catch (error) {
130+
if (Axios.isCancel(error)) {
131+
return undefined;
132+
}
111133
console.log(error);
112134
// TODO - handle error
113135
return { myGroups, otherGroups };

0 commit comments

Comments
 (0)