feat(MED-100): update analysis level bars

This commit is contained in:
2025-08-25 11:50:32 +03:00
parent b6a0940506
commit e8e762e7ee
2 changed files with 20 additions and 14 deletions

View File

@@ -85,35 +85,43 @@ const AnalysisLevelBar = ({
return calculated; return calculated;
}, [value, upper, lower]); }, [value, upper, lower]);
const [isVeryLow, isLow, isHigh, isVeryHigh] = useMemo(() => [
level === AnalysisResultLevel.VERY_LOW,
level === AnalysisResultLevel.LOW,
level === AnalysisResultLevel.HIGH,
level === AnalysisResultLevel.VERY_HIGH,
], [level, value, upper, lower]);
const hasAbnormalLevel = isVeryLow || isLow || isHigh || isVeryHigh;
return ( return (
<div className="mt-4 flex h-3 w-[35%] max-w-[360px] gap-1 sm:mt-0"> <div className="mt-4 flex h-3 w-[35%] max-w-[360px] gap-1 sm:mt-0">
{normLowerIncluded && ( {normLowerIncluded && (
<> <>
<Level <Level
isActive={level === AnalysisResultLevel.VERY_LOW} isActive={isVeryLow}
color="destructive" color="destructive"
isFirst isFirst
/> />
<Level isActive={level === AnalysisResultLevel.LOW} color="warning" /> <Level isActive={isLow} color="warning" />
</> </>
)} )}
<Level <Level
isFirst={!normLowerIncluded} isFirst={!normLowerIncluded}
isLast={!normUpperIncluded} isLast={!normUpperIncluded}
color={level === AnalysisResultLevel.NORMAL ? "success" : "warning"} {...(hasAbnormalLevel ? { color: "warning", isActive: false } : { color: "success", isActive: true })}
isActive
arrowLocation={arrowLocation} arrowLocation={arrowLocation}
/> />
{normUpperIncluded && ( {normUpperIncluded && (
<> <>
<Level <Level
isActive={level === AnalysisResultLevel.HIGH} isActive={isHigh}
color="warning" color="warning"
/> />
<Level <Level
isActive={level === AnalysisResultLevel.VERY_HIGH} isActive={isVeryHigh}
color="destructive" color="destructive"
isLast isLast
/> />

View File

@@ -108,7 +108,7 @@ const Analysis = ({
<div className="text-muted-foreground text-sm">{unit}</div> <div className="text-muted-foreground text-sm">{unit}</div>
</div> </div>
<div className="text-muted-foreground mx-8 flex flex-col-reverse gap-2 text-center text-sm sm:block sm:gap-0"> <div className="text-muted-foreground mx-8 flex flex-col-reverse gap-2 text-center text-sm sm:block sm:gap-0">
{normLower} - {normUpper} {normLower} - {normUpper} %
<div> <div>
<Trans i18nKey="analysis-results:results.range.normal" /> <Trans i18nKey="analysis-results:results.range.normal" />
</div> </div>
@@ -120,19 +120,17 @@ const Analysis = ({
level={analysisResultLevel!} level={analysisResultLevel!}
/> />
</> </>
) : ( ) : (isCancelled ? null : (
<> <>
<div className="flex items-center gap-3 sm:ml-auto"> <div className="flex items-center gap-3 sm:ml-auto">
{!isCancelled && ( <div className="font-semibold">
<div className="font-semibold"> <Trans i18nKey="analysis-results:waitingForResults" />
<Trans i18nKey="analysis-results:waitingForResults" /> </div>
</div>
)}
</div> </div>
<div className="mx-8 w-[60px]"></div> <div className="mx-8 w-[60px]"></div>
<AnalysisLevelBarSkeleton /> <AnalysisLevelBarSkeleton />
</> </>
)} ))}
</div> </div>
); );
}; };