Skip to content
Snippets Groups Projects
Commit c1dc7d29 authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

fix(assignHE): show specific error and remove double invitation

parent 73681cde
No related branches found
No related tags found
2 merge requests!58Sprint #20 - Goal - Reviewers submit report,!53fix(assignHE): show specific error and remove double invitation
import * as validators from './formValidators' import * as validators from './formValidators'
export * from './utils'
export { default as withFilePreview } from './withFilePreview' export { default as withFilePreview } from './withFilePreview'
export * from './withFileDownload' export * from './withFileDownload'
export { default as withNativeFileDrop } from './withNativeFileDrop' export { default as withNativeFileDrop } from './withNativeFileDrop'
......
import { get } from 'lodash'
export const handleError = fn => e => {
fn(get(JSON.parse(e.response), 'error', 'Oops! Something went wrong!'))
}
...@@ -69,7 +69,6 @@ module.exports = models => async (req, res) => { ...@@ -69,7 +69,6 @@ module.exports = models => async (req, res) => {
try { try {
const user = await UserModel.findByEmail(email) const user = await UserModel.findByEmail(email)
await teamHelper.setupTeam({ user, role, objectType: 'collection' })
invitationHelper.userId = user.id invitationHelper.userId = user.id
let invitation = invitationHelper.getInvitation({ let invitation = invitationHelper.getInvitation({
invitations: collection.invitations, invitations: collection.invitations,
...@@ -89,6 +88,7 @@ module.exports = models => async (req, res) => { ...@@ -89,6 +88,7 @@ module.exports = models => async (req, res) => {
} }
invitation.invitedOn = Date.now() invitation.invitedOn = Date.now()
await teamHelper.setupTeam({ user, role, objectType: 'collection' })
await collection.save() await collection.save()
await collectionHelper.addHandlingEditor({ user, invitation }) await collectionHelper.addHandlingEditor({ user, invitation })
......
...@@ -46,7 +46,7 @@ import { ...@@ -46,7 +46,7 @@ import {
canOverrideTechnicalChecks, canOverrideTechnicalChecks,
getInvitationsWithReviewersForFragment, getInvitationsWithReviewersForFragment,
} from 'pubsweet-component-faraday-selectors' } from 'pubsweet-component-faraday-selectors'
import { RemoteOpener } from 'pubsweet-component-faraday-ui' import { RemoteOpener, handleError } from 'pubsweet-component-faraday-ui'
import ManuscriptLayout from './ManuscriptLayout' import ManuscriptLayout from './ManuscriptLayout'
import { parseEicDecision, parseSearchParams, redirectToError } from './utils' import { parseEicDecision, parseSearchParams, redirectToError } from './utils'
...@@ -188,7 +188,7 @@ export default compose( ...@@ -188,7 +188,7 @@ export default compose(
fetchUpdatedCollection() fetchUpdatedCollection()
modalProps.hideModal() modalProps.hideModal()
}) })
.catch(() => modalProps.setModalError('Oops! Something went wrong.')), .catch(handleError(modalProps.setModalError)),
revokeHE: ({ revokeHE: ({
getCollection, getCollection,
revokeHandlingEditor, revokeHandlingEditor,
...@@ -202,7 +202,7 @@ export default compose( ...@@ -202,7 +202,7 @@ export default compose(
getCollection({ id: collectionId }) getCollection({ id: collectionId })
modalProps.hideModal() modalProps.hideModal()
}) })
.catch(() => modalProps.setModalError('Oops! Something went wrong.')), .catch(handleError(modalProps.setModalError)),
createRecommendation: ({ createRecommendation: ({
fragment, fragment,
collection, collection,
...@@ -219,9 +219,7 @@ export default compose( ...@@ -219,9 +219,7 @@ export default compose(
fetchUpdatedCollection() fetchUpdatedCollection()
modalProps.hideModal() modalProps.hideModal()
}) })
.catch(() => { .catch(handleError(modalProps.setModalError))
modalProps.setModalError('Oops! Something went wrong.')
})
}, },
onHEResponse: ({ onHEResponse: ({
history, history,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment