diff --git a/src/components/CreationCohort/ControlPanel/ControlPanel.tsx b/src/components/CreationCohort/ControlPanel/ControlPanel.tsx index 41d817c3a..787a479be 100644 --- a/src/components/CreationCohort/ControlPanel/ControlPanel.tsx +++ b/src/components/CreationCohort/ControlPanel/ControlPanel.tsx @@ -102,6 +102,8 @@ const ControlPanel: React.FC<{ const { uuid, includePatient, status, jobFailMsg } = count const [patientCount, setPatientCount] = useState(includePatient) + const [countError, setCountError] = useState(jobFailMsg) + const [countStatus, setCountStatus] = useState(status) const [requestShare, setRequestShare] = useState({ currentSnapshot, @@ -220,7 +222,9 @@ const ControlPanel: React.FC<{ setCountLoading(LoadingStatus.FETCHING) dispatch(countCohortCreation({ uuid: uuid })) } - }, [dispatch, status, uuid]) + setCountStatus(status) + setCountError(jobFailMsg) + }, [dispatch, status, uuid, jobFailMsg]) useEffect(() => { setPatientCount(includePatient) @@ -236,6 +240,12 @@ const ControlPanel: React.FC<{ setPatientCount(message.extra_info?.measure) setCountLoading(LoadingStatus.SUCCESS) } + if (message.job_name === WebSocketJobName.COUNT && message.status === WebSocketJobStatus.failed) { + setCountStatus('failed') + setPatientCount(message.extra_info?.measure) + setCountError(message.extra_info?.request_job_fail_msg) + setCountLoading(LoadingStatus.SUCCESS) + } } webSocketContext?.addListener(listener) @@ -408,11 +418,11 @@ const ControlPanel: React.FC<{ )} - {(status === 'failed' || status === 'error') && ( + {(countStatus === 'failed' || countStatus === 'error') && ( Une erreur est survenue lors du calcul du nombre de patients de votre requĂȘte.
- {jobFailMsg} + {countError}