Skip to content

Commit

Permalink
fix/concept-answers: added customConceptAnswers check
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqedme committed Feb 22, 2024
1 parent b17a4bd commit cb6bbb1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export function CodedPersonAttributeField({
const { data: conceptAnswers, isLoading: isLoadingConceptAnswers } = useConceptAnswers(
customConceptAnswers.length ? '' : answerConceptSetUuid,
);

const { t } = useTranslation();
const fieldName = `attributes.${personAttributeType.uuid}`;
const [error, setError] = useState(false);

useEffect(() => {
if (!answerConceptSetUuid) {
if (!answerConceptSetUuid && !customConceptAnswers.length) {
reportError(
t(
'codedPersonAttributeNoAnswerSet',
Expand All @@ -41,10 +42,10 @@ export function CodedPersonAttributeField({
);
setError(true);
}
}, [answerConceptSetUuid]);
}, [answerConceptSetUuid, customConceptAnswers]);

useEffect(() => {
if (!isLoadingConceptAnswers) {
if (!isLoadingConceptAnswers && !customConceptAnswers.length) {
if (!conceptAnswers) {
reportError(
t(
Expand All @@ -69,7 +70,7 @@ export function CodedPersonAttributeField({
setError(true);
}
}
}, [isLoadingConceptAnswers, conceptAnswers]);
}, [isLoadingConceptAnswers, conceptAnswers, customConceptAnswers]);

const answers = useMemo(() => {
if (customConceptAnswers.length) {
Expand Down

0 comments on commit cb6bbb1

Please sign in to comment.