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

fix(upload-file): fix uploading a file on submit manuscript wizard

parent b6c3a4d7
No related branches found
No related tags found
1 merge request!13Sprint #14
...@@ -51,7 +51,9 @@ export const createDraftSubmission = history => (dispatch, getState) => { ...@@ -51,7 +51,9 @@ export const createDraftSubmission = history => (dispatch, getState) => {
actions.createFragment(collection, { actions.createFragment(collection, {
created: new Date(), // TODO: set on server created: new Date(), // TODO: set on server
files: { files: {
manuscripts: [],
supplementary: [], supplementary: [],
coverLetter: [],
}, },
fragmentType: 'version', fragmentType: 'version',
metadata: {}, metadata: {},
......
import React from 'react' import React from 'react'
import { get } from 'lodash'
import { th } from '@pubsweet/ui' import { th } from '@pubsweet/ui'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { get, isEqual } from 'lodash'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import styled from 'styled-components' import styled from 'styled-components'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { selectFragment } from 'xpub-selectors'
import { change as changeForm } from 'redux-form' import { change as changeForm } from 'redux-form'
import { import {
compose, compose,
lifecycle, lifecycle,
withState, withState,
getContext,
withContext, withContext,
withHandlers, withHandlers,
} from 'recompose' } from 'recompose'
...@@ -77,11 +77,11 @@ const Files = ({ ...@@ -77,11 +77,11 @@ const Files = ({
export default compose( export default compose(
withRouter, withRouter,
getContext({ version: PropTypes.object, project: PropTypes.object }),
connect( connect(
state => ({ (state, { match }) => ({
isFetching: getRequestStatus(state),
error: getFileError(state), error: getFileError(state),
isFetching: getRequestStatus(state),
version: selectFragment(state, match.params.version),
}), }),
{ {
changeForm, changeForm,
...@@ -103,6 +103,13 @@ export default compose( ...@@ -103,6 +103,13 @@ export default compose(
supplementary: get(files, 'supplementary') || [], supplementary: get(files, 'supplementary') || [],
})) }))
}, },
componentWillReceiveProps(nextProps) {
const { setFiles, version: { files: previousFiles } } = this.props
const { version: { files } } = nextProps
if (!isEqual(previousFiles, files)) {
setFiles(files)
}
},
}), }),
withHandlers({ withHandlers({
dropSortableFile: ({ files, setFiles, changeForm }) => ( dropSortableFile: ({ files, setFiles, changeForm }) => (
......
...@@ -174,7 +174,7 @@ export default { ...@@ -174,7 +174,7 @@ export default {
title: '4. Manuscript Files Upload', title: '4. Manuscript Files Upload',
children: [ children: [
{ {
fieldId: 'file-upload', fieldId: 'files',
renderComponent: Files, renderComponent: Files,
validate: [requiredFiles], validate: [requiredFiles],
}, },
......
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