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

fixes issue#93 #548

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions client/src/lib/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ export async function createGroup(apiClient, groupName) {

try {
response = await apiClient.post(`${config.GROUPS_API_URL}`, payload);
return response.data;
} catch (error) {
console.log(error);
if (error && error.message) {
return { message: error.message };
}
// TODO - Handle error
}

return response.data;
}
4 changes: 3 additions & 1 deletion client/src/pages/Search/Groups.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ export default function SearchGroups() {

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

if (newGroup.id) {
if (newGroup && newGroup.id) {
const newOtherGroups = JSON.parse(JSON.stringify(otherGroups));

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

setOtherGroups(newOtherGroups);
alert(`Group with name ${groupName} created successfully`);
} else if (newGroup.message) {
alert(newGroup.message);
} else {
alert("Group creation failed");
}
Expand Down
7 changes: 7 additions & 0 deletions client/src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export default () => {
await loginWithRedirect({
redirect_uri: window.location.origin,
});
} else if (
error.response &&
error.response.status === 409 &&
error.response.data.message
) {
const modError = new Error(error.response.data.message);
return Promise.reject(modError);
}

return Promise.reject(error);
Expand Down