Skip to content

Commit

Permalink
Update Transition to latest main
Browse files Browse the repository at this point in the history
Let the Survey and ValidateSurvey components load preferences from
server when the component is mounted.
  • Loading branch information
tahini committed May 16, 2023
1 parent 58e772e commit 825692d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import moment from 'moment-business-days';
import _get from 'lodash.get';

import config from 'chaire-lib-common/lib/config/shared/project.config';
import Preferences from 'chaire-lib-common/lib/config/Preferences';
import * as surveyHelperNew from 'evolution-common/lib/utils/helpers';
import Section from '../survey/Section';
import SectionNav from '../survey/SectionNav';
import { withSurveyContext } from 'evolution-frontend/lib/components/hoc/WithSurveyContextHoc';
import ConfirmModal from '../survey/modal/ConfirmModal';
import LoadingPage from '../shared/LoadingPage';
import { startSetSurveyValidateInterview, startUpdateSurveyValidateInterview, startResetSurveyValidateInterview, startSurveyValidateAddGroupedObjects, startSurveyValidateRemoveGroupedObjects } from '../../actions/survey/survey';
import { InterviewContext } from 'evolution-frontend/lib/contexts/InterviewContext';
Expand All @@ -26,7 +26,8 @@ export class ValidateSurvey extends React.Component {
constructor(props) {
super(props);
this.state = {
confirmModalOpenedShortname: null
confirmModalOpenedShortname: null,
preferencesLoaded: false
};
// set language if empty and change locale:
if (!props.i18n.language || config.languages.indexOf(props.i18n.language) <= -1)
Expand Down Expand Up @@ -61,6 +62,9 @@ export class ValidateSurvey extends React.Component {
componentDidMount() {
const interviewUuid = this.props.interviewUuid;
this.props.startSetSurveyValidateInterview(interviewUuid);
Preferences.load().then(() => {
this.setState({ preferencesLoaded: true })
})
}

onKeyPress(e) {
Expand Down
7 changes: 6 additions & 1 deletion packages/evolution-legacy/src/components/survey/Survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import moment from 'moment-business-days';
import _get from 'lodash.get';

import config from 'chaire-lib-common/lib/config/shared/project.config';
import Preferences from 'chaire-lib-common/lib/config/Preferences';
import * as surveyHelperNew from 'evolution-common/lib/utils/helpers';
import Section from './Section';
import SectionNav from './SectionNav';
Expand All @@ -28,7 +29,8 @@ export class Survey extends React.Component {
super(props);
surveyHelperNew.devLog('params_survey', props.location.search)
this.state = {
confirmModalOpenedShortname: null
confirmModalOpenedShortname: null,
preferencesLoaded: false
};
// set language if empty and change locale:
if (!props.i18n.language || config.languages.indexOf(props.i18n.language) <= -1)
Expand Down Expand Up @@ -67,6 +69,9 @@ export class Survey extends React.Component {
const pathSectionParentSection = pathSectionShortname && this.surveyContext.sections[pathSectionShortname] ? this.surveyContext.sections[pathSectionShortname].parentSection : null;
const { state } = this.context;
this.props.startSetInterview(existingActiveSection || pathSectionParentSection, surveyUuid, state.status === 'entering' && Object.keys(state.responses).length > 0 ? state.responses : undefined);
Preferences.load().then(() => {
this.setState({ preferencesLoaded: true })
});
}

onKeyPress(e) {
Expand Down

0 comments on commit 825692d

Please sign in to comment.