From 7bee420f696cb5de78480cd0c3fc04f007663eeb Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Sun, 24 Nov 2024 13:12:02 +0530 Subject: [PATCH] Issue feat:Resolve observation Id issue for first time login user --- src/pages/observation/[observationId]/index.tsx | 15 ++++++++++----- src/pages/observation/index.tsx | 11 ++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/pages/observation/[observationId]/index.tsx b/src/pages/observation/[observationId]/index.tsx index b46b7a77..1c15b509 100644 --- a/src/pages/observation/[observationId]/index.tsx +++ b/src/pages/observation/[observationId]/index.tsx @@ -70,6 +70,8 @@ const ObservationDetails = () => { const [entityData, setEntityData] = useState([]); const [filteredEntityData, setFilteredEntityData] = useState([]); const [loading, setLoading] = React.useState(false); + const [observationId, setObservationId] = React.useState(""); + @@ -193,6 +195,7 @@ const ObservationDetails = () => { { console.log("entityIds?.length", entities?.length); const response = await fetchEntities({ solutionId }); + setObservationId(response?.result?._id) setFetchEntityResponse(response?.result?.entities) entities = response?.result?.entities?.map( (item: any) => item?._id @@ -274,8 +277,6 @@ setFilteredEntityData(result) }; const executeAddEntities = async () => { - if (Id) { - const observationId = Id; if (entity === ObservationEntityType.CENTER && unmatchedCohortIds.length !== 0) { await addEntities({ data, observationId }); const urlPath = window.location.pathname; @@ -283,6 +284,8 @@ setFilteredEntityData(result) const solutionId = urlPath.split('/observation/')[1]; const response = await fetchEntities({ solutionId }); + setObservationId(response?.result?._id) + setFetchEntityResponse(response?.result?.entities) } else if (unmatchedUserIds.length !== 0) { await addEntities({ data, observationId }); @@ -291,15 +294,17 @@ setFilteredEntityData(result) const solutionId = urlPath.split('/observation/')[1]; const response = await fetchEntities({ solutionId }); + setObservationId(response?.result?._id) + setFetchEntityResponse(response?.result?.entities) } - } + }; executeAddEntities(); } - }, [entityIds, Data]); + }, [entityIds, Data,observationId]); @@ -420,7 +425,7 @@ setFilteredEntityData(result) const { Id } = router.query; - const queryParams = { entityId: cohortId, Id: Id , observationName: observationName }; + const queryParams = { entityId: cohortId, Id: observationId , observationName: observationName }; router.push({ pathname: newFullPath, query: queryParams, diff --git a/src/pages/observation/index.tsx b/src/pages/observation/index.tsx index 579fac93..7c43f6fa 100644 --- a/src/pages/observation/index.tsx +++ b/src/pages/observation/index.tsx @@ -81,7 +81,16 @@ const ObservationForms: React.FC = () => { const [basePath, queryString] = fullPath.split('?'); const newRoute = `/${observationId}`; let newFullPath = `${basePath}${newRoute}`; - const queryParams = { entity: entity, observationName: observationName, Id: id }; + let queryParams; + if(id==="") + { + queryParams = { entity: entity, observationName: observationName }; + + } + else{ + queryParams = { entity: entity, observationName: observationName, Id: id }; + + } localStorage.setItem("observationDescription", description) localStorage.setItem("endDateForSelectedObservation", endDate.toString())