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

Commit 260c38a

Browse files
committed
fixes issue#93
1 parent 9547065 commit 260c38a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

client/src/lib/groups.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,11 @@ export async function createGroup(apiClient, groupName) {
188188

189189
try {
190190
response = await apiClient.post(`${config.GROUPS_API_URL}`, payload);
191+
return response.data;
191192
} catch (error) {
192-
console.log(error);
193+
if (error && error.message) {
194+
return { message: error.message };
195+
}
193196
// TODO - Handle error
194197
}
195-
196-
return response.data;
197198
}

client/src/pages/Search/Groups.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,15 @@ export default function SearchGroups() {
108108

109109
const newGroup = await groupLib.createGroup(apiClient, groupName);
110110

111-
if (newGroup.id) {
111+
if (newGroup && newGroup.id) {
112112
const newOtherGroups = JSON.parse(JSON.stringify(otherGroups));
113113

114114
newOtherGroups.push({ ...newGroup, count: 0 });
115115

116116
setOtherGroups(newOtherGroups);
117117
alert(`Group with name ${groupName} created successfully`);
118+
} else if (newGroup.message) {
119+
alert(newGroup.message);
118120
} else {
119121
alert("Group creation failed");
120122
}

client/src/services/api.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export default () => {
3333
await loginWithRedirect({
3434
redirect_uri: window.location.origin,
3535
});
36+
} else if (
37+
error.response &&
38+
error.response.status === 409 &&
39+
error.response.data.message
40+
) {
41+
const modError = new Error(error.response.data.message);
42+
return Promise.reject(modError);
3643
}
3744

3845
return Promise.reject(error);

0 commit comments

Comments
 (0)