From 84cc6208ddbb4eab3429ae0383ad0f75cfe2357e Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Fri, 22 Nov 2024 15:27:20 +0530 Subject: [PATCH 1/2] preset reset fix --- .../ConsultationDetails/ConsultationFeedTab.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx b/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx index 21c6f304cb5..e51f32239c6 100644 --- a/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx +++ b/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx @@ -34,6 +34,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { const bed = props.consultationData.current_bed?.bed_object; const feedStateSessionKey = `encounterFeedState[${props.consultationId}]`; const [preset, setPreset] = useState(); + const [selectedPreset, setSelectedPreset] = useState(); const [showPresetSaveConfirmation, setShowPresetSaveConfirmation] = useState(false); const [isUpdatingPreset, setIsUpdatingPreset] = useState(false); @@ -100,6 +101,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { if (preset) { setPreset(preset); + setSelectedPreset(preset); } }, }); @@ -126,6 +128,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { await presetsQuery.refetch(); setPreset(updated); + setSelectedPreset(updated); setHasMoved(false); setIsUpdatingPreset(false); setShowPresetSaveConfirmation(false); @@ -180,11 +183,9 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { { - if (!preset) { - return; - } + setSelectedPreset(undefined); setHasMoved(true); setTimeout(async () => { const { data } = await operate({ type: "get_status" }); @@ -193,7 +194,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { feedStateSessionKey, JSON.stringify({ type: "position", - assetBed: preset.asset_bed.id, + assetBed: "", value: (data as GetStatusResponse).result.position, } satisfies LastAccessedPosition), ); @@ -222,7 +223,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { obj.name} - value={preset} + value={selectedPreset} onChange={(value) => { triggerGoal("Camera Preset Clicked", { presetName: preset?.name, @@ -232,6 +233,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { }); setHasMoved(false); setPreset(value); + setSelectedPreset(value); }} /> {isUpdatingPreset ? ( From 570a60d3baae6077af1aa147e3c04d07eae35a78 Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Sun, 1 Dec 2024 12:32:52 +0530 Subject: [PATCH 2/2] modify LastAccessedPosition --- public/locale/en.json | 2 ++ .../ConsultationFeedTab.tsx | 27 ++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index 5faa645b133..55d51d1d06f 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -898,6 +898,7 @@ "next_sessions": "Next Sessions", "no": "No", "no_attachments_found": "This communication has no attachments.", + "no_bed_asset_linked_allocated": "No bed/asset linked allocated", "no_bed_types_found": "No Bed Types found", "no_beds_available": "No beds available", "no_changes": "No changes", @@ -1283,6 +1284,7 @@ "update_facility_middleware_success": "Facility middleware updated successfully", "update_log": "Update Log", "update_patient_details": "Update Patient Details", + "update_preset": "Update Preset", "update_preset_position_to_current": "Update preset's position to camera's current position", "update_record": "Update Record", "update_record_for_asset": "Update record for asset", diff --git a/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx b/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx index e51f32239c6..bc518feb02f 100644 --- a/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx +++ b/src/components/Facility/ConsultationDetails/ConsultationFeedTab.tsx @@ -79,26 +79,11 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { return presets.find((obj) => obj.id === lastState.value); } if (lastState.type === "position") { - const assetBedObj = presets.find( - (p) => p.asset_bed.id === lastState.assetBed, - )?.asset_bed; - - if (!assetBedObj) { - return; - } - - return { - ...presets[0], - id: "", - asset_bed: assetBedObj, - position: lastState.value, - } satisfies CameraPreset; + return; } } })() ?? presets[0]; - console.log({ preset, presets }); - if (preset) { setPreset(preset); setSelectedPreset(preset); @@ -157,7 +142,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { } if (!bed || !asset) { - return No bed/asset linked allocated; + return {t("no_bed_asset_linked_allocated")}; } const cannotSaveToPreset = !hasMoved || !preset?.id; @@ -165,8 +150,8 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { return ( setShowPresetSaveConfirmation(false)} @@ -194,7 +179,6 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { feedStateSessionKey, JSON.stringify({ type: "position", - assetBed: "", value: (data as GetStatusResponse).result.position, } satisfies LastAccessedPosition), ); @@ -226,7 +210,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => { value={selectedPreset} onChange={(value) => { triggerGoal("Camera Preset Clicked", { - presetName: preset?.name, + presetName: selectedPreset?.name, consultationId: props.consultationId, userId: authUser.id, result: "success", @@ -279,7 +263,6 @@ type LastAccessedPreset = { type LastAccessedPosition = { type: "position"; - assetBed: string; value: PTZPayload; };