Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ This API is used to GET the surveys ids to which the surveyed or the surveyers h
{
"id": 0,
"interviewerId": "string",
"interrogationId": "string",
"surveyUnitId": "string",
"reviewerId": "string",
"campaignId": "string",
Expand Down Expand Up @@ -519,7 +520,7 @@ This API is used to GET all required nomenclatures for the application such as q

---

`GET /survey-unit/{id}` : get a survey unit by id
`GET /interrogations/{id}` : get a survey unit by interrogation id

<details>
<summary>Answer format</summary>
Expand All @@ -545,7 +546,7 @@ This API is used to GET all required nomenclatures for the application such as q

---

`PUT /survey-unit/{id}` : Edit a survey unit by id
`PUT /interrogations/{id}` : Edit a survey unit by interrogation id


<details>
Expand Down Expand Up @@ -1381,12 +1382,12 @@ The application is completely functional offline in browser or in the applicatio

For the reviewer mode, the information recovered is done on two requetes:

- To retrieve the data: VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/survey-unit/" + idSurvey + "/data"
- To retrieve the stateData : VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/survey-unit/" + idSurvey + "/state-data"
- To retrieve the data: VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/interrogations/" + interrogationId + "/data"
- To retrieve the stateData : VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/interrogations/" + interrogationId + "/state-data"

For the interviewer mode, the information retrieved is done on the following request:

- VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/survey-unit/" + idSurvey.
- VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/interrogations/" + interrogationId.

Same mechanism used to save information relevant to surveys.

Expand Down
4 changes: 2 additions & 2 deletions e2e/e2e-reviewer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock("axios");
const urlHost = import.meta.env.VITE_KEYCLOAK_REDIRECT_URI;
const urlUserSurvey = edtOrganisationApiBaseUrl + "api/survey-assigment/interviewer/my-surveys";
const urlSurveysDataReviewer = edtOrganisationApiBaseUrl + "api/survey-assigment/reviewer/my-surveys";
const urlSurveyData = stromaeBackOfficeApiBaseUrl + "api/survey-unit/";
const urlSurveyData = stromaeBackOfficeApiBaseUrl + "api/interrogations/";

const userServiceMock = jest.fn(isReviewer).mockImplementationOnce(() => true);

Expand Down Expand Up @@ -43,7 +43,7 @@ describe("App.ts", () => {
};

const mockSurveyData = (request: any, url: string) => {
const idSurvey = Number.parseInt(url.split("survey-unit/")[1].split("-")[1] ?? 0);
const idSurvey = Number.parseInt(url.split("interrogations/")[1].split("-")[1] ?? 0);
request.respond({
headers: mockHeaders,
body: JSON.stringify(userData[idSurvey - 1]),
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jest.mock("axios");

const urlHost = import.meta.env.VITE_KEYCLOAK_REDIRECT_URI;
const urlUserSurvey = edtOrganisationApiBaseUrl + "api/survey-assigment/interviewer/my-surveys";
const urlSurveyData = stromaeBackOfficeApiBaseUrl + "api/survey-unit/";
const urlSurveyData = stromaeBackOfficeApiBaseUrl + "api/interrogations/";

describe("App.ts", () => {
let browser;
Expand All @@ -29,7 +29,7 @@ describe("App.ts", () => {
};

const mockSurveyData = (request: any, url: string) => {
const idSurvey = Number.parseInt(url.split("survey-unit/")[1].split("-")[1] ?? 0);
const idSurvey = Number.parseInt(url.split("interrogations/")[1].split("-")[1] ?? 0);
request.respond({
headers: mockHeaders,
body: JSON.stringify(userData[idSurvey - 1]),
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default tseslint.config(
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_$" }],
},
},
);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "edt",
"version": "4.5.1",
"dateVersion": "10/07/2025",
"version": "4.6.2",
"dateVersion": "22/08/2025",
"licence": "MIT",
"type": "module",
"dependencies": {
Expand Down
11 changes: 6 additions & 5 deletions src/documentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ This API is used to GET the surveys ids to which the surveyed or the surveyers h
{
"id": 0,
"interviewerId": "string",
"interrogationId": "string",
"surveyUnitId": "string",
"reviewerId": "string",
"campaignId": "string",
Expand Down Expand Up @@ -503,7 +504,7 @@ This API is used to GET all required nomenclatures for the application such as q

---

`GET /survey-unit/{id}` : get a survey unit by id
`GET /interrogations/{id}` : get a survey unit by id

<details>
<summary>Answer format</summary>
Expand All @@ -529,7 +530,7 @@ This API is used to GET all required nomenclatures for the application such as q

---

`PUT /survey-unit/{id}` : Edit a survey unit by id
`PUT /interrogations/{id}` : Edit a survey unit by id


<details>
Expand Down Expand Up @@ -1395,12 +1396,12 @@ The application is completely functional offline in browser or in the applicatio

For the reviewer mode, the information recovered is done on two requetes:

- To retrieve the data: VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/survey-unit/" + idSurvey + "/data"
- To retrieve the stateData : VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/survey-unit/" + idSurvey + "/state-data"
- To retrieve the data: VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/interrogations/" + interrogationId + "/data"
- To retrieve the stateData : VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/interrogations/" + interrogationId + "/state-data"

For the interviewer mode, the information retrieved is done on the following request:

- VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/survey-unit/" + idSurvey.
- VITE_STROMAE_BACK_OFFICE_API_BASE_URL + "api/interrogations/" + interrogationId.

Same mechanism used to save information relevant to surveys.

Expand Down
1 change: 1 addition & 0 deletions src/interface/entity/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface UserSurveys {
campaignId: string;
subCampaignId?: string;
interviewerId: string;
interrogationId: string;
questionnaireModelId: string;
reviewerId?: string;
surveyUnitId: string;
Expand Down
141 changes: 0 additions & 141 deletions src/orchestrator/Orchestrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,52 +48,6 @@ const renderLoading = () => {
);
};

// const getDataOfLoop = (collected: any, editedSaved: any, iteration: number | undefined) => {
// let maxLenght = Number(localStorage.getItem("loopSize") ?? 0);
// for (let i = 0; i < maxLenght; i++) {
// if (i != iteration || (collected[i] == null && i == iteration)) {
// collected[i] = editedSaved[i];
// }
// }
// return collected;
// };

// const getDataOfCurrentBinding = (
// collected: any,
// edited: any,
// collectedSaved: any,
// editedSaved: any,
// dataOfField: any,
// iteration: number | undefined,
// ) => {
// // partie collected dejà set (mode enquete) -> set values of collected (value current lunawtic) to edited
// // and collected remains with the collected value on bdd

// if (collected) {
// if (editedSaved && Array.isArray(collected)) {
// collected = getDataOfLoop(collected, editedSaved, iteration);
// }
// dataOfField.EDITED = collected;
// dataOfField.COLLECTED = collectedSaved;
// } else if (dataOfField) {
// dataOfField.EDITED = edited ?? editedSaved;
// dataOfField.COLLECTED = collectedSaved;
// }

// return dataOfField;
// };

//prop is for activity and prop being modified
// const isPropCurrent = (prop: string, bindings?: string[]) => {
// return bindings?.includes(prop) ?? false;
// };

//return a copy of a object
// const copyObject = (object: any) => {
// if (object == null) return object;
// return Array.isArray(object) ? [...object] : JSON.parse(JSON.stringify(object));
// };

const isWorkTime = (source: LunaticModel | undefined) => {
return source ? source.label == "WorkTime" : getCurrentPageSource().label == "WorkTime";
};
Expand All @@ -111,95 +65,6 @@ const propsWorkTime = (source: LunaticModel): string[] => {
return uniqueBindingDependencies;
};

//if weekly planner, doesn't distinction edited/collected, so edited/collected get value of collected
// const setDataOfWorkTimeReviewer = (
// source: LunaticModel | undefined,
// data: LunaticData | undefined,
// dataCollected: any,
// ) => {
// if (!source) {
// source = getCurrentPageSource();
// }

// const weeklyPlannerProps = propsWorkTime(source);
// weeklyPlannerProps.forEach(prop => {
// let dataOfField = dataCollected[prop];
// const collectedSaved = data?.COLLECTED?.[prop]?.COLLECTED;
// const editedSaved = data?.COLLECTED?.[prop]?.EDITED;
// if (dataOfField) {
// dataOfField.EDITED = editedSaved;
// dataOfField.COLLECTED = collectedSaved;
// }
// });

// return dataCollected;
// };

// const setDataOfActivityReviewer = (
// dataCollected: any,
// data: LunaticData | undefined,
// components: any,
// iteration: number | undefined,
// ) => {
// const bindings: string[] = components?.filter(
// (component: any) => component.componentType != "Sequence",
// )[0]?.bindingDependencies;
// for (let prop in FieldNameEnumActivity as any) {
// let dataOfField = dataCollected[prop];
// const collected = dataOfField?.COLLECTED;
// const edited = dataOfField?.EDITED;
// const editedSaved = data?.COLLECTED?.[prop]?.EDITED;
// const collectedSaved = data?.COLLECTED?.[prop]?.COLLECTED;
// //prop activity + prop currently being edited
// if (isPropCurrent(prop, bindings)) {
// //get data of current prop ->
// //COLLECTED : value of bdd (COLLECTED)
// //EDITED: if exist EDITED -> value of lunatic for value[iteration], other -> value of bdd (EDITED)
// dataOfField = getDataOfCurrentBinding(
// copyObject(collected),
// copyObject(edited),
// copyObject(collectedSaved),
// copyObject(editedSaved),
// dataOfField,
// iteration,
// );
// } else if (dataOfField) {
// //prop activity + prop not currently being edited,
// //so edited get value of edited in bdd, and collected get value of partie collected in bdd
// dataOfField.EDITED = copyObject(editedSaved);
// dataOfField.COLLECTED = copyObject(collectedSaved);
// }
// dataCollected[prop] = dataOfField;
// }
// return dataCollected;
// };

//data of a reviewer
// const getDataReviewer = (
// getData: any,
// data: LunaticData | undefined,
// components: any,
// iteration: number | undefined,
// source?: LunaticModel,
// ) => {
// const callbackholder = getData();
// let dataCollected = callbackholder.COLLECTED;

// if (!source) {
// source = getCurrentPageSource();
// }
// // data -> get data of bdd, callbackholder -> lunatic / current data
// if (callbackholder && dataCollected) {
// if (isWorkTime(source)) {
// dataCollected = setDataOfWorkTimeReviewer(source, data, dataCollected);
// } else {
// dataCollected = setDataOfActivityReviewer(dataCollected, data, components, iteration);
// }
// }
// callbackholder.COLLECTED = dataCollected;
// return callbackholder;
// };

/**
* Retrieves and updates interviewer data.
*
Expand Down Expand Up @@ -328,12 +193,6 @@ export const OrchestratorForStories = (props: OrchestratorProps) => {
const getDataLocal = () => {
// Since we want to disable EDITED, only consider collected data
return getDataInterviewer(getData, data, source);
/*
const dataLocal = isReviewer()
? getDataReviewer(getData, data, components, iteration)
: getDataInterviewer(getData, data, source);
return dataLocal;
*/
};

callbackHolder.getData = getDataLocal;
Expand Down
37 changes: 20 additions & 17 deletions src/pages/home-surveyed/HomeSurveyed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ const HomeSurveyedPage = () => {

const initHome = (idsSurveysSelected: string[]) => {
initializeHomeSurveys(idHousehold ?? "").then(() => {
// initializeSurveysDatasCache(idsSurveysSelected).finally(() => {

// });

userDatas = userDatasMap();
if (getData(idsSurveysSelected[0]) != undefined) {
setState(getData(idsSurveysSelected[0]));
Expand All @@ -94,35 +90,42 @@ const HomeSurveyedPage = () => {
};

useEffect(() => {
if (navigator.onLine && role === EdtUserRightsEnum.SURVEYED) {
initializeDatas(setError).then(() => {
setInitialized(true);
});
} else if (role === EdtUserRightsEnum.SURVEYED) {
initializeDatas(setError).then(() => {
setInitialized(true);
setState({});
});
if (role === EdtUserRightsEnum.SURVEYED) {
if (navigator.onLine) {
initializeDatas(setError).then(() => {
setInitialized(true);
});
} else {
initializeDatas(setError).then(() => {
setInitialized(true);
setState({});
});
}
return;
}

if (role == EdtUserRightsEnum.REVIEWER && !isDemo) {
if (role === EdtUserRightsEnum.REVIEWER) {
if (isDemo) {
const userDatas = userDatasMap();
setDatas(userDatas);
return;
}

userDatas = userDatasMap();
const idsSurveysSelected = userDatas
.map(data => data.data.surveyUnitId)
.filter(
(survey: string) =>
!survey.startsWith("activitySurvey") && !survey.startsWith("workTimeSurvey"),
);

if (navigator.onLine) {
getRemoteSavedSurveysDatas(idsSurveysSelected, setError).then(() => {
initHome(idsSurveysSelected);
});
} else {
initHome(idsSurveysSelected);
}
} else if (role == EdtUserRightsEnum.REVIEWER && isDemo) {
let userDatas = userDatasMap();
setDatas(userDatas);
}
}, []);

Expand Down
Loading
Loading