diff --git a/src/filing/actions/refileReady.js b/src/filing/actions/refileReady.js new file mode 100644 index 000000000..645e0fc3e --- /dev/null +++ b/src/filing/actions/refileReady.js @@ -0,0 +1,7 @@ +import * as types from '../constants' + +export default function refileReady() { + return { + type: types.REFILE_READY + } +} diff --git a/src/filing/actions/startRefile.js b/src/filing/actions/startRefile.js new file mode 100644 index 000000000..98e9c633a --- /dev/null +++ b/src/filing/actions/startRefile.js @@ -0,0 +1,7 @@ +import * as types from '../constants' + +export default function startRefile() { + return { + type: types.START_REFILE + } +} diff --git a/src/filing/constants/index.js b/src/filing/constants/index.js index a76f129f7..e8073c1ef 100644 --- a/src/filing/constants/index.js +++ b/src/filing/constants/index.js @@ -24,6 +24,9 @@ export const UPDATE_FILING_PERIOD = 'UPDATE_FILING_PERIOD' export const UPDATE_PATHNAME = 'UPDATE_PATHNAME' export const SET_LEI = 'SET_LEI' +export const START_REFILE = 'START_REFILE' +export const REFILE_READY = 'REFILE_READY' + export const REQUEST_VERIFY_QUALITY = 'REQUEST_VERIFY_QUALITY' export const REQUEST_VERIFY_MACRO = 'REQUEST_VERIFY_MACRO' export const VERIFY_QUALITY = 'VERIFY_QUALITY' @@ -75,4 +78,4 @@ export const CHECK_SIGNATURE = 'CHECK_SIGNATURE' export const UPDATE_STATUS = 'UPDATE_STATUS' export const REQUEST_LATEST_SUBMISSION = 'REQUEST_LATEST_SUBMISSION' -export const RECEIVE_LATEST_SUBMISSION = 'RECEIVE_LATEST_SUBMISSION' \ No newline at end of file +export const RECEIVE_LATEST_SUBMISSION = 'RECEIVE_LATEST_SUBMISSION' diff --git a/src/filing/modals/confirmationModal/container.jsx b/src/filing/modals/confirmationModal/container.jsx index 80eaaf7d0..79a40af4a 100644 --- a/src/filing/modals/confirmationModal/container.jsx +++ b/src/filing/modals/confirmationModal/container.jsx @@ -1,6 +1,8 @@ import { connect } from 'react-redux' import { withRouter } from 'react-router-dom' import hideConfirm from '../../actions/hideConfirm.js' +import startRefile from '../../actions/startRefile.js' +import refileReady from '../../actions/refileReady.js' import fetchNewSubmission from '../../actions/fetchNewSubmission.js' import refreshState from '../../actions/refreshState.js' import selectFile from '../../actions/selectFile.js' @@ -32,15 +34,18 @@ export function mapDispatchToProps(dispatch, ownProps) { } const triggerRefile = (lei, period, page = '', file) => { + dispatch(startRefile()) dispatch(refreshState()) if (page === 'upload' && file) { checkFileErrors(file, fileErrors => { - if (fileErrors.length) + if (fileErrors.length){ + dispatch(refileReady()) return dispatch(processFileErrors(fileErrors, file.name)) - + } return dispatch(fetchNewSubmission(lei, period)).then(() => { dispatch(selectFile(file)) dispatch(fetchUpload(file)) + dispatch(refileReady()) }) }) } else { @@ -48,6 +53,7 @@ export function mapDispatchToProps(dispatch, ownProps) { const pathname = `/filing/${period}/${lei}/upload` if(page === 'institutions') ownProps.history.push(pathname) else ownProps.history.replace(pathname) + dispatch(refileReady()) }) } } diff --git a/src/filing/reducers/index.js b/src/filing/reducers/index.js index 47406e2b8..32233c142 100644 --- a/src/filing/reducers/index.js +++ b/src/filing/reducers/index.js @@ -18,6 +18,7 @@ import error from './error.js' import user from './user.js' import redirecting from './redirecting.js' import latestSubmissions from './latestSubmissions' +import refiling from './refiling' export default combineReducers({ lei, @@ -37,5 +38,6 @@ export default combineReducers({ error, user, redirecting, - latestSubmissions + latestSubmissions, + refiling }) diff --git a/src/filing/reducers/refiling.js b/src/filing/reducers/refiling.js new file mode 100644 index 000000000..bbc5e0ef0 --- /dev/null +++ b/src/filing/reducers/refiling.js @@ -0,0 +1,16 @@ +import { START_REFILE, REFILE_READY } from '../constants' +/* + * Show that a refile has been triggered to differentiate + * between empty state on a refile vs first load + */ + +export default (state = 0, action) => { + switch (action.type) { + case START_REFILE: + return 1 + case REFILE_READY: + return 0 + default: + return state + } +} diff --git a/src/filing/submission/router.jsx b/src/filing/submission/router.jsx index 7964caa42..f82fc4a7a 100644 --- a/src/filing/submission/router.jsx +++ b/src/filing/submission/router.jsx @@ -34,7 +34,7 @@ export class SubmissionRouter extends Component { guardRouting() { this.renderChildren = false - const { submission, edits, lei, match: {params}, dispatch } = this.props + const { submission, refiling, edits, lei, match: {params}, dispatch } = this.props const status = submission.status const wrongYear = !submission.id || +submission.id.period.year !== +params.filingPeriod @@ -48,7 +48,7 @@ export class SubmissionRouter extends Component { if (unmatchedId) dispatch(refreshState()) if(!lei || lei !== params.lei) return dispatch(setLei(params.lei)) - if(submission.isFetching) return + if(refiling || submission.isFetching) return if (unmatchedId || !status || status.code === UNINITIALIZED || wrongYear) { return dispatch(fetchSubmission()).then(() => { @@ -152,7 +152,7 @@ export class SubmissionRouter extends Component { } export function mapStateToProps(state, ownProps) { - const { submission, lei, edits } = state.app + const { submission, lei, edits, refiling } = state.app const { match: {params} } = ownProps @@ -160,7 +160,8 @@ export function mapStateToProps(state, ownProps) { submission, params, lei, - edits + edits, + refiling } }