@@ -61,24 +61,23 @@ export async function createUserGroup(
61
61
* Updates the name of an existing user group.
62
62
* @param id - The unique identifier of the user group to update.
63
63
* @param newName - The new name to assign to the user group.
64
- * @param userIds - The new name to assign to the user group.
65
- // * @param queryIds - The new name to assign to the user group.
66
64
* @returns The updated user group or an error if the update fails.
67
65
*/
68
66
export async function updateUserGroup (
69
67
id : string ,
70
68
newName : string ,
71
- userIds ?: string [ ] ,
72
69
) : Promise < UserGroup | string > {
73
70
if ( ! ( await superAdminAccessCheck ( ) ) ) {
74
71
throw new Error ( "Unauthorized" ) ;
75
72
}
76
- console . log ( id , newName ) ;
73
+
77
74
try {
78
75
// Check if the new name already exists
79
76
const existingGroups = await getAllUserGroups ( ) ;
80
77
const groupExists =
81
- existingGroups . items ?. some ( ( group ) => group . name === newName ) ?? false ;
78
+ existingGroups . items ?. some ( ( group ) => {
79
+ return group . name === newName ;
80
+ } ) ?? false ;
82
81
83
82
if ( groupExists ) {
84
83
console . warn ( `Group with name '${ newName } ' already exists.` ) ;
@@ -91,11 +90,11 @@ export async function updateUserGroup(
91
90
WHERE id = $2
92
91
RETURNING id, name;
93
92
` ;
94
- const escapedValues =
95
- userIds && userIds . map ( ( _ , i ) => `$${ i + 1 } ` ) . join ( ) + ")" ;
96
- const queryString = updateUserGroupMembersQuery + escapedValues ;
97
93
98
- const result = await dbClient . query ( queryString , [ newName , id , userIds ] ) ;
94
+ const result = await dbClient . query ( updateUserGroupMembersQuery , [
95
+ newName ,
96
+ id ,
97
+ ] ) ;
99
98
100
99
if ( result . rows . length === 0 ) {
101
100
throw new Error ( `User group with ID '${ id } ' not found.` ) ;
0 commit comments