diff --git a/packages/component-invite/src/routes/postHandleInvitation.js b/packages/component-invite/src/routes/postHandleInvitation.js index 893908b6642ff41fa55fbabd0f837d91535a62f8..5be9650861cc50aed18fffd6ed959da624936792 100644 --- a/packages/component-invite/src/routes/postHandleInvitation.js +++ b/packages/component-invite/src/routes/postHandleInvitation.js @@ -12,7 +12,7 @@ module.exports = models => async (req, res) => { return } - const user = await models.User.find(req.user) + let user = await models.User.find(req.user) if (!user.invitations) { res.status(400).json({ error: 'The user has no invitation' }) logger.error('The request user does not have any invitation') @@ -22,12 +22,12 @@ module.exports = models => async (req, res) => { try { const collection = await models.Collection.find(collectionId) - const matchingInvitation = user.invitations.find( + const matchingInvitations = user.invitations.filter( invitation => invitation.collectionId === collectionId && invitation.type === type, ) - if (matchingInvitation === undefined) { + if (matchingInvitations.length === 0) { res.status(400).json({ error: `Request data does not match any user invitation`, }) @@ -37,10 +37,10 @@ module.exports = models => async (req, res) => { return } + const matchingInvitation = matchingInvitations[0] matchingInvitation.hasAnswer = true if (accept === true) { matchingInvitation.isAccepted = true - await user.save() try { const users = await models.User.all() @@ -57,14 +57,19 @@ module.exports = models => async (req, res) => { return res.status(500).json({ error: 'Mail could not be sent.' }) } } else { + matchingInvitation.isAccepted = false await teamHelper.removeTeamMember( matchingInvitation.teamId, user.id, models.Team, ) + const { reason } = req.body + if (reason !== undefined) { + matchingInvitation.reason = reason + } } - - res.status(204).json() + user = await user.save() + res.status(200).json(user) return } catch (e) { const notFoundError = await helpers.handleNotFoundError(e, 'collection') diff --git a/packages/components-faraday/src/components/Admin/AdminUsers.js b/packages/components-faraday/src/components/Admin/AdminUsers.js index 4185c022c7a6c704fdacb35f20039c4d29690789..f81860a85cb51e8d8f51686a3ba3eb69192af4ad 100644 --- a/packages/components-faraday/src/components/Admin/AdminUsers.js +++ b/packages/components-faraday/src/components/Admin/AdminUsers.js @@ -24,6 +24,7 @@ const TableRow = ({ affiliation, isConfirmed, editorInChief, + handlingEditor, admin, roleOptions, }) => ( @@ -36,8 +37,8 @@ const TableRow = ({ <td>{affiliation}</td> <td> <Role>{`Author${isEqual(editorInChief, true) ? ', Editor in Chief' : ''}${ - isEqual(admin, true) ? ', Admin' : '' - }`}</Role> + isEqual(handlingEditor, true) ? ', Handling Editor' : '' + }${isEqual(admin, true) ? ', Admin' : ''}`}</Role> </td> <td> <Tag>{isConfirmed ? 'Confirmed' : 'Invited'}</Tag> diff --git a/packages/components-faraday/src/components/Admin/EditUserForm.js b/packages/components-faraday/src/components/Admin/EditUserForm.js index ecbef0d9aff2bc5ad41ab4706a3da6cf313e5d95..afbe740a1a0b933dddbab781d39cb952753cb560 100644 --- a/packages/components-faraday/src/components/Admin/EditUserForm.js +++ b/packages/components-faraday/src/components/Admin/EditUserForm.js @@ -69,6 +69,17 @@ const EditUserForm = ({ roles, journal, user, error }) => ( )} name="editorInChief" /> + <ValidatedField + component={input => ( + <Checkbox + checked={input.value} + type="checkbox" + {...input} + label="Handling Editor" + /> + )} + name="handlingEditor" + /> <ValidatedField component={input => ( <Checkbox diff --git a/packages/components-faraday/src/components/Admin/utils.js b/packages/components-faraday/src/components/Admin/utils.js index 18d68678757f353480e592d49f094e0e98129b11..eb9b5cec9493be46809ba4bddafabf961eba5db9 100644 --- a/packages/components-faraday/src/components/Admin/utils.js +++ b/packages/components-faraday/src/components/Admin/utils.js @@ -24,6 +24,7 @@ export const parseUpdateUser = values => { 'roles', 'rev', 'editorInChief', + 'handlingEditor', ] return pick(values, valuesToSave) diff --git a/packages/components-faraday/src/components/Dashboard/DashboardCard.js b/packages/components-faraday/src/components/Dashboard/DashboardCard.js index c3efeff710fbd173d63a1d94e72c17a02e49dac8..5a0087a40ee4f16bf8489a2172ef8b5625de19c6 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardCard.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardCard.js @@ -70,11 +70,11 @@ const DashboardCard = ({ </RightDetails> </Top> <Bottom> - <LeftDetails flex="2"> + <LeftDetails flex="3"> <Status>{mapStatusToLabel(status)}</Status> <DateField>{submitted || ''}</DateField> </LeftDetails> - <RightDetails flex="5"> + <RightDetails flex="4"> <ManuscriptType title={manuscriptMeta}> {manuscriptMeta} </ManuscriptType> diff --git a/packages/components-faraday/src/components/Dashboard/utils.js b/packages/components-faraday/src/components/Dashboard/utils.js index 3f8c72b5a438a5298b87a353a4114a7b38856fc2..c3604010acb437e90aaeb9528b7826d8419b5586 100644 --- a/packages/components-faraday/src/components/Dashboard/utils.js +++ b/packages/components-faraday/src/components/Dashboard/utils.js @@ -78,7 +78,7 @@ export const parseJournalIssue = (journal, metadata) => export const mapStatusToLabel = status => { switch (status) { case 'he-invited': - return 'HE Invited' + return 'Handling Editor Invited' default: return 'Submitted' }