From 1f493091d7fbf75aae2f058616dfd20b5429a373 Mon Sep 17 00:00:00 2001 From: Laurent Caouissin Date: Tue, 17 Oct 2023 11:18:47 +0200 Subject: [PATCH 1/3] feat: add "SessionLostComponent" --- src/components/auth/provider/component.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/auth/provider/component.js b/src/components/auth/provider/component.js index 056d3182..0a83cc08 100644 --- a/src/components/auth/provider/component.js +++ b/src/components/auth/provider/component.js @@ -5,8 +5,26 @@ import { useRef, useState } from 'react'; import { OIDC, READ_ONLY } from '../../../utils/constants'; import { useAsyncEffect } from '../../../utils/hooks/useAsyncEffect'; import { environment, oidcConf } from '../../../utils/read-env-vars'; +import { Button } from '../../designSystem'; import { LoaderSimple } from '../../shared/loader'; +const SessionLostComponent = () => ( + <> +

Vous avez été déconnecté.

+

+ Vos réponses ont été sauvegardées, vous pourrez ainsi compléter + ultèrieurement votre questionnaire. +

+ + +); + const AuthenticatingErrorComponent = () => (

Erreur lors de l'authentification

); @@ -56,7 +74,7 @@ export function AuthProvider({ children }) { loadingComponent={LoaderSimple} authenticatingComponent={LoaderSimple} callbackSuccessComponent={LoaderSimple} - sessionLostComponent={LoaderSimple} + sessionLostComponent={SessionLostComponent} authenticatingErrorComponent={AuthenticatingErrorComponent} serviceWorkerNotSupportedComponent={ServiceWorkerNotSupportedComponent} > From e37d62970f7a28c10aea1a3073edb3125627c557 Mon Sep 17 00:00:00 2001 From: Laurent Caouissin Date: Tue, 17 Oct 2023 11:20:58 +0200 Subject: [PATCH 2/3] fix: prevent useless re-render --- .../orchestrator/collector/index.js | 6 ++++-- .../manager/orchestratorManager.js | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/orchestrator/collector/index.js b/src/components/orchestrator/collector/index.js index ac748674..618f7770 100644 --- a/src/components/orchestrator/collector/index.js +++ b/src/components/orchestrator/collector/index.js @@ -2,7 +2,7 @@ import * as lunatic from '@inseefr/lunatic'; import Card from '@material-ui/core/Card'; import Container from '@material-ui/core/Container'; import { makeStyles } from '@material-ui/core/styles'; -import { useCallback, useEffect, useRef, useState } from 'react'; +import { memo, useCallback, useEffect, useRef, useState } from 'react'; import { simpleLog } from '../../../utils/events'; import { END_PAGE, @@ -23,7 +23,7 @@ import '../custom-lunatic.scss'; import { ButtonsNavigation } from '../navigation'; import { StyleWrapper } from '../styleWrapper'; -export const Orchestrator = ({ +const OrchestratorComponent = ({ source, logoutAndClose: quit, stromaeData, @@ -299,6 +299,8 @@ export const Orchestrator = ({ ); }; +export const Orchestrator = memo(OrchestratorComponent); + const useStyles = makeStyles((theme) => ({ root: { flex: '1 1 auto', diff --git a/src/components/orchestrator/manager/orchestratorManager.js b/src/components/orchestrator/manager/orchestratorManager.js index b0e1899d..9f19ce4e 100644 --- a/src/components/orchestrator/manager/orchestratorManager.js +++ b/src/components/orchestrator/manager/orchestratorManager.js @@ -16,6 +16,7 @@ import { import { useAPI, useAPIRemoteData, + useConstCallback, useGetReferentiel, } from '../../../utils/hooks'; import { useAuth, useAuthUser } from '../../../utils/oidc'; @@ -32,6 +33,10 @@ const useStyles = makeStyles((theme) => ({ }, })); +const preferences = ['COLLECTED']; +const features = ['VTL', 'MD']; +const savingType = 'COLLECTED'; + const { PORTAIL_URL: portail } = environment; const OrchestratorManager = () => { @@ -58,7 +63,7 @@ const OrchestratorManager = () => { const [errorSending, setErrorSending] = useState(null); - const sendData = async (dataToSave) => { + const sendData = useConstCallback(async (dataToSave) => { if (!readonly) { const { data, stateData } = dataToSave; const { /*status,*/ error: dataError } = await putData(data); @@ -71,11 +76,11 @@ const OrchestratorManager = () => { if (paradataPostError) setErrorSending('Error during sending'); LOGGER.clear(); } - }; + }); - const logoutAndClose = () => { + const logoutAndClose = useConstCallback(() => { logout(`${portail}/${getCurrentSurvey(window.location.href)}`); - }; + }); useEffect(() => { if (isAuthenticated && questionnaire) { @@ -109,9 +114,9 @@ const OrchestratorManager = () => { autoSuggesterLoading={true} getReferentiel={getReferentiel} save={sendData} - savingType='COLLECTED' - preferences={['COLLECTED']} - features={['VTL', 'MD']} + savingType={savingType} + preferences={preferences} + features={features} pagination={true} activeControls={true} readonly={readonly} From e611ec6f94fdd7ef54b18db0c9aca95a2aaf44e6 Mon Sep 17 00:00:00 2001 From: Laurent Caouissin Date: Tue, 17 Oct 2023 11:21:32 +0200 Subject: [PATCH 3/3] build: bumb version to 2.4.11 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eff10c83..d6512fb1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stromae", - "version": "2.4.10", + "version": "2.4.11", "description": "Web application for the management of questionnaires powered by Lunatic", "repository": { "type": "git",