From 4b0a04e70a95a208c3959af6d69efeda0c83823c Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Thu, 17 Oct 2024 12:56:17 +0530 Subject: [PATCH] fix: create event tracker fix --- .../disease-outbreak/SaveDiseaseOutbreak.ts | 9 ++++--- src/webapp/pages/form-page/useForm.ts | 27 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/domain/usecases/utils/disease-outbreak/SaveDiseaseOutbreak.ts b/src/domain/usecases/utils/disease-outbreak/SaveDiseaseOutbreak.ts index c43aee08..098de46c 100644 --- a/src/domain/usecases/utils/disease-outbreak/SaveDiseaseOutbreak.ts +++ b/src/domain/usecases/utils/disease-outbreak/SaveDiseaseOutbreak.ts @@ -17,12 +17,13 @@ export function saveDiseaseOutbreak( teamMemberRepository: TeamMemberRepository; roleRepository: RoleRepository; }, - diseaseOutbreakEventBaseAttrs: DiseaseOutbreakEventBaseAttrs + diseaseOutbreakEvent: DiseaseOutbreakEventBaseAttrs ): FutureData { return repositories.diseaseOutbreakEventRepository - .save(diseaseOutbreakEventBaseAttrs) - .flatMap(() => { - return saveIncidentManagerTeamMemberRole(repositories, diseaseOutbreakEventBaseAttrs); + .save(diseaseOutbreakEvent) + .flatMap((diseaseOutbreakId: Id) => { + const diseaseOutbreakEventWithId = { ...diseaseOutbreakEvent, id: diseaseOutbreakId }; + return saveIncidentManagerTeamMemberRole(repositories, diseaseOutbreakEventWithId); }); } diff --git a/src/webapp/pages/form-page/useForm.ts b/src/webapp/pages/form-page/useForm.ts index 09c89371..c257b191 100644 --- a/src/webapp/pages/form-page/useForm.ts +++ b/src/webapp/pages/form-page/useForm.ts @@ -69,7 +69,8 @@ export function useForm(formType: FormType, id?: Id): State { const currentEventTracker = getCurrentEventTracker(); useEffect(() => { - if (currentEventTrackerState?.id === currentEventTracker?.id) return; + if (currentEventTracker?.id && currentEventTrackerState?.id === currentEventTracker?.id) + return; compositionRoot.getWithOptions.execute(formType, currentEventTracker, id).run( formData => { @@ -337,20 +338,18 @@ export function useForm(formType: FormType, id?: Id): State { id: currentEventTracker.id, }); break; + + case "incident-action-plan": + case "incident-response-action": + goTo(RouteName.INCIDENT_ACTION_PLAN, { + id: currentEventTracker.id, + }); + break; default: - switch (formType) { - case "incident-action-plan": - case "incident-response-action": - goTo(RouteName.INCIDENT_ACTION_PLAN, { - id: currentEventTracker.id, - }); - break; - default: - goTo(RouteName.EVENT_TRACKER, { - id: currentEventTracker.id, - }); - break; - } + goTo(RouteName.EVENT_TRACKER, { + id: currentEventTracker.id, + }); + break; } } else { goTo(RouteName.DASHBOARD);