Commit 51af07a6 authored by Audrey Hamelers's avatar Audrey Hamelers
parent 35640c43
Pipeline #13063 passed with stages
in 5 minutes and 52 seconds
......@@ -26,7 +26,7 @@ class DashboardPage extends React.Component {
if (this.state.errors.length > 0) {
setTimeout(() => {
this.setState({ errors: [] })
}, 4000)
}, 5000)
}
}
async setReviewer(noteId, newPath) {
......@@ -36,25 +36,15 @@ class DashboardPage extends React.Component {
awaitRefetchQueries: true,
})
this.props.history.replace(newPath)
if (!set.data.addReviewer) {
this.setState({
errors: [
{
message: 'Manuscript already accepted for review.',
type: 'warning',
},
],
})
} else {
this.setState({
errors: [
{
message: 'Manuscript accepted for review.',
type: 'success',
},
],
})
}
const { success, message } = await set.data.addReviewer
this.setState({
errors: [
{
message,
type: success ? 'success' : 'warning',
},
],
})
}
render() {
const { currentUser, history } = this.props
......
......@@ -10,7 +10,10 @@ export const CURRENT_USER = gql`
`
export const ADD_REVIEWER = gql`
mutation AddReviewer($noteId: ID!) {
addReviewer(noteId: $noteId)
addReviewer(noteId: $noteId) {
success
message
}
}
`
export const COUNT_MANUSCRIPTS = gql`
......
const Team = require('./data-access')
const Note = require('../note/data-access')
const Manuscript = require('../manuscript')
const logger = require('@pubsweet/logger')
const TeamManager = {
......@@ -21,11 +22,33 @@ const TeamManager = {
userId,
)
await Note.delete(noteId, userId)
return true
const teams = await Team.selectByManuscriptId(manuscriptId)
if (
teams.some(t => t.roleName === 'submitter' && t.userId === userId)
) {
const man = await Manuscript.findById(manuscriptId, userId)
if (man.status === 'in-review') {
await Manuscript.update(
{ id: manuscriptId, status: 'submitted' },
userId,
)
return {
success: false,
message: `You have already checked and submitted ${manuscriptId}.`,
}
}
}
return {
success: true,
message: `Submission ${manuscriptId} accepted for review.`,
}
}
} catch (error) {
logger.error('Set reviewer error: ', error)
return false
return {
success: false,
message: 'Submission has already been taken for review.',
}
}
},
delete: Team.delete,
......
......@@ -3,5 +3,5 @@ extend type Query {
}
extend type Mutation {
addReviewer(noteId: ID!): Boolean!
addReviewer(noteId: ID!): MutationResult
}
\ No newline at end of file
Markdown is supported
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