Skip to content
Snippets Groups Projects
Commit 496459b9 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'master' of gitlab.coko.foundation:xpub/xpub-faraday

parents 299c7230 587d4bf1
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
......@@ -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>
......
......@@ -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
......
......@@ -24,6 +24,7 @@ export const parseUpdateUser = values => {
'roles',
'rev',
'editorInChief',
'handlingEditor',
]
return pick(values, valuesToSave)
......
......@@ -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>
......
......@@ -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'
}
......
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