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