diff --git a/src/Components/Facility/Consultations/BedActivityTimeline.tsx b/src/Components/Facility/Consultations/BedActivityTimeline.tsx index 8a2df05170e..300ca93788f 100644 --- a/src/Components/Facility/Consultations/BedActivityTimeline.tsx +++ b/src/Components/Facility/Consultations/BedActivityTimeline.tsx @@ -86,6 +86,10 @@ const BedAllocationNode = ({ prevBed?: CurrentBed; isLastNode: boolean; }) => { + const { newlyLinkedAssets, existingAssets, unlinkedAssets } = getAssetDiff( + prevBed?.assets_objects ?? [], + bed.assets_objects ?? [] + ); const event: TimelineEvent = { type: "allocated", timestamp: bed.start_date, @@ -93,14 +97,18 @@ const BedAllocationNode = ({ icon: "l-bed", iconWrapperStyle: bed.end_date === null ? "bg-green-500" : "", iconStyle: bed.end_date === null ? "text-white" : "", - notes: bed.assets_objects ? ( - - ) : ( - "" - ), + notes: + newlyLinkedAssets.length === 0 && + existingAssets.length === 0 && + unlinkedAssets.length === 0 ? ( + "" + ) : ( + + ), }; return ( @@ -122,17 +130,14 @@ const BedAllocationNode = ({ }; const BedTimelineAsset = ({ - assets, - prevBedAssets, + newlyLinkedAssets, + existingAssets, + unlinkedAssets, }: { - assets: AssetData[]; - prevBedAssets?: AssetData[]; + newlyLinkedAssets: AssetData[]; + existingAssets: AssetData[]; + unlinkedAssets: AssetData[]; }) => { - const { newlyLinkedAssets, existingAssets, unlinkedAssets } = getAssetDiff( - prevBedAssets || [], - assets - ); - return (

Assets

@@ -144,21 +149,21 @@ const BedTimelineAsset = ({ {newlyLinkedAssets.length > 0 && newlyLinkedAssets.map((newAsset) => (
- + {newAsset.name}
))} {existingAssets.length > 0 && existingAssets.map((existingAsset) => (
- + {existingAsset.name}
))} {unlinkedAssets.length > 0 && unlinkedAssets.map((unlinkedAsset) => (
- + {unlinkedAsset.name}
))} @@ -230,7 +235,10 @@ const BedActivityIButtonPopover = ({ return ( - +