Skip to content

Commit

Permalink
Merge pull request #44 from InseeFrLab/feat/sprint18
Browse files Browse the repository at this point in the history
Feat/sprint18
  • Loading branch information
MichaelC67 authored Feb 20, 2024
2 parents a9a4eb4 + 8f63114 commit fbc439f
Show file tree
Hide file tree
Showing 56 changed files with 2,399 additions and 781 deletions.
5 changes: 3 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
REACT_APP_STROMAE_BACK_OFFICE_API_BASE_URL=https://stromae-edt-kc.demo.insee.io/
REACT_APP_EDT_ORGANISATION_API_BASE_URL=https://edt-api-kc.demo.insee.io/
REACT_APP_KEYCLOAK_AUTHORITY=https://auth.demo.insee.io/auth/realms/questionnaires-edt/
REACT_APP_KEYCLOAK_AUTHORITY_REVIEWER=https://auth.insee.io/auth/realms/questionnaires-particuliers/?kc_idp_hint=insee-ssp
REACT_APP_KEYCLOAK_CLIENT_ID=client-edt
REACT_APP_KEYCLOAK_REDIRECT_URI=http://localhost:3000/
REACT_APP_HOUSE_REFERENCE_REGULAR_EXPRESSION=.\$
REACT_APP_SEPARATOR_SUGGESTER=;
REACT_APP_NODE_ENV="development"
REACT_APP_CHROMIUM_PATH=node_modules/chromium/lib/chromium/chrome-win/chrome.exe
REACT_APP_NUM_ACTIVITY_SURVEYS=6
REACT_APP_NUM_WORKTIME_SURVEYS=3
REACT_APP_NUM_WORKTIME_SURVEYS=3
REACT_APP_REVIEWER_ROLE=edt-reviewer
REACT_APP_SURVEYED_ROLE=repondant_coleman
5 changes: 3 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
REACT_APP_STROMAE_BACK_OFFICE_API_BASE_URL=https://stromae-edt-kc.demo.insee.io/
REACT_APP_EDT_ORGANISATION_API_BASE_URL=https://edt-api-kc.demo.insee.io/
REACT_APP_KEYCLOAK_AUTHORITY=https://auth.demo.insee.io/auth/realms/questionnaires-edt/
REACT_APP_KEYCLOAK_AUTHORITY_REVIEWER=https://auth.insee.io/auth/realms/questionnaires-particuliers/?kc_idp_hint=insee-ssp
REACT_APP_KEYCLOAK_CLIENT_ID=client-edt
REACT_APP_KEYCLOAK_REDIRECT_URI=https://insee-recette-edt.k8s.keyconsulting.fr/
REACT_APP_HOUSE_REFERENCE_REGULAR_EXPRESSION=.\$
REACT_APP_SEPARATOR_SUGGESTER=;
REACT_APP_NODE_ENV="production"
REACT_APP_CHROMIUM_PATH=/builds/insee/edt/deploy/pwa-edt/node_modules/chromium/lib/chromium/chrome-linux/chrome
REACT_APP_NUM_ACTIVITY_SURVEYS=6
REACT_APP_NUM_WORKTIME_SURVEYS=3
REACT_APP_NUM_WORKTIME_SURVEYS=3
REACT_APP_REVIEWER_ROLE=edt-reviewer
REACT_APP_SURVEYED_ROLE=repondant_coleman
5 changes: 3 additions & 2 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
REACT_APP_STROMAE_BACK_OFFICE_API_BASE_URL=https://stromae-edt-kc.demo.insee.io/
REACT_APP_EDT_ORGANISATION_API_BASE_URL=https://edt-api-kc.demo.insee.io/
REACT_APP_KEYCLOAK_AUTHORITY=https://auth.demo.insee.io/auth/realms/questionnaires-edt/
REACT_APP_KEYCLOAK_AUTHORITY_REVIEWER=https://auth.insee.io/auth/realms/questionnaires-particuliers/?kc_idp_hint=insee-ssp
REACT_APP_KEYCLOAK_CLIENT_ID=client-edt
REACT_APP_KEYCLOAK_REDIRECT_URI=https://insee-edt.k8s.keyconsulting.fr/
REACT_APP_HOUSE_REFERENCE_REGULAR_EXPRESSION=.\$
Expand All @@ -10,4 +9,6 @@ REACT_APP_NODE_ENV="staging"
REACT_APP_CHROMIUM_PATH=/builds/insee/edt/deploy/pwa-edt/node_modules/chromium/lib/chromium/chrome-linux/chrome
REACT_APP_NUM_ACTIVITY_SURVEYS=6
REACT_APP_NUM_WORKTIME_SURVEYS=3
DISPLAY=:10.0
DISPLAY=:10.0
REACT_APP_REVIEWER_ROLE=edt-reviewer
REACT_APP_SURVEYED_ROLE=repondant_coleman
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ Those states have been defined to ease the visibility of the ongoing current sur

## Lifecycle state

![](https://imgur.com/Y3bjnVs.png)
![](./src/documentation/images/lifecycle_state.png)

### Project structure

![](https://i.imgur.com/Jt1FrnR.png)
![](./src/documentation/images/projet_structure.png)

`src` : Contains all the source code of the application. It also has the 2 surveys sources required by Lunatic and used by EDT.

Expand Down Expand Up @@ -392,7 +392,7 @@ SSO is available using INSEE LDAP only with users with reviewer role. The review

#### Architecture schema

![](https://i.imgur.com/Q3sKoCe.png)
![](./src/documentation/images/schema_architecture.png)

#### API Edt-pilotage

Expand Down Expand Up @@ -976,7 +976,7 @@ The `.env.production` file is used when the builded app is hosted.
REACT_APP_STROMAE_BACK_OFFICE_API_BASE_URL=https://stromae-edt-kc.demo.insee.io/
REACT_APP_EDT_ORGANISATION_API_BASE_URL=https://edt-api-kc.demo.insee.io/
REACT_APP_KEYCLOAK_AUTHORITY=https://auth.demo.insee.io/auth/realms/questionnaires-edt/
REACT_APP_KEYCLOAK_AUTHORITY_REVIEWER=https://auth.insee.io/auth/realms/questionnaires-particuliers/?kc_idp_hint=insee-ssp
REACT_APP_KEYCLOAK_AUTHORITY_REVIEWER=https://auth.insee.io/auth/realms/questionnaires-particuliers/
REACT_APP_KEYCLOAK_CLIENT_ID=client-edt
REACT_APP_KEYCLOAK_REDIRECT_URI=https://insee-recette-edt.k8s.keyconsulting.fr/
REACT_APP_HOUSE_REFERENCE_REGULAR_EXPRESSION=.\$
Expand Down Expand Up @@ -1019,7 +1019,7 @@ Even if you create a path, it never passes through this component, so we cannot

The callbackHolder function recovers the data and the errors which give us lunatic.

![](https://imgur.com/SNpbvje.png)
![](./src/documentation/images/orchestrator_code.png)

The getData() function provided by lunatic, instead of returning it within callbackHolder, we proceed to process the data recovered by lunatic, to be able to transform that data, along with that of the database and obtain our data model filled with the COLLECTED and EDITED.

Expand All @@ -1038,9 +1038,7 @@ For each existing property :
- **value of COLLECTED:** data of lunatic *(callbackholder.getData()[prop].COLLECTED)*;



![](https://imgur.com/JCtEcUC.png)

![](./src/documentation/images/orchestrator_code_interviewer.png)

If the user is a reviewer, the data is treated as follows:

Expand Down Expand Up @@ -1076,11 +1074,11 @@ value of lunatic for value[iteration], other -> value of bdd (EDITED)
- **value of EDITED:** data of bbdd *(data[prop].EDITED)*;
- **value of COLLECTED:** data of bbdd *(data[prop].COLLECTED)*;

![](https://imgur.com/PNZL2hu.png)
![](./src/documentation/images/orchestrator_code_reviewer.png)

Here a diagram of the flow of orchestrator data

![Orchestrator data flow](https://imgur.com/yYYqvSJ.png)
![Orchestrator data flow](./src/documentation/images/orchestrator_flow.png)


## Maintenance and evolution
Expand Down
2 changes: 1 addition & 1 deletion e2e/mocks/activitySurveySource.json
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@
"name": "OTHERPRIVATE"
},
"id": "5",
"label": "\"Autre moyen privé (monorue,kk trottinette ou skate, bateau, électrique ou non...)\""
"label": "\"Autre moyen privé (monoroue, trottinette ou skate, bateau, électrique ou non...)\""
},
{
"response": {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "edt",
"version": "3.10.3",
"dateVersion": "09/01/2024",
"version": "3.12.4",
"dateVersion": "20/02/2024",
"licence": "MIT",
"dependencies": {
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@inseefr/lunatic": "2.0.7-v2",
"@inseefrlab/lunatic-edt": "^0.11.7",
"@inseefrlab/lunatic-edt": "^0.12.1",
"@mui/material": "^5.10.7",
"@mui/styles": "^5.12.0",
"@react-pdf/font": "2.2.0",
Expand Down Expand Up @@ -62,6 +62,7 @@
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"concurrently": "^7.4.0",
"dayjs": "^1.11.5",
"eslint": "^7.11.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-storybook": "^0.6.4",
Expand All @@ -75,8 +76,7 @@
"prettier": "^2.7.1",
"react-app-rewired": "^2.2.1",
"tsc-watch": "^5.0.3",
"typescript": "^4.8.3",
"dayjs": "^1.11.5"
"typescript": "^4.8.3"
},
"scripts": {
"start": "react-scripts start",
Expand Down
7 changes: 7 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ html, body {
min-height: 100vh;
overflow: hidden !important;
padding: 0 !important;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
border: none;
z-index: 2147483647;
}

#root {
Expand Down
77 changes: 35 additions & 42 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useTranslation } from "react-i18next";
import { EdtRoutes } from "routes/EdtRoutes";
import { getDatas, initializeDatas, initializeListSurveys } from "service/survey-service";
import { getUserRights, setAuth, setUser, setUserToken } from "service/user-service";

import { getCookie } from "utils/utils";
const App = () => {
const { t } = useTranslation();
const [initialized, setInitialized] = useState(false);
Expand All @@ -30,53 +30,46 @@ const App = () => {
};

useEffect(() => {
if (
window.location.search &&
getCookie("KC_RESTART") == null &&
localStorage.getItem("setauth") == null
) {
localStorage.setItem("setauth", "yes");
window.location.search = "";
}

if (auth?.userData?.access_token && getDatas().size === 0 && error === undefined) {
setUserToken(auth.userData?.access_token);
setUser(auth.userData);
}

setAuth(auth);
//keeps user token up to date after session renewal
auth.userManager?.events.addUserLoaded(() => {
auth.userManager.getUser().then(user => {
setUserToken(user?.access_token || "");
setAuth(auth);
//keeps user token up to date after session renewal
auth.userManager.events.addUserLoaded(() => {
auth.userManager.getUser().then(user => {
setUserToken(user?.access_token || "");
});
});
});

auth.userManager?.events.addSilentRenewError(() => {
if (navigator.onLine) {
auth.userManager
.signoutRedirect({
id_token_hint: getTokenHint(),
})
.then(() => auth.userManager.clearStaleState())
.then(() => auth.userManager.signoutRedirectCallback())
.then(() => {
sessionStorage.clear();
localStorage.clear();
})
.then(() => auth.userManager.clearStaleState())
.then(() => window.location.replace(process.env.REACT_APP_PUBLIC_URL || ""))
.catch(err => {
setErrorType(err);
});
}
});

auth.userManager?.settings.userStore.getAllKeys().then(keys => {
auth.userManager.settings.stateStore.getAllKeys().then(keysState => {
if (
window.location.search.includes("state") &&
auth.userData == null &&
keys.length == 0 &&
keysState.length == 0
) {
window.location.search = "";
auth.userManager.events.addSilentRenewError(() => {
if (navigator.onLine) {
auth.userManager
.signoutRedirect({
id_token_hint: getTokenHint(),
})
.then(() => auth.userManager.clearStaleState())
.then(() => auth.userManager.signoutRedirectCallback())
.then(() => {
sessionStorage.clear();
localStorage.clear();
})
.then(() => auth.userManager.clearStaleState())
.then(() => window.location.replace(process.env.REACT_APP_PUBLIC_URL || ""))
.catch(err => {
setErrorType(err);
});
}
});
});

if (auth.userData) {
initializeDatas(setError).then(() => {
setInitialized(true);
});
Expand All @@ -89,7 +82,7 @@ const App = () => {
}
}, [auth]);

const renderErrorOrLoadingPage = () => {
const errorOrLoadingPage = () => {
return !error ? (
<LoadingFull
message={t("page.home.loading.message")}
Expand All @@ -100,7 +93,7 @@ const App = () => {
);
};

return <>{initialized && !error ? <EdtRoutes /> : renderErrorOrLoadingPage()}</>;
return <>{initialized && !error ? <EdtRoutes /> : errorOrLoadingPage()}</>;
};

export default App;
26 changes: 25 additions & 1 deletion src/activity-survey.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,30 @@
"name": "ISLOCKED",
"componentRef": ""
},
{
"variableType": "COLLECTED",
"values": {
"COLLECTED": null,
"EDITED": null,
"INPUTED": null,
"FORCED": null,
"PREVIOUS": null
},
"name": "QUALITY_SCORE",
"componentRef": ""
},
{
"variableType": "COLLECTED",
"values": {
"COLLECTED": null,
"EDITED": null,
"INPUTED": null,
"FORCED": null,
"PREVIOUS": null
},
"name": "QUALITY_SCORE_SUBSTRACT_POINTS",
"componentRef": ""
},
{
"variableType": "CALCULATED",
"expression": "true",
Expand Down Expand Up @@ -907,7 +931,7 @@
"name": "OTHERPRIVATE"
},
"id": "5",
"label": "\"Autre moyen privé (monorue,kk trottinette ou skate, bateau, électrique ou non...)\""
"label": "\"Autre moyen privé (monoroue, trottinette ou skate, bateau, électrique ou non...)\""
},
{
"response": {
Expand Down
48 changes: 27 additions & 21 deletions src/assets/illustration/install/ios/edge2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/commons/InstallPageStep/InstallPageStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Box } from "@mui/material";
import InfoIcon from "assets/illustration/info.svg";
import { EdtRoutesNameEnum } from "enumerations/EdtRoutesNameEnum";
import { useCallback } from "react";
import { isMobile as isMobileDevice, isIOS } from "react-device-detect";
import { isIOS, isMobile as isMobileDevice } from "react-device-detect";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { getNavigatePath } from "service/navigation-service";
Expand Down
2 changes: 1 addition & 1 deletion src/components/commons/Responsive/Responsive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ const Default = ({ children }: ResponsiveProps) => {
return isNotMobile ? <>{children}</> : <></>;
};

export { Desktop, Tablet, Mobile, Default };
export { Default, Desktop, Mobile, Tablet };
Loading

0 comments on commit fbc439f

Please sign in to comment.