From 7af1dcca6a54c0be4e6f8895a2612fe7545dd2fb Mon Sep 17 00:00:00 2001 From: Devdeep Ghosh Date: Tue, 20 Feb 2024 12:30:36 +0530 Subject: [PATCH] improved logic for showing asset changes --- .../Consultations/BedActivityTimeline.tsx | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Components/Facility/Consultations/BedActivityTimeline.tsx b/src/Components/Facility/Consultations/BedActivityTimeline.tsx index c3649cc87f3..a74e8716bbe 100644 --- a/src/Components/Facility/Consultations/BedActivityTimeline.tsx +++ b/src/Components/Facility/Consultations/BedActivityTimeline.tsx @@ -1,3 +1,4 @@ +import Chip from "../../../CAREUI/display/Chip"; import Timeline, { TimelineNode } from "../../../CAREUI/display/Timeline"; import { classNames, formatDateTime } from "../../../Utils/utils"; import { AssetData } from "../../Assets/AssetTypes"; @@ -19,13 +20,14 @@ export default function BedActivityTimeline({ "py-4 md:px-3", loading && "animate-pulse opacity-70" )} - name="bed" + name="bed-allocation" > {consultationBeds.map((bed, index) => { return ( 0 ? consultationBeds[index + 1] : undefined} isLastNode={index === consultationBeds.length - 1} /> ); @@ -37,9 +39,11 @@ export default function BedActivityTimeline({ const BedAllocationNode = ({ bed, + prevBed, isLastNode, }: { bed: CurrentBed; + prevBed?: CurrentBed; isLastNode: boolean; }) => { return ( @@ -57,14 +61,23 @@ const BedAllocationNode = ({ "" ), }} - titleSuffix={} + titleSuffix={ + + } isLast={isLastNode} /> ); }; -const BedTitleSuffix = ({ bed }: { bed: CurrentBed; isLastNode?: boolean }) => { +const BedTitleSuffix = ({ + bed, + prevBed, +}: { + bed: CurrentBed; + isLastNode?: boolean; + prevBed?: CurrentBed; +}) => { return (
@@ -73,8 +86,20 @@ const BedTitleSuffix = ({ bed }: { bed: CurrentBed; isLastNode?: boolean }) => { {formatDateTime(bed.start_date).split(";")[1]}

- {bed.end_date === null ? "Currently occupying" : "Transferred to"}{" "} + {bed.bed_object.id === prevBed?.bed_object.id + ? "Asset changed in" + " " + : "Transferred to" + " "} {`${bed.bed_object.name} (${bed.bed_object.bed_type}) in ${bed.bed_object.location_object?.name}`} + {bed.end_date === null ? ( + + ) : ( + "" + )}

);