-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displaying camera feed without preset in Patient consultation page#8901 #8922
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||||||||||||||||||||||||
import { useEffect, useRef, useState } from "react"; | ||||||||||||||||||||||||||||||||
import { useEffect, useMemo, useRef, useState } from "react"; | ||||||||||||||||||||||||||||||||
import { ConsultationTabProps } from "./index"; | ||||||||||||||||||||||||||||||||
import useQuery from "../../../Utils/request/useQuery"; | ||||||||||||||||||||||||||||||||
import CameraFeed from "../../CameraFeed/CameraFeed"; | ||||||||||||||||||||||||||||||||
|
@@ -23,6 +23,7 @@ import { | |||||||||||||||||||||||||||||||
GetStatusResponse, | ||||||||||||||||||||||||||||||||
} from "../../CameraFeed/routes"; | ||||||||||||||||||||||||||||||||
import StillWatching from "../../CameraFeed/StillWatching"; | ||||||||||||||||||||||||||||||||
import routes from "@/Redux/api"; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export const ConsultationFeedTab = (props: ConsultationTabProps) => { | ||||||||||||||||||||||||||||||||
const { t } = useTranslation(); | ||||||||||||||||||||||||||||||||
|
@@ -50,7 +51,23 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { | |||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
}, []); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const asset = preset?.asset_bed.asset_object; | ||||||||||||||||||||||||||||||||
const bedObjectId = props.consultationData.current_bed?.bed_object?.id || ""; | ||||||||||||||||||||||||||||||||
const bedsQuery = useQuery(routes.listAssetBeds, { | ||||||||||||||||||||||||||||||||
query: { | ||||||||||||||||||||||||||||||||
bed_object: bedObjectId, | ||||||||||||||||||||||||||||||||
limit: 50, | ||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+54
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
const bedLocationId = bed?.location_object?.id; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const matchingAsset = useMemo(() => { | ||||||||||||||||||||||||||||||||
return bedsQuery.data?.results.find( | ||||||||||||||||||||||||||||||||
(bedItem) => bedItem.asset_object?.location_object?.id === bedLocationId, | ||||||||||||||||||||||||||||||||
)?.asset_object; | ||||||||||||||||||||||||||||||||
}, [bedsQuery.data, bedLocationId]); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+62
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if bedsQuery (better known as assetBedsQuery) is already filtered by a bed, why filter by location? We do not allow linking an asset with a bed with different locations anyhow in the first place.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rithviknishad I need to filter the fetched values by bedId and asset_class. const filteredAssets = useMemo(() => {
return assetBedsQuery.data?.results.filter(
(bedItem) =>
bedItem.bed_object?.id === bedId &&
bedItem.asset_object?.asset_class === "ONVIF"
);
}, [assetBedsQuery.data, bedId]); However, I have a question: if a bed has multiple cameras, should I display all camera assets? I am getting multiple camera assets. |
||||||||||||||||||||||||||||||||
const asset = preset?.asset_bed?.asset_object ?? matchingAsset; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const { key, operate } = useOperateCamera(asset?.id ?? ""); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
@@ -149,6 +166,10 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { | |||||||||||||||||||||||||||||||
return <Loading />; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
if (bedsQuery.loading) { | ||||||||||||||||||||||||||||||||
return <div>Loading bed/asset...</div>; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+169
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add it as an or condition in line 165 along with
Suggested change
|
||||||||||||||||||||||||||||||||
if (!bed || !asset) { | ||||||||||||||||||||||||||||||||
return <span>No bed/asset linked allocated</span>; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use proper names to avoid confusions. You are using the Asset Beds list API and not Beds list API.