Skip to content

Commit

Permalink
refactor: switch from remote to local survey source for reviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
MailineN committed Aug 21, 2024
1 parent 0664096 commit 27128e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/pages/end-survey/EndSurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ const EndSurveyPage = () => {
data: dataWithIsEnvoyed ?? callbackHolder.getData(),
};

const handleSuccess = (surveyDataAnswer: any) => {
surveyData.data.lastRemoteSaveDate = surveyDataAnswer.stateData?.date;
return saveDataAndInit(surveyData, true);
};
// const handleSuccess = (surveyDataAnswer: any) => {
// surveyData.data.lastRemoteSaveDate = surveyDataAnswer.stateData?.date;
// return saveDataAndInit(surveyData, true);
// };

const handleError = () => {
setErrorSubmit(true);
Expand Down
2 changes: 0 additions & 2 deletions src/service/loop-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,7 @@ const getCurrentLoopPage = (

//TODO: Edit this function to send state data with COMPLETED status instead
const setLoopCompleted = (idSurvey: string, iteration: number | undefined, isCompleted: boolean) => {
console.log("setLoopCompleted ", idSurvey, iteration, isCompleted);
const completed = setValue(idSurvey, FieldNameEnum.ISCOMPLETED, isCompleted, iteration);
console.log("setLoopCompleted -> completed", completed);
if (completed) {
saveData(idSurvey, completed);
}
Expand Down
21 changes: 9 additions & 12 deletions src/service/survey-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import {
import { EdtUserRightsEnum } from "./../enumerations/EdtUserRightsEnum";
import { LunaticData } from "./../interface/lunatic/Lunatic";
import {
fetchSurveysSourcesByIds,
fetchUserSurveysInfo,
remoteGetSurveyData,
remoteGetSurveyDataReviewer,
Expand Down Expand Up @@ -235,23 +234,21 @@ const initDataForSurveys = (setError: (error: ErrorCodeEnum) => void) => {
[SurveysIdsEnum.ACTIVITY_SURVEYS_IDS]: activitySurveysIds,
[SurveysIdsEnum.WORK_TIME_SURVEYS_IDS]: workingTimeSurveysIds,
};
const sources: SourceData = {
[SourcesEnum.ACTIVITY_SURVEY]: edtActivitySurvey,
[SourcesEnum.WORK_TIME_SURVEY]: edtWorkTimeSurvey,
};
const innerPromises: Promise<any>[] = [
getRemoteSavedSurveysDatas(allSurveysIds, setError).then(() => {
return initializeSurveysDatasCache(allSurveysIds);
}),
saveSurveysIds(surveysIds),
fetchSurveysSourcesByIds(
[SourcesEnum.ACTIVITY_SURVEY, SourcesEnum.WORK_TIME_SURVEY],
setError,
).then(sources => {
const inerFetchPromises: Promise<any>[] = [
saveSources(sources),
saveUserSurveysData({ data: userDatas }),
];
return Promise.all(inerFetchPromises);
}),
];
return Promise.all(innerPromises);
const inerFetchPromises: Promise<any>[] = [
saveSources(sources),
saveUserSurveysData({ data: userDatas }),
];
return Promise.all([...innerPromises, ...inerFetchPromises]);
});
} else {
return lunaticDatabase.get(USER_SURVEYS_DATA).then((data: LunaticData | undefined) => {
Expand Down

0 comments on commit 27128e3

Please sign in to comment.