diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 54eee52878e..56bb1de5a08 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -120,16 +120,21 @@ export const ConsultationDetails = (props: any) => { data.symptoms_text = symptoms.join(", "); } setConsultationData(data); - const assetRes = await dispatch( - listAssetBeds({ - bed: data?.current_bed?.bed_object?.id, - }) - ); - const isCameraAttachedRes = assetRes.data.results.some( - (asset: { asset_object: { asset_class: string } }) => { - return asset?.asset_object?.asset_class === "ONVIF"; - } - ); + const assetRes = data?.current_bed?.bed_object?.id + ? await dispatch( + listAssetBeds({ + bed: data?.current_bed?.bed_object?.id, + }) + ) + : null; + const isCameraAttachedRes = + assetRes != null + ? assetRes.data.results.some( + (asset: { asset_object: { asset_class: string } }) => { + return asset?.asset_object?.asset_class === "ONVIF"; + } + ) + : false; setIsCameraAttached(isCameraAttachedRes); const id = res.data.patient; const patientRes = await dispatch(getPatient({ id }));