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

Commit 3cff9ad

Browse files
#34 - Trim group name before creation and #60 - Prompt to enter group name
1 parent 8d0f119 commit 3cff9ad

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

client/src/components/AddToGroupModal/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ export default function AddToGroupModal({ onCancel, updateUser, user }) {
101101
* Creates a new group
102102
*/
103103
const createGroup = async () => {
104-
if (filter.length === 0) {
104+
const groupName = filter.trim();
105+
if (groupName.length === 0) {
105106
alert("Enter a group name");
106107
return;
107108
}
108109

109110
setCreatingGroup(true);
110111

111-
const newGroup = await groupLib.createGroup(apiClient, filter);
112+
const newGroup = await groupLib.createGroup(apiClient, groupName);
112113

113114
if (newGroup.id) {
114115
const newOtherGroups = JSON.parse(JSON.stringify(otherGroups));
@@ -117,7 +118,7 @@ export default function AddToGroupModal({ onCancel, updateUser, user }) {
117118

118119
setOtherGroups(newOtherGroups);
119120

120-
alert(`Group with name ${filter} created successfully`);
121+
alert(`Group with name ${groupName} created successfully`);
121122

122123
setFilter("");
123124
} else {

client/src/components/GroupsSideMenu/filters.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ export default function GroupTabFilters({
4747
};
4848

4949
const createGroup = () => {
50-
if (searchText.length === 0) {
50+
const groupName = searchText.trim();
51+
if (groupName.length === 0) {
52+
alert("Enter a group name");
5153
return;
5254
}
5355

54-
onCreateNewGroup(searchText);
56+
onCreateNewGroup(groupName);
5557
};
5658

5759
return (

0 commit comments

Comments
 (0)