Skip to content

Commit

Permalink
Merge pull request #421 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat:Resolve observation Id issue for first time login user
  • Loading branch information
itsvick authored Nov 24, 2024
2 parents ac195bb + 7bee420 commit 36a13b6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/pages/observation/[observationId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const ObservationDetails = () => {
const [entityData, setEntityData] = useState<any[]>([]);
const [filteredEntityData, setFilteredEntityData] = useState<any[]>([]);
const [loading, setLoading] = React.useState(false);
const [observationId, setObservationId] = React.useState("");




Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -274,15 +277,15 @@ 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;

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 });
Expand All @@ -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]);



Expand Down Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion src/pages/observation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 36a13b6

Please sign in to comment.