diff --git a/src/domain/usecases/RemoveRepeatableProgramStageUseCase.ts b/src/domain/usecases/RemoveRepeatableProgramStageUseCase.ts index db9b9ec..5aa0080 100644 --- a/src/domain/usecases/RemoveRepeatableProgramStageUseCase.ts +++ b/src/domain/usecases/RemoveRepeatableProgramStageUseCase.ts @@ -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); }); } diff --git a/src/webapp/components/survey/hook/useSurveyForm.ts b/src/webapp/components/survey/hook/useSurveyForm.ts index a7b6ce6..44538f4 100644 --- a/src/webapp/components/survey/hook/useSurveyForm.ts +++ b/src/webapp/components/survey/hook/useSurveyForm.ts @@ -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}`); } ); }