Skip to content

Commit

Permalink
(fix) O3-3713: Should not load infinitely when the conceptId is undef…
Browse files Browse the repository at this point in the history
…ined (#336)

* (fix) O3-3713: fix infinite loading when conceptId is undefined

* (chore): Update tsconfig and hook loading condition
  • Loading branch information
NethmiRodrigo authored Aug 9, 2024
1 parent 988016a commit 190cf27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/components/interactive-builder/edit-question.modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ const EditQuestionModal: React.FC<EditQuestionModalProps> = ({
);
const [programWorkflows, setProgramWorkflows] = useState<Array<ProgramWorkflow>>([]);

const hasConceptChanged = selectedConcept && questionToEdit?.questionOptions?.concept !== selectedConcept?.uuid;
const hasConceptChanged =
selectedConcept &&
questionToEdit?.questionOptions.concept &&
questionToEdit?.questionOptions?.concept !== selectedConcept?.uuid;
const [addInlineDate, setAddInlineDate] = useState(false);

// Maps the data type of a concept to a date picker type.
Expand Down Expand Up @@ -276,8 +279,8 @@ const EditQuestionModal: React.FC<EditQuestionModalProps> = ({
rendering: fieldType ? fieldType : questionToEdit.questionOptions.rendering,
...((selectedConcept || questionToEdit.questionOptions.concept) && {
concept: selectedConcept ? selectedConcept.uuid : questionToEdit.questionOptions.concept,
conceptMappings: conceptMappings?.length ? conceptMappings : questionToEdit.questionOptions.conceptMappings,
}),
conceptMappings: conceptMappings?.length ? conceptMappings : questionToEdit.questionOptions.conceptMappings,
answers: mappedAnswers,
...(questionType === 'patientIdentifier' && {
identifierType: selectedPatientIdentifierType
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useConceptName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export function useConceptName(conceptId: string | undefined) {
return {
conceptName: data?.data?.name?.display ?? null,
conceptNameLookupError: error,
isLoadingConceptName: (!data && !error) || false,
isLoadingConceptName: (conceptId && !data && !error) || false,
};
}

0 comments on commit 190cf27

Please sign in to comment.