Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Merge pull request #552 from CDCgov/duplicate-loading
Browse files Browse the repository at this point in the history
[SDPV-680] Loading spinner from knowledge transfer
  • Loading branch information
kierk authored Jan 4, 2019
2 parents 2b7cb49 + 6f08970 commit fef3017
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
21 changes: 14 additions & 7 deletions webpack/actions/survey_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,22 @@ function fetchSurveyFailure(error) {
};
}

export function fetchDuplicates(id) {
export function fetchDuplicates(id, successHandler=null, failureHandler=null) {
const getPromise = axios.get(routes.duplicatesSurveyPath(id), {
headers: {
'X-Key-Inflection': 'camel',
'Accept': 'application/json'
}
});
if (successHandler) {
getPromise.then(successHandler);
}
if (failureHandler) {
getPromise.catch(failureHandler);
}
return {
type: FETCH_DUPLICATES,
payload: axios.get(routes.duplicatesSurveyPath(id), {
headers: {
'X-Key-Inflection': 'camel',
'Accept': 'application/json'
}
})
payload: getPromise
};
}

Expand Down
21 changes: 12 additions & 9 deletions webpack/containers/surveys/SurveyDedupeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ import BasicAlert from '../../components/BasicAlert';
class SurveyDedupeContainer extends Component {
constructor(props) {
super(props);
this.state = {
fetchDuplicatesAttempted: false
};
if (this.props.params.surveyId) {
this.props.fetchSurvey(this.props.params.surveyId);
this.props.fetchDuplicates(this.props.params.surveyId);
this.props.fetchDuplicates(this.props.params.surveyId, (successResponse)=>{
this.setState({fetchDuplicatesAttempted: successResponse.status === 200});
});
}
}

Expand All @@ -44,18 +49,16 @@ class SurveyDedupeContainer extends Component {
}

render() {
if(!this.props.survey || !this.props.potentialDupes){
if(!this.props.survey || !this.props.potentialDupes || !this.state.fetchDuplicatesAttempted){
return (
<Grid className="basic-bg">
<Row>
<Col xs={12}>
{this.props.isLoading &&
<div>
<LoadingSpinner msg="Loading survey..." />
<p>If not redirected there may no longer be any duplicates detected for this survey - try refreshing or contacting an administrator)</p>
</div>
}
{this.props.loadStatus == 'failure' &&
<div>
<LoadingSpinner msg={!this.state.fetchDuplicatesAttempted ? "Finding Duplicates..." : "Loading survey..."} />
<p>If not redirected there may no longer be any duplicates detected for this survey - try refreshing or contacting an administrator)</p>
</div>
{this.props.loadStatus === 'failure' &&
<BasicAlert msg={this.props.loadStatusText} severity='danger' />
}
</Col>
Expand Down

0 comments on commit fef3017

Please sign in to comment.