Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,13 @@ const MainActivityPage = () => {
);
},
nextClickCallback: (routeToGoal: boolean) => {
const codeActivity = getValueOfActivity(callbackHolder.getData(), currentIteration) ?? "";
const skip = filtrePage(EdtRoutesNameEnum.MAIN_ACTIVITY_GOAL, codeActivity);
// TODO: regarder comment update des données du callbackHolder directement à la sélection de l'activité

// Check if the user has selected an existing activity or created a new one
// If the user has selected an existing activity, the data is saved as intended during a lunatic loop
// If not, the save process is delayed to the next page (to go back into a lunatic loop)
const initialCodeActivity = getValueOfActivity(callbackHolder.getData(), currentIteration) ?? "";
const customActivityLabel = localStorage.getItem("selectionValue - label");
const loopNavigateFunction =
customActivityLabel !== null ? loopNavigate : saveAndLoopNavigate;

const codeActivity =
customActivityLabel !== null && customActivityLabel !== ""
? localStorage.getItem("selectedSuggesterIdNewActivity") ?? ""
: initialCodeActivity;

if (customActivityLabel !== null && customActivityLabel !== "") {
setValue(
Expand Down Expand Up @@ -177,11 +174,18 @@ const MainActivityPage = () => {
);

saveData(idSurvey, data, true, true).then(() => {
//Clean history to avoid data overflow
// Clean history to avoid data overflow
localStorage.removeItem("historyInputSuggester");
});
}
if (routeToGoal && !skip) {

const loopNavigateFunction =
customActivityLabel !== null && customActivityLabel !== ""
? loopNavigate
: saveAndLoopNavigate;

const skipToGoal = filtrePage(EdtRoutesNameEnum.MAIN_ACTIVITY_GOAL, codeActivity);
if (routeToGoal && !skipToGoal) {
loopNavigateFunction(
idSurvey,
context.source,
Expand All @@ -190,11 +194,13 @@ const MainActivityPage = () => {
currentIteration,
);
} else {
const skip = filtrePage(EdtRoutesNameEnum.SECONDARY_ACTIVITY, codeActivity);
const skipToSecondary = filtrePage(EdtRoutesNameEnum.SECONDARY_ACTIVITY, codeActivity);
loopNavigateFunction(
idSurvey,
context.source,
skip ? EdtRoutesNameEnum.ACTIVITY_LOCATION : getNextLoopPage(currentPage),
skipToSecondary
? EdtRoutesNameEnum.ACTIVITY_LOCATION
: getNextLoopPage(currentPage),
LoopEnum.ACTIVITY_OR_ROUTE,
currentIteration,
);
Expand Down
14 changes: 7 additions & 7 deletions src/service/loop-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ const ignoreDepsOfCheckboxGroup = (
};

const filtrePage = (page: EdtRoutesNameEnum, activityCode: string) => {
let codesToIgnore;

let listToIgnore: string[] = [];

const activityCodeOrSuggesterCode =
activityCode.split("-").length > 1 ? activityCode.split("-")[0] : activityCode;

switch (page) {

case EdtRoutesNameEnum.MAIN_ACTIVITY_GOAL:
listToIgnore = CODES_ACTIVITY_IGNORE_GOAL;
break;
Expand All @@ -305,7 +305,7 @@ const filtrePage = (page: EdtRoutesNameEnum, activityCode: string) => {
break;
}

codesToIgnore = getAllCodesFromActivitiesCodes(listToIgnore);
const codesToIgnore = getAllCodesFromActivitiesCodes(listToIgnore);
const exist = codesToIgnore.indexOf(activityCodeOrSuggesterCode) >= 0;
return exist;
};
Expand Down Expand Up @@ -499,10 +499,10 @@ const findItemInCategoriesNomenclature = (
parent?: NomenclatureActivityOption,
):
| {
item: NomenclatureActivityOption;
parent: NomenclatureActivityOption | undefined;
index?: number;
}
item: NomenclatureActivityOption;
parent: NomenclatureActivityOption | undefined;
index?: number;
}
| undefined => {
let res = referentiel.find(a => a.id === id);
if (res) {
Expand Down
Loading