diff --git a/src/app/admin/components/UsersTable.tsx b/src/app/admin/components/UsersTable.tsx index 23d1c2a6..5ad38e0f 100644 --- a/src/app/admin/components/UsersTable.tsx +++ b/src/app/admin/components/UsersTable.tsx @@ -19,11 +19,21 @@ export default function UsersTable({ users }: { users: User[] }) { const deleteUser = async (id: Schema["User"]["deleteType"]) => client.models.User.delete(id); const updateUser = async (updatedData: Schema["User"]["updateType"]) => { + if (updatedData.role) { + const roleUpdateResult = await client.mutations.AddUserToGroup({ + userId: updatedData.id, + groupName: updatedData.role, + }); + + if (roleUpdateResult.errors) { + throw new Error("Failed to update user role in Cognito"); + } + } + return client.models.User.update({ id: updatedData.id, firstName: updatedData.firstName, lastName: updatedData.lastName, - role: updatedData.role, teamId: updatedData.teamId, }); };