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

add author as submitting when creating new manuscript submission

parent 3ae1e96d
No related branches found
No related tags found
No related merge requests found
import { pick } from 'lodash'
import { actions } from 'pubsweet-client'
/* constants */
......@@ -15,8 +16,27 @@ export const createDraftSuccess = draft => ({
})
/* actions */
export const createDraftSubmission = history => dispatch =>
dispatch(actions.createCollection()).then(({ collection }) => {
export const createDraftSubmission = history => (dispatch, getState) => {
const currentUser = getState().currentUser.user
let authors = []
if (!currentUser.admin) {
authors = [
{
...pick(currentUser, [
'affiliation',
'email',
'firstName',
'lastName',
'middleName',
'country',
]),
isSubmitting: true,
isCorresponding: true,
},
]
}
return dispatch(actions.createCollection()).then(({ collection }) => {
if (!collection.id) {
throw new Error('Failed to create a project')
}
......@@ -28,6 +48,7 @@ export const createDraftSubmission = history => dispatch =>
files: {
supplementary: [],
},
authors,
fragmentType: 'version',
metadata: {},
version: 1,
......@@ -41,7 +62,7 @@ export const createDraftSubmission = history => dispatch =>
}, 1000)
})
})
}
/* reducer */
const initialState = {
......
......@@ -72,17 +72,16 @@ const Authors = ({
export default compose(
withRouter,
getContext({ version: PropTypes.object, project: PropTypes.object }),
connect(null, {
addAuthor,
changeForm,
}),
withState('authors', 'setAuthors', []),
lifecycle({
componentDidMount() {
const { version, setAuthors } = this.props
setAuthors(version.authors)
connect(
state => ({
currentUser: state.currentUser.user,
}),
{
addAuthor,
changeForm,
},
}),
),
withState('authors', 'setAuthors', []),
withState('editMode', 'setEditMode', false),
withState('editedAuthor', 'setEditedAuthor', -1),
withHandlers({
......@@ -131,4 +130,10 @@ export default compose(
setFormAuthors(newAuthors)
},
}),
lifecycle({
componentDidMount() {
const { version, setAuthors } = this.props
setAuthors(version.authors)
},
}),
)(Authors)
......@@ -22,7 +22,10 @@ const DashboardCard = ({
const hasFiles = !isEmpty(files)
const abstract = get(version, 'metadata.abstract')
const metadata = get(version, 'metadata')
return (
const journalIssueType = journal.issueTypes.find(
t => t.value === get(metadata, 'issue'),
)
return version ? (
<Card>
<ListView>
<Left>
......@@ -69,9 +72,7 @@ const DashboardCard = ({
<DetailsView>
<LeftDetails>
<JournalTitle>{journal.metadata.nameText}</JournalTitle>
<Issue>
{journal.issueTypes.find(t => t.value === metadata.issue).label}
</Issue>
{journalIssueType && <Issue>{journalIssueType.label}</Issue>}
{get(version, 'authors') && (
<Authors>
<span>Authors:</span>
......@@ -111,7 +112,7 @@ const DashboardCard = ({
</RightDetails>
</DetailsView>
</Card>
)
) : null
}
export default compose(getContext({ journal: PropTypes.object }))(DashboardCard)
......
......@@ -26,7 +26,7 @@ module.exports = {
'pubsweet-client': {
API_ENDPOINT: '/api',
'login-redirect': '/',
'redux-log': false,
'redux-log': true,
theme: process.env.PUBSWEET_THEME,
},
'mail-transport': {
......
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