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

feat(assign-he): finish assigning and revoking he

parent c8d0e0aa
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ module.exports = models => async (req, res) => {
'revoke-handling-editor',
)
return res.status(204).json()
return res.status(200).json({})
} catch (e) {
logger.error(e.message)
return res.status(500).json({ error: 'Email could not be sent.' })
......
......@@ -5,6 +5,7 @@ import { get } from 'lodash'
import { compose } from 'recompose'
import { connect } from 'react-redux'
import { th, Icon } from '@pubsweet/ui'
import { actions } from 'pubsweet-client'
import styled, { withTheme } from 'styled-components'
import { handlingEditors, assignHandlingEditor } from '../../redux/editors'
......@@ -34,14 +35,22 @@ class AssignHEModal extends React.Component {
showModal,
hideModal,
setModalError,
updateCollection,
getCollections,
} = this.props
assignHandlingEditor(email, collectionId).then(
() => {
hideModal()
showModal({
type: 'confirmation',
title: 'Assignation Sent',
cancelText: 'OK',
updateCollection({
id: collectionId,
status: 'he-invited',
}).then(() => {
getCollections()
hideModal()
showModal({
type: 'confirmation',
title: 'Assignation Sent',
cancelText: 'OK',
})
})
},
e => {
......@@ -103,7 +112,11 @@ export default compose(
state => ({
editors: handlingEditors(state),
}),
{ assignHandlingEditor },
{
assignHandlingEditor,
updateCollection: actions.updateCollection,
getCollections: actions.getCollections,
},
),
withTheme,
)(AssignHEModal)
......
......@@ -10,7 +10,7 @@ import {
} from 'pubsweet-component-modal/src/components'
import ZipFiles from './ZipFiles'
import { parseVersion, parseJournalIssue } from './utils'
import { parseVersion, parseJournalIssue, mapStatusToLabel } from './utils'
import HandlingEditorActions from './HandlingEditorActions'
const DashboardCard = ({
......@@ -71,7 +71,7 @@ const DashboardCard = ({
</Top>
<Bottom>
<LeftDetails flex="2">
<Status>{status}</Status>
<Status>{mapStatusToLabel(status)}</Status>
<DateField>{submitted || ''}</DateField>
</LeftDetails>
<RightDetails flex="5">
......
import React from 'react'
import { get, head } from 'lodash'
import { connect } from 'react-redux'
import { actions } from 'pubsweet-client'
import { Icon, Button, th } from '@pubsweet/ui'
import { compose, withHandlers } from 'recompose'
import styled, { css, withTheme } from 'styled-components'
......@@ -64,7 +65,12 @@ const handleError = fn => e => {
}
export default compose(
connect(null, { revokeHandlingEditor, assignHandlingEditor }),
connect(null, {
revokeHandlingEditor,
assignHandlingEditor,
updateCollection: actions.updateCollection,
getCollections: actions.getCollections,
}),
withTheme,
withModal({
modalKey: 'confirmHE',
......@@ -93,6 +99,8 @@ export default compose(
getHandlingEditor,
hideModal,
setModalError,
updateCollection,
getCollections,
}) => actionType => {
const editor = getHandlingEditor()
const resendConfig = {
......@@ -117,10 +125,16 @@ export default compose(
confirmText: 'Revoke invite',
onConfirm: () =>
revokeHandlingEditor(get(editor, 'id'), project.id).then(() => {
hideModal()
showModal({
type: 'success',
title: 'Handling Editor Assignation Revoked',
updateCollection({
id: project.id,
status: 'submitted',
}).then(() => {
getCollections()
hideModal()
showModal({
type: 'success',
title: 'Handling Editor Assignation Revoked',
})
})
}, handleError(setModalError)),
}
......
......@@ -74,3 +74,12 @@ export const parseVersion = version => ({
export const parseJournalIssue = (journal, metadata) =>
journal.issueTypes.find(t => t.value === get(metadata, 'issue'))
export const mapStatusToLabel = status => {
switch (status) {
case 'he-invited':
return 'HE 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