Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
update queen-v2 & bump version
Browse files Browse the repository at this point in the history
03a16be

fwt
  • Loading branch information
ddecrulle committed Apr 14, 2023
1 parent eed1ce5 commit 7043c9e
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 97 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
docker_drama:
needs: check_if_version_upgraded
environment: Main
if: needs.check_if_version_upgraded.outputs.is_drama_upgraded_version
if: needs.check_if_version_upgraded.outputs.is_drama_upgraded_version == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -108,7 +108,7 @@ jobs:
docker_queen:
needs: check_if_version_upgraded
environment: Main
if: needs.check_if_version_upgraded.outputs.is_queen_upgraded_version
if: needs.check_if_version_upgraded.outputs.is_queen_upgraded_version == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -132,7 +132,7 @@ jobs:
docker_queen_v2:
needs: check_if_version_upgraded
environment: Main
if: needs.check_if_version_upgraded.outputs.is_queen_v2_upgraded_version
if: needs.check_if_version_upgraded.outputs.is_queen_v2_upgraded_version == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -156,7 +156,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs: check_if_version_upgraded
if: needs.check_if_version_upgraded.outputs.is_upgraded_version
if: needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true'
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion drama-queen/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "drama-queen",
"private": true,
"version": "0.1.1",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite --port 5000 --strictPort",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "drama-queen-container",
"private": true,
"version": "1.0.1",
"version": "1.0.0",
"workspaces": [
"drama-queen",
"queen-v2",
Expand Down
4 changes: 2 additions & 2 deletions queen-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "queen-v2",
"version": "1.0.0-fix-nginx",
"version": "1.0.0-03a16be",
"description": "Web application for the management of questionnaires powered by Lunatic",
"repository": {
"type": "git",
Expand All @@ -12,7 +12,7 @@
"dependencies": {
"@axa-fr/react-oidc-context": "^3.1.6",
"@craco/craco": "^6.4.0",
"@inseefr/lunatic": "2.0.7-v2-main-2023-02-28-14-48-47",
"@inseefr/lunatic": "2.4.1",
"@inseefr/trevas": "^0.1.16",
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
Expand Down
18 changes: 7 additions & 11 deletions queen-v2/src/components/lightOrchestrator/lightOrchestrator.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import * as lunatic from '@inseefr/lunatic';

import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useAsyncValue, useLunaticFetcher } from 'utils/hook';
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';

import D from 'i18n';
import { componentHasResponse } from 'utils/components/deduceState';
import { LoopPanel } from './LoopPanel';
import ButtonContinue from './buttons/continue/index';
import { ComponentDisplayer } from './componentDisplayer';
import D from 'i18n';
import Header from './header';
import { LoopPanel } from './LoopPanel';
import NavBar from './navBar';
import { componentHasResponse } from 'utils/components/deduceState';
import { useStyles } from './lightOrchestrator.style';
import NavBar from './navBar';

function onLogChange(response, value, args) {
console.log('onChange', { response, value, args });
Expand All @@ -32,7 +31,7 @@ function LightOrchestrator({
readonly,
pagination,
source,
suggesters,
getReferentiel,
missing = true,
shortcut = true,
autoSuggesterLoading,
Expand All @@ -44,8 +43,6 @@ function LightOrchestrator({
definitiveQuit,
}) {
const { data } = surveyUnit;
const { lunaticFetcher } = useLunaticFetcher();
const suggesterFetcher = useAsyncValue(lunaticFetcher);
const classes = useStyles();
const lunaticStateRef = useRef();

Expand Down Expand Up @@ -87,8 +84,7 @@ function LightOrchestrator({
onChange: customHandleChange,
preferences,
autoSuggesterLoading,
suggesters,
suggesterFetcher,
getReferentiel,
missing,
shortcut,
missingStrategy,
Expand Down
28 changes: 12 additions & 16 deletions queen-v2/src/components/orchestratorManager/orchestratorManager.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { COMPLETED, VALIDATED, useQuestionnaireState } from 'utils/hook/questionnaire';
import { EventsManager, INIT_ORCHESTRATOR_EVENT, INIT_SESSION_EVENT } from 'utils/events';
import { ORCHESTRATOR_COLLECT, ORCHESTRATOR_READONLY, READ_ONLY } from 'utils/constants';
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { useAPI, useAPIRemoteData, useAuth } from 'utils/hook';
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom';
import { ORCHESTRATOR_COLLECT, ORCHESTRATOR_READONLY, READ_ONLY } from 'utils/constants';
import { EventsManager, INIT_ORCHESTRATOR_EVENT, INIT_SESSION_EVENT } from 'utils/events';
import { useAPI, useAPIRemoteData, useAuth, useGetReferentiel } from 'utils/hook';
import { COMPLETED, VALIDATED, useQuestionnaireState } from 'utils/hook/questionnaire';

import { AppContext } from 'components/app';
import Error from 'components/shared/Error';
import LightOrchestrator from 'components/lightOrchestrator';
import Error from 'components/shared/Error';
import NotFound from 'components/shared/not-found';
import Preloader from 'components/shared/preloader';
import { buildSuggesterFromNomenclatures } from 'utils/questionnaire/nomenclatures';
import { checkQuestionnaire } from 'utils/questionnaire';
import paradataIdbService from 'utils/indexedbb/services/paradata-idb-service';
import { sendCloseEvent } from 'utils/communication';
import paradataIdbService from 'utils/indexedbb/services/paradata-idb-service';
import surveyUnitIdbService from 'utils/indexedbb/services/surveyUnit-idb-service';
import { checkQuestionnaire } from 'utils/questionnaire';

export const OrchestratorManager = () => {
const { standalone, apiUrl } = useContext(AppContext);
Expand All @@ -41,7 +40,7 @@ export const OrchestratorManager = () => {
const { oidcUser } = useAuth();
const isAuthenticated = !!oidcUser?.profile;

const [suggesters, setSuggesters] = useState(null);
const { getReferentiel } = useGetReferentiel();
const [init, setInit] = useState(false);

const [error, setError] = useState(null);
Expand All @@ -66,14 +65,11 @@ export const OrchestratorManager = () => {
}, [isAuthenticated, LOGGER, questionnaire]);

useEffect(() => {
if (!init && questionnaire && surveyUnit && nomenclatures) {
if (!init && questionnaire && surveyUnit) {
const { valid, error: questionnaireError } = checkQuestionnaire(questionnaire);
if (valid) {
setSource(questionnaire);
const suggestersBuilt = buildSuggesterFromNomenclatures(apiUrl)(nomenclatures);
setSuggesters(suggestersBuilt);
setInit(true);
console.log('suggesters injection done');
LOGGER.log(INIT_ORCHESTRATOR_EVENT);
} else {
setError(questionnaireError);
Expand Down Expand Up @@ -167,11 +163,11 @@ export const OrchestratorManager = () => {
{![READ_ONLY, undefined].includes(readonlyParam) && <NotFound />}
{loadingMessage && <Preloader message={loadingMessage} />}
{error && <Error message={error} />}
{!loadingMessage && !error && source && surveyUnit && suggesters && (
{!loadingMessage && !error && source && surveyUnit && (
<LightOrchestrator
surveyUnit={surveyUnit}
source={source}
suggesters={suggesters}
getReferentiel={getReferentiel}
autoSuggesterLoading={true}
standalone={standalone}
readonly={readonly}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AppVersion, Button } from 'components/designSystem';
import {
Checkbox,
Container,
Expand All @@ -7,19 +6,21 @@ import {
Typography,
makeStyles,
} from '@material-ui/core';
import { AppVersion, Button } from 'components/designSystem';
import { useEffect, useState } from 'react';
import {
DATA_EXAMPLE_URL,
DEFAULT_DATA_URL,
DEFAULT_NOMENCLATURE_URL,
NOMENCLATURE_EXAMPLE_URL,
QUESTIONNAIRE_EXAMPLE_URL,
SIMPSONS,
} from 'utils/constants';
import React, { useEffect, useState } from 'react';

import D from 'i18n';
import { useHistory } from 'react-router-dom';
import Examples from './examples';
import Helper from './helper';
import { useHistory } from 'react-router-dom';

const useStyles = makeStyles(theme => ({
root: {
Expand Down Expand Up @@ -58,6 +59,7 @@ const QuestionnaireForm = () => {
useEffect(() => {
setQuestionnaire(selected ? QUESTIONNAIRE_EXAMPLE_URL(selected) : selected);
setData(selected ? DATA_EXAMPLE_URL(selected) : selected);
setNomenclature(selected ? NOMENCLATURE_EXAMPLE_URL(selected) : selected);
}, [selected]);

const history = useHistory();
Expand Down Expand Up @@ -115,7 +117,7 @@ const QuestionnaireForm = () => {
<TextField
id="nomenclature-url-form"
label={D.labelNomenclature}
placeholder={JSON.stringify(DEFAULT_NOMENCLATURE_URL)}
placeholder={DEFAULT_NOMENCLATURE_URL}
helperText={D.helperTextNomenclature}
fullWidth
margin="normal"
Expand Down
28 changes: 13 additions & 15 deletions queen-v2/src/components/visualizer/visualizer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useCallback, useContext, useEffect, useState } from 'react';
import { useGetReferentiel, useRemoteData, useVisuQuery } from 'utils/hook';
import { checkQuestionnaire, downloadDataAsJson } from 'utils/questionnaire';
import { useRemoteData, useVisuQuery } from 'utils/hook';

import { AppContext } from 'components/app';
import Error from 'components/shared/Error';
import LightOrchestrator from 'components/lightOrchestrator';
import Error from 'components/shared/Error';
import Preloader from 'components/shared/preloader';
import QuestionnaireForm from './questionnaireForm';
import { buildSuggesterFromNomenclatures } from 'utils/questionnaire/nomenclatures';
import surveyUnitIdbService from 'utils/indexedbb/services/surveyUnit-idb-service';
import { useHistory } from 'react-router';
import surveyUnitIdbService from 'utils/indexedbb/services/surveyUnit-idb-service';
import QuestionnaireForm from './questionnaireForm';

const Visualizer = () => {
const { apiUrl, standalone } = useContext(AppContext);
Expand All @@ -18,16 +17,16 @@ const Visualizer = () => {
const [error, setError] = useState(null);
const [source, setSource] = useState(null);

const { questionnaireUrl, dataUrl, readonly } = useVisuQuery();
const { questionnaireUrl, dataUrl, nomenclatures, readonly } = useVisuQuery();
const {
surveyUnit: suData,
questionnaire,
nomenclatures,
loadingMessage,
errorMessage,
} = useRemoteData(questionnaireUrl, dataUrl);

const [suggesters, setSuggesters] = useState(null);
const { getReferentielForVizu } = useGetReferentiel(nomenclatures);

const history = useHistory();

useEffect(() => {
Expand All @@ -45,17 +44,15 @@ const Visualizer = () => {
}, [suData]);

useEffect(() => {
if (questionnaireUrl && questionnaire && suData && nomenclatures) {
if (questionnaireUrl && questionnaire && suData) {
const { valid, error: questionnaireError } = checkQuestionnaire(questionnaire);
if (valid) {
setSource(questionnaire);
const suggestersBuilt = buildSuggesterFromNomenclatures(apiUrl)(nomenclatures);
setSuggesters(suggestersBuilt);
} else {
setError(questionnaireError);
}
}
}, [questionnaireUrl, questionnaire, suData, apiUrl, nomenclatures]);
}, [questionnaireUrl, questionnaire, suData, apiUrl]);

useEffect(() => {
if (errorMessage) setError(errorMessage);
Expand Down Expand Up @@ -85,11 +82,12 @@ const Visualizer = () => {
<>
{loadingMessage && <Preloader message={loadingMessage} />}
{error && <Error message={error} />}
{questionnaireUrl && source && surveyUnit && suggesters && (
{questionnaireUrl && source && surveyUnit && (
<LightOrchestrator
surveyUnit={surveyUnit}
source={source}
suggesters={suggesters}
autoSuggesterLoading={true}
getReferentiel={getReferentielForVizu}
standalone={standalone}
readonly={readonly}
pagination={true}
Expand Down
4 changes: 2 additions & 2 deletions queen-v2/src/utils/api/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export const fetcher = async (url, token, method, body) => {
}
};

export const getFetcherForLunatic = token => async (url, options) => {
export const getFetcherForLunatic = token => (url, options) => {
const otherHeader = options?.headers || {};
return fetch(url, {
...options,
headers: token ? { ...otherHeader, Authorization: `Bearer ${token}` } : otherHeader,
});
}).then(r => r.json());
};
Loading

0 comments on commit 7043c9e

Please sign in to comment.