Skip to content

Commit

Permalink
fix: remove repeatable program stage
Browse files Browse the repository at this point in the history
  • Loading branch information
deeonwuli committed Dec 19, 2024
1 parent 41bdbc0 commit 5cf1aff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/domain/usecases/RemoveRepeatableProgramStageUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ export class RemoveRepeatableProgramStageUseCase {
//Repeatable Program Stages are only applicable to Prevalence Facility forms

const eventId = questionnaire.stages.find(stage => stage.id === stageId)?.instanceId;
const updatedQuestionnaire = Questionnaire.removeProgramStage(questionnaire, stageId);

if (!eventId)
return Future.error(new Error("Cannot find event Id correspoding to the stage"));
if (!eventId) {
return Future.success(updatedQuestionnaire);
}

return this.surveyRepository
.deleteEventSurvey(eventId, questionnaire.orgUnit.id, PREVALENCE_FACILITY_LEVEL_FORM_ID)
.flatMap(() => {
const updatedQuestionnaire = Questionnaire.removeProgramStage(
questionnaire,
stageId
);
return Future.success(updatedQuestionnaire);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/webapp/components/survey/hook/useSurveyForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function useSurveyForm(formType: SURVEY_FORM_TYPES, eventId: string | und
},
err => {
setLoading(false);
setError(err.message);
setError(`Cannot find event Id correspoding to the stage: ${err.message}`);
}
);
}
Expand Down

0 comments on commit 5cf1aff

Please sign in to comment.