Skip to content

Commit 564720b

Browse files
committed
Fix issue with assigning members
https://topcoder.atlassian.net/browse/PROD-4315
1 parent 48318ac commit 564720b

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/actions/challenges.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -677,27 +677,33 @@ export function createResource (challengeId, roleId, memberHandle, email, userId
677677
type: CREATE_CHALLENGE_RESOURCE_PENDING
678678
})
679679

680+
let newResource
680681
try {
681-
const newResource = await createResourceAPI(resource)
682-
let userEmail = email
683-
if (!userEmail) {
682+
newResource = await createResourceAPI(resource)
683+
} catch (error) {
684+
dispatch({
685+
type: CREATE_CHALLENGE_RESOURCE_FAILURE
686+
})
687+
return
688+
}
689+
690+
let userEmail = email
691+
if (!userEmail && userId) {
692+
try {
684693
const memberInfos = await searchProfilesByUserIds([userId])
685694
if (memberInfos.length > 0) {
686695
userEmail = memberInfos[0].email
687696
}
697+
} catch (error) {
688698
}
689-
dispatch({
690-
type: CREATE_CHALLENGE_RESOURCE_SUCCESS,
691-
payload: {
692-
...newResource,
693-
email: userEmail
694-
}
695-
})
696-
} catch (error) {
697-
dispatch({
698-
type: CREATE_CHALLENGE_RESOURCE_FAILURE
699-
})
700699
}
700+
dispatch({
701+
type: CREATE_CHALLENGE_RESOURCE_SUCCESS,
702+
payload: {
703+
...newResource,
704+
email: userEmail
705+
}
706+
})
701707
}
702708
}
703709

0 commit comments

Comments
 (0)