Skip to content

Commit

Permalink
Merge pull request #380 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat: Call fetch  entity API when we add new unmatched entities
  • Loading branch information
itsvick authored Nov 10, 2024
2 parents 4053590 + 4a7ba58 commit 56480b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/pages/observation/[observationId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,22 @@ setEntityData(result)
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 });
setFetchEntityResponse(response?.result?.entities)
} else if (unmatchedUserIds.length !== 0) {
await addEntities({ data, observationId });
const urlPath = window.location.pathname;

const solutionId = urlPath.split('/observation/')[1];

const response = await fetchEntities({ solutionId });
setFetchEntityResponse(response?.result?.entities)
}

}
};

Expand Down Expand Up @@ -444,7 +457,7 @@ setEntityData(result)
<Entity
key={item.cohortId || index} // Use a unique key here
entityMemberValue={toPascalCase(item?.name)}
status={item?.status===ObservationStatus?.Started?ObservationStatus.NOT_STARTED:item?.status}
status={item?.status===ObservationStatus?.STARTED?ObservationStatus.NOT_STARTED:item?.status}
onClick={() =>
entityType !== ObservationEntityType.CENTER
? onStartObservation(item?._id)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/app.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export enum ObservationStatus {
DRAFT = 'draft',
COMPLETED = 'completed',
NOT_STARTED = 'notstarted',
Started="started"
STARTED="started"
}

export enum CenterType {
Expand Down

0 comments on commit 56480b4

Please sign in to comment.