Skip to content

fix(PM-1077): handled errors for certain use cases #1643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
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: 5 additions & 2 deletions src/components/Users/user-add.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ const UserAddModalContent = ({ projectId, addNewProjectMember, onMemberInvited,

try {
if (userPermissionToAdd === PROJECT_ROLES.COPILOT) {
const { success: invitations = [], failed } = await inviteUserToProject(projectId, {
const { success: invitations = [], failed, ...rest } = await inviteUserToProject(projectId, {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable rest is being destructured from the response of inviteUserToProject, but it's not clear what properties it contains. Ensure that rest.message is a valid property and handle cases where it might not exist.

handles: [userToAdd.handle],
role: userPermissionToAdd
})
if (failed) {
const error = get(failed, '0.message', 'Unable to invite user')
const error = get(failed, '0.message', 'User cannot be invited')
setAddUserError(error)
setIsAdding(false)
} else if (rest.message) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition else if (rest.message) assumes that rest.message is an error message. Consider checking if rest.message is indeed an error or if it should be handled differently.

setAddUserError(rest.message)
setIsAdding(false)
} else {
onMemberInvited(invitations[0] || {})
onClose()
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Users extends Component {
projectMembers,
invitedMembers: invitedMembers.map(m => ({
...m,
email: m.email || invitedUsers[m.userId].email
email: m.email || invitedUsers[m.userId].handle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name email is now being used to store a handle. Consider renaming the variable to handle for clarity and to avoid confusion, as it no longer represents an email address.

}))
})
const { loggedInUser } = this.props
Expand Down