diff --git a/src/orchestrator/Orchestrator.tsx b/src/orchestrator/Orchestrator.tsx
index c8b41d7e..34e9d0aa 100644
--- a/src/orchestrator/Orchestrator.tsx
+++ b/src/orchestrator/Orchestrator.tsx
@@ -357,6 +357,7 @@ export const OrchestratorForStories = (props: OrchestratorProps) => {
source,
),
);
+ console.log("Value", value);
return (
{
>
- {/* {
aria-label={t("page.alert-when-quit.alt-alert-icon")}
/>
}
- > */}
+ >
{
{activitiesRoutesOrGaps.length !== 0 &&
(isReviewerMode ? (
- {/* {
aria-label={t("page.alert-when-quit.alt-alert-icon")}
/>
}
- > */}
+ >
{t("page.activity-planner.activity-for-day")}
diff --git a/src/pages/home-surveyed/HomeSurveyed.tsx b/src/pages/home-surveyed/HomeSurveyed.tsx
index 5db91b85..711d6396 100644
--- a/src/pages/home-surveyed/HomeSurveyed.tsx
+++ b/src/pages/home-surveyed/HomeSurveyed.tsx
@@ -372,9 +372,9 @@ const HomeSurveyedPage = () => {
return (
<>
- {/*
+
- */}
+
{isReviewer ? (
diff --git a/src/service/api-service/getRemoteData.ts b/src/service/api-service/getRemoteData.ts
index 7d864cc4..000ab213 100644
--- a/src/service/api-service/getRemoteData.ts
+++ b/src/service/api-service/getRemoteData.ts
@@ -1,9 +1,12 @@
import axios from "axios";
import { ErrorCodeEnum } from "enumerations/ErrorCodeEnum";
import { StateData, SurveyData, UserSurveys } from "interface/entity/Api";
-import { LunaticData, SourceData } from "interface/lunatic/Lunatic";
+import { LunaticData, ReferentielData, SourceData } from "interface/lunatic/Lunatic";
import { initStateData, initSurveyData } from "../survey-service";
import { getUserToken, isReviewer } from "../user-service";
+import { AuthContextProps } from "oidc-react";
+import { NomenclatureActivityOption } from "@inseefrlab/lunatic-edt";
+import { ReferentielsEnum } from "enumerations/ReferentielsEnum";
export const edtOrganisationApiBaseUrl = process.env.REACT_APP_EDT_ORGANISATION_API_BASE_URL;
export const stromaeBackOfficeApiBaseUrl = process.env.REACT_APP_STROMAE_BACK_OFFICE_API_BASE_URL;
@@ -31,6 +34,57 @@ export const getHeader = (origin?: string, userToken?: string) => {
};
};
+const fetchRemoteReferentiel = (auth: AuthContextProps, idReferentiel: ReferentielsEnum) => {
+ return axios.get(
+ stromaeBackOfficeApiBaseUrl + "api/nomenclature/" + idReferentiel,
+ getHeader(stromaeBackOfficeApiBaseUrl),
+ );
+};
+
+const fetchRemoteReferentiels = (setError: (error: ErrorCodeEnum) => void): Promise => {
+ let refs: ReferentielData = {
+ [ReferentielsEnum.ACTIVITYNOMENCLATURE]: [],
+ [ReferentielsEnum.ACTIVITYAUTOCOMPLETE]: [],
+ [ReferentielsEnum.ROUTE]: [],
+ [ReferentielsEnum.MEANOFTRANSPORT]: [],
+ [ReferentielsEnum.ACTIVITYSECONDARYACTIVITY]: [],
+ [ReferentielsEnum.ROUTESECONDARYACTIVITY]: [],
+ [ReferentielsEnum.LOCATION]: [],
+ [ReferentielsEnum.KINDOFWEEK]: [],
+ [ReferentielsEnum.KINDOFDAY]: [],
+ [ReferentielsEnum.ACTIVITYGOAL]: [],
+ };
+ let refsEndPoints: string[] = [];
+ Object.values(ReferentielsEnum).forEach(value => {
+ refsEndPoints.push("api/nomenclature/" + value);
+ });
+
+ return new Promise(resolve => {
+ axios
+ .all(
+ refsEndPoints.map(endPoint =>
+ axios.get(
+ stromaeBackOfficeApiBaseUrl + endPoint,
+ getHeader(stromaeBackOfficeApiBaseUrl),
+ ),
+ ),
+ )
+ .then(res => {
+ Object.values(ReferentielsEnum).forEach((key, index) => {
+ refs[key as ReferentielsEnum] = res[index].data;
+ });
+ resolve(refs);
+ })
+ .catch(err => {
+ if (err.response?.status === 403) {
+ setError(ErrorCodeEnum.NO_RIGHTS);
+ } else {
+ setError(ErrorCodeEnum.UNREACHABLE_NOMENCLATURES);
+ }
+ });
+ });
+};
+
const revertTransformedArray = (dataAct: any) => {
const revertedDataAct: { [key: string]: any } = {};
Object.keys(dataAct).forEach(key => {
@@ -240,6 +294,8 @@ const remoteGetSurveyDataReviewer = (
};
export {
+ fetchRemoteReferentiel,
+ fetchRemoteReferentiels,
fetchReviewerSurveysAssignments,
fetchSurveysSourcesByIds,
fetchUserSurveysInfo,
diff --git a/src/service/survey-service.ts b/src/service/survey-service.ts
index 16a60cf3..3e474a00 100644
--- a/src/service/survey-service.ts
+++ b/src/service/survey-service.ts
@@ -94,7 +94,11 @@ const NUM_MAX_WORKTIME_SURVEYS = 3;
let referentielsData: ReferentielData;
let sourcesData: SourceData;
-let surveysIds: SurveysIds;
+let surveysIds: SurveysIds = {
+ [SurveysIdsEnum.ALL_SURVEYS_IDS]: [],
+ [SurveysIdsEnum.ACTIVITY_SURVEYS_IDS]: [],
+ [SurveysIdsEnum.WORK_TIME_SURVEYS_IDS]: [],
+};
let userDatasActivity: UserSurveys[] = [];
let userDatasWorkTime: UserSurveys[] = [];
let userDatas: UserSurveys[] = [];
@@ -175,7 +179,6 @@ const initializeRefs = () => {
return lunaticDatabase.get(REFERENTIELS_ID).then(refData => {
if (!refData && navigator.onLine) {
return fetchReferentiels().then(refs => {
- console.log("refs", refs);
return saveReferentiels(refs);
});
} else {
@@ -797,7 +800,7 @@ const dataIsChange = (idSurvey: string, dataAct: LunaticData, lastData: LunaticD
if (!dataCollected || !currentDataCollected) {
return true;
}
- console.log("dataIsChange", !_.isEqual(dataCollected, currentDataCollected));
+ //console.log("dataIsChange", !_.isEqual(dataCollected, currentDataCollected));
return !_.isEqual(dataCollected, currentDataCollected);
};
@@ -967,7 +970,6 @@ const saveData = (
forceUpdate = false,
stateDataForced?: StateData,
): Promise => {
- console.log("saveData");
data.lastLocalSaveDate = navigator.onLine ? Date.now() : Date.now() + 1;
if (!data.houseReference) {
const regexp = new RegExp(process.env.REACT_APP_HOUSE_REFERENCE_REGULAR_EXPRESSION || "");