Skip to content

Commit

Permalink
fix(data): fix duplicate userDatas
Browse files Browse the repository at this point in the history
  • Loading branch information
lailabjil committed Apr 23, 2024
1 parent a391c43 commit 9dc3e2d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,16 @@ The variable ENDTIME is updated EDITED part by removing the ancient third elemen

![DURATION ENDTIME VALUE](./src/documentation/images/update_survey_delete_activity_duration_endtime_value.png)

## Offline

The application is completely functional offline in browser or in the application, you can exit the application and when you return you will be able to use it without any problem and all the cached data will be used.

Once in offline mode, authentication is not performed or the token is reviewed until the next online connection. Likewise, there is no requirement for the released API, everything is cached.

As there is no requirement with the API, the local data will not be sent until we go online and : either click on the "update the list" button, or modify the corresponding survey.

If we click the "update list" button after having been in offline mode and having made modifications, we will send all the households that have been modified in offline.

## Maintenance and evolution

### Install local development environment
Expand Down
12 changes: 7 additions & 5 deletions src/service/survey-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,13 @@ const initializeListSurveys = (setError: (error: ErrorCodeEnum) => void) => {
surveysData = data;
addArrayToSession("surveysData", surveysData);
data.forEach((surveyData: UserSurveys) => {
if (surveyData.questionnaireModelId === SourcesEnum.ACTIVITY_SURVEY) {
userDatas.push(surveyData);
}
if (surveyData.questionnaireModelId === SourcesEnum.WORK_TIME_SURVEY) {
userDatas.push(surveyData);
if (!userDatas?.find(user => user.surveyUnitId == surveyData.surveyUnitId)) {
if (surveyData.questionnaireModelId === SourcesEnum.ACTIVITY_SURVEY) {
userDatas.push(surveyData);
}
if (surveyData.questionnaireModelId === SourcesEnum.WORK_TIME_SURVEY) {
userDatas.push(surveyData);
}
}
});
return saveUserSurveysData({ data: userDatas }).then(saved => console.log(saved, data));
Expand Down

0 comments on commit 9dc3e2d

Please sign in to comment.