Skip to content

Commit

Permalink
Merge branch 'v2-master' into v2-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentC35 committed Oct 17, 2023
2 parents 08e15b9 + cc707b7 commit 26eccca
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
20 changes: 19 additions & 1 deletion src/components/auth/provider/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<>
<h1 className=''>Vous avez été déconnecté.</h1>
<p>
Vos réponses ont été sauvegardées, vous pourrez ainsi compléter
ultèrieurement votre questionnaire.
</p>
<Button
onClick={() => {
window.location = window.location.href;
}}
>
Se reconnecter
</Button>
</>
);

const AuthenticatingErrorComponent = () => (
<h1>Erreur lors de l'authentification</h1>
);
Expand Down Expand Up @@ -56,7 +74,7 @@ export function AuthProvider({ children }) {
loadingComponent={LoaderSimple}
authenticatingComponent={LoaderSimple}
callbackSuccessComponent={LoaderSimple}
sessionLostComponent={LoaderSimple}
sessionLostComponent={SessionLostComponent}
authenticatingErrorComponent={AuthenticatingErrorComponent}
serviceWorkerNotSupportedComponent={ServiceWorkerNotSupportedComponent}
>
Expand Down
6 changes: 4 additions & 2 deletions src/components/orchestrator/collector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -299,6 +299,8 @@ export const Orchestrator = ({
);
};

export const Orchestrator = memo(OrchestratorComponent);

const useStyles = makeStyles((theme) => ({
root: {
flex: '1 1 auto',
Expand Down
19 changes: 12 additions & 7 deletions src/components/orchestrator/manager/orchestratorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import {
useAPI,
useAPIRemoteData,
useConstCallback,
useGetReferentiel,
} from '../../../utils/hooks';
import { useAuth, useAuthUser } from '../../../utils/oidc';
Expand All @@ -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 = () => {
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 26eccca

Please sign in to comment.