diff --git a/packages/component-faraday-ui/src/helpers/utils.js b/packages/component-faraday-ui/src/helpers/utils.js index 6ffe4a6dbdb4752ae70ded671d531cbd2c3c7dde..8b798e34e7b73272c922ab6201019b5b4b221fb9 100644 --- a/packages/component-faraday-ui/src/helpers/utils.js +++ b/packages/component-faraday-ui/src/helpers/utils.js @@ -1,17 +1,7 @@ import { get, chain, find } from 'lodash' export const handleError = fn => e => { - const errorForAuthorWhenHEWasRevoked = - 'Your Handling Editor was changed. A new handling editor will be assigned to your manuscript soon. Sorry for the inconvenience.' - let error = get( - JSON.parse(e.response), - 'error', - 'Oops! Something went wrong!', - ) - if (error === 'No revision has been found.') { - error = errorForAuthorWhenHEWasRevoked - } - fn(error) + fn(get(JSON.parse(e.response), 'error', 'Oops! Something went wrong!')) } export const getReportComments = ({ report, isPublic = false }) => diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js index 3c73c09d83f26b514477722dd2b304dbee51e3c3..296bebafcfc99f9f765f677a90d97d74f630b3e1 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptHeader.js @@ -135,27 +135,22 @@ export default compose( if (pendingInvitation.userId === currentUserId) { return <Text ml={1}>Invited</Text> } - if ( - (get(pendingInvitation, 'userId', false) || - get(heInvitation, 'userId', false)) && - (admin || editorInChief) - ) { + const invitedHeId = + get(pendingInvitation, 'userId', false) || + get(heInvitation, 'userId', false) + + if (invitedHeId && (admin || editorInChief)) { const person = chain(handlingEditors) - .filter( - he => - he.id === - (get(heInvitation, 'userId', false) || - get(pendingInvitation, 'userId', false)), - ) + .filter(he => he.id === invitedHeId) .map(he => ({ ...he, name: `${he.firstName} ${he.lastName}` })) .first() .value() - let invitedPerson = {} + let invitedHe = {} if (get(pendingInvitation, 'userId', false)) { - invitedPerson = pendingInvitation + invitedHe = pendingInvitation } else if (get(heInvitation, 'userId', false)) { - invitedPerson = heInvitation + invitedHe = heInvitation } return ( <PersonInvitation @@ -163,7 +158,7 @@ export default compose( isLatestVersion={isLatestVersion} ml={1} withName - {...invitedPerson} + {...invitedHe} onResend={resendInvitation} onRevoke={revokeInvitation} person={person} diff --git a/packages/component-manuscript-manager/src/routes/fragments/patch.js b/packages/component-manuscript-manager/src/routes/fragments/patch.js index acd037254ddb9ada6417d99980a2a30588799d08..6a3e11ef06411ccd3868b8da6aca8389289f0d6a 100644 --- a/packages/component-manuscript-manager/src/routes/fragments/patch.js +++ b/packages/component-manuscript-manager/src/routes/fragments/patch.js @@ -24,7 +24,8 @@ module.exports = models => async (req, res) => { fragment = await models.Fragment.find(fragmentId) if (!fragment.revision) { return res.status(400).json({ - error: 'No revision has been found.', + error: + 'Your Handling Editor was changed. A new handling editor will be assigned to your manuscript soon. Sorry for the inconvenience.', }) } diff --git a/packages/component-manuscript-manager/src/tests/fragments/patch.test.js b/packages/component-manuscript-manager/src/tests/fragments/patch.test.js index f4e2147a5604bf4f77e0782fdd1f33cb28ec9f58..be867cbe7df7674d91c619d7837a94ed08e808e6 100644 --- a/packages/component-manuscript-manager/src/tests/fragments/patch.test.js +++ b/packages/component-manuscript-manager/src/tests/fragments/patch.test.js @@ -148,7 +148,9 @@ describe('Patch fragments route handler', () => { expect(res.statusCode).toBe(400) const data = JSON.parse(res._getData()) - expect(data.error).toEqual('No revision has been found.') + expect(data.error).toEqual( + 'Your Handling Editor was changed. A new handling editor will be assigned to your manuscript soon. Sorry for the inconvenience.', + ) }) it('should return an error when the user is inactive', async () => { const { inactiveUser } = testFixtures.users