Skip to content

Commit

Permalink
when refiling is triggered, note this in the state, preventing an inc…
Browse files Browse the repository at this point in the history
…orrect submission query and associated bugginess
  • Loading branch information
wpears committed Dec 31, 2019
1 parent 7b95c42 commit e594f6d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/filing/actions/refileReady.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as types from '../constants'

export default function refileReady() {
return {
type: types.REFILE_READY
}
}
7 changes: 7 additions & 0 deletions src/filing/actions/startRefile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as types from '../constants'

export default function startRefile() {
return {
type: types.START_REFILE
}
}
5 changes: 4 additions & 1 deletion src/filing/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
export const RECEIVE_LATEST_SUBMISSION = 'RECEIVE_LATEST_SUBMISSION'
10 changes: 8 additions & 2 deletions src/filing/modals/confirmationModal/container.jsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -32,22 +34,26 @@ 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 {
return dispatch(fetchNewSubmission(lei, period)).then(() => {
const pathname = `/filing/${period}/${lei}/upload`
if(page === 'institutions') ownProps.history.push(pathname)
else ownProps.history.replace(pathname)
dispatch(refileReady())
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/filing/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,5 +38,6 @@ export default combineReducers({
error,
user,
redirecting,
latestSubmissions
latestSubmissions,
refiling
})
16 changes: 16 additions & 0 deletions src/filing/reducers/refiling.js
Original file line number Diff line number Diff line change
@@ -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
}
}
9 changes: 5 additions & 4 deletions src/filing/submission/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(() => {
Expand Down Expand Up @@ -152,15 +152,16 @@ 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

return {
submission,
params,
lei,
edits
edits,
refiling
}
}

Expand Down

0 comments on commit e594f6d

Please sign in to comment.