Skip to content

Commit

Permalink
fix: nomenclatures files not read properly
Browse files Browse the repository at this point in the history
  • Loading branch information
MailineN committed Aug 5, 2024
1 parent 22974fe commit b0f9f3f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/assets/surveyData/edtNomenclatures/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export { default as edtActivityAutoComplete } from "./edtActivityAutoComplete.json";
export { default as edtActivityCategory } from "./edtActivityCategory.json";
export { default as edtActivityGoal } from "./edtActivityGoal.json";
export { default as edtActivitySecondaryActivity } from "./edtActivitySecondaryActivity.json";
export { default as edtKindOfDay } from "./edtKindOfDay.json";
export { default as edtKindOfWeek } from "./edtKindOfWeek.json";
export { default as edtMeanOfTransport } from "./edtMeanOfTransport.json";
export { default as edtPlace } from "./edtPlace.json";
export { default as edtRoute } from "./edtRoute.json";
export { default as edtRouteSecondaryActivity } from "./edtRouteSecondaryActivity.json";
export { default as edtWorkingPlace } from "./edtWorkingPlace.json";
12 changes: 0 additions & 12 deletions src/assets/surveyData/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
export { default as edtActivitySurvey } from "./edtActivitySurvey.json";
export { default as edtWorkTimeSurvey } from "./edtWorkTimeSurvey.json";

export { default as edtActivityAutoComplete } from "./edtNomenclatures/edtActivityAutoComplete.json";
export { default as edtActivityCategory } from "./edtNomenclatures/edtActivityCategory.json";
export { default as edtActivityGoal } from "./edtNomenclatures/edtActivityGoal.json";
export { default as edtActivitySecondaryActivity } from "./edtNomenclatures/edtActivitySecondaryActivity.json";
export { default as edtKindOfDay } from "./edtNomenclatures/edtKindOfDay.json";
export { default as edtKindOfWeek } from "./edtNomenclatures/edtKindOfWeek.json";
export { default as edtMeanOfTransport } from "./edtNomenclatures/edtMeanOfTransport.json";
export { default as edtPlace } from "./edtNomenclatures/edtPlace.json";
export { default as edtRoute } from "./edtNomenclatures/edtRoute.json";
export { default as edtRouteSecondaryActivity } from "./edtNomenclatures/edtRouteSecondaryActivity.json";
export { default as edtWorkingPlace } from "./edtNomenclatures/edtWorkingPlace.json";
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const LoopSurveyPageStep = (props: LoopSurveyPageStepProps) => {
const currentIteration = paramIteration ? +paramIteration : 0;
const isRoute = getValue(idSurvey, FieldNameEnum.ISROUTE, currentIteration) as boolean;
const stepData = getStepData(currentPage, isRoute);
console.log("stepData", stepData);
const modifiable = !surveyReadOnly(context.rightsSurvey);
const IconError = errorIcon as React.FunctionComponent<React.SVGProps<SVGSVGElement>>;

Expand Down Expand Up @@ -112,7 +113,7 @@ const LoopSurveyPageStep = (props: LoopSurveyPageStepProps) => {
modifiable: modifiable,
idSurvey: idSurvey,
};

console.log("Context", context);
const loopSurveyPageProps = {
onNext: useCallback((e: React.MouseEvent) => onNext(e, setNextClickEvent), [nextClickEvent]),
onPrevious: useCallback(
Expand Down
12 changes: 12 additions & 0 deletions src/orchestrator/Orchestrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,18 @@ export const OrchestratorForStories = (props: OrchestratorProps) => {
{components.map(function (component: any) {
const { id, componentType, response, options, value, ...other } = component;
const Component = lunatic[componentType];
console.log("response", response);
console.log(
"variables",
getVariables(
data,
getDataLocal(),
iteration,
getBindingDependencies(components),
value,
source,
),
);
return (
<div className="lunatic lunatic-component" key={`component-${id}`}>
<Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
onClose,
onNext,
onPrevious,
saveAndLoopNavigate,
saveAndLoopNavigateLocally,

Check warning on line 19 in src/pages/activity/activity-or-route-planner/activity/main-activity/MainActivity.tsx

View workflow job for this annotation

GitHub Actions / test_lint

'saveAndLoopNavigateLocally' is defined but never used
setEnviro,
validateLocally,
Expand Down Expand Up @@ -119,7 +120,7 @@ const MainActivityPage = () => {
backClickEvent: backClickEvent,
nextClickEvent: nextClickEvent,
backClickCallback: () => {
saveAndLoopNavigateLocally(
saveAndLoopNavigate(
idSurvey,
context.source,
getPreviousLoopPage(currentPage),
Expand All @@ -129,9 +130,10 @@ const MainActivityPage = () => {
},
nextClickCallback: (routeToGoal: boolean) => {
const codeActivity = getValueOfActivity(callbackHolder.getData(), currentIteration) ?? "";
console.log("codeActivity", codeActivity);
const skip = filtrePage(EdtRoutesNameEnum.MAIN_ACTIVITY_GOAL, codeActivity);
if (routeToGoal && !skip) {
saveAndLoopNavigateLocally(
saveAndLoopNavigate(
idSurvey,
context.source,
EdtRoutesNameEnum.MAIN_ACTIVITY_GOAL,
Expand All @@ -140,7 +142,7 @@ const MainActivityPage = () => {
);
} else {
const skip = filtrePage(EdtRoutesNameEnum.SECONDARY_ACTIVITY, codeActivity);
saveAndLoopNavigateLocally(
saveAndLoopNavigate(
idSurvey,
context.source,
skip ? EdtRoutesNameEnum.ACTIVITY_LOCATION : getNextLoopPage(currentPage),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ const SecondaryActivitySelectionPage = () => {
const paramIteration = useParams().iteration;
const currentIteration = paramIteration ? +paramIteration : 0;
const isRoute = getValue(idSurvey, FieldNameEnum.ISROUTE, currentIteration) as boolean;
console.log("isRoute", isRoute);
const referentiel = isRoute ? getRouteSecondaryActivityRef() : getActivitySecondaryActivityRef();
console.log("referentiel", referentiel);
const newActivities = getNewSecondaryActivities(idSurvey, referentiel);
console.log("newActivities", newActivities);
const modifiable = !surveyReadOnly(context.rightsSurvey);

const iconAddAlt = t("accessibility.asset.mui-icon.add");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const WithScreenPage = () => {
getOrchestratorPage(EdtRoutesNameEnum.ACTIVITY_OR_ROUTE_PLANNER),
context.source,
),
undefined,
undefined,
undefined,
true,
);
},
onSelectValue: () => {
Expand All @@ -92,12 +96,17 @@ const WithScreenPage = () => {
getOrchestratorPage(EdtRoutesNameEnum.ACTIVITY_OR_ROUTE_PLANNER),
context.source,
),
undefined,
undefined,
undefined,
true,
);
});
},
labels: getLabels("with-screen-selecter"),
errorIcon: <ErrorIcon />,
};
console.log("Final data with screen : ", context.data);
return (
<LoopSurveyPage
onNext={useCallback((e: React.MouseEvent) => onNext(e, setNextClickEvent), [nextClickEvent])}
Expand Down
3 changes: 2 additions & 1 deletion src/service/api-service/getLocalSurveyData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
edtPlace,
edtRoute,
edtRouteSecondaryActivity,
} from "assets/surveyData";
} from "assets/surveyData/edtNomenclatures";

const fetchReferentiel = (auth: AuthContextProps, idReferentiel: ReferentielsEnum) => {
console.log("fetchReferentiel", { data: idReferentiel });
return Promise.resolve({ data: idReferentiel });
};

Expand Down
2 changes: 2 additions & 0 deletions src/service/navigation-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
} from "service/survey-service";
import { getLastPageStep } from "./stepper.service";
import { surveyReadOnly } from "./survey-activity-service";
import { get } from "lodash";

Check warning on line 33 in src/service/navigation-service.ts

View workflow job for this annotation

GitHub Actions / test_lint

'get' is defined but never used

let _context: OrchestratorContext;
let _navigate: NavigateFunction;
Expand Down Expand Up @@ -208,6 +209,7 @@ const saveAndNav = (
currentIteration?: number,
forceUpdate?: boolean,
): void => {
forceUpdate ?? console.log("saveAndNav", getData(idSurvey));
saveData(idSurvey, getData(idSurvey), forceUpdate).then(() => {
navToRouteOrRouteNotSelection(idSurvey, route, value, routeNotSelection, currentIteration);
});
Expand Down
3 changes: 3 additions & 0 deletions src/service/survey-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const initializeRefs = () => {
return lunaticDatabase.get(REFERENTIELS_ID).then(refData => {
if (!refData && navigator.onLine) {
return fetchReferentiels().then(refs => {
console.log("refs", refs);
return saveReferentiels(refs);
});
} else {
Expand Down Expand Up @@ -1092,6 +1093,7 @@ const getSurveyStateData = (data: LunaticData, idSurvey: string): StateData => {
const saveReferentiels = (data: ReferentielData): Promise<ReferentielData> => {
return lunaticDatabase.save(REFERENTIELS_ID, data).then(() => {
referentielsData = data;
console.log("saveReferentiels", referentielsData);
return data;
});
};
Expand Down Expand Up @@ -1156,6 +1158,7 @@ const getNewSecondaryActivities = (idSurvey: string, referentiel: CheckboxOneCus

let listSecondaryActivities = referentiel;
listSecondaryActivitiesIds?.forEach((id: string, index: number) => {
console.log("id", id);
const existActivity = referentiel.find(ref => ref.value == id) != null;
if (validate(id) && !existActivity) {
const newActivity = {
Expand Down

0 comments on commit b0f9f3f

Please sign in to comment.