prettier fix

This commit is contained in:
Danel Kungla
2025-09-19 17:22:36 +03:00
parent efa94b3322
commit 0c2cfe6d18
509 changed files with 17988 additions and 9920 deletions

View File

@@ -1,12 +1,15 @@
import { useMemo } from 'react';
import type { AnalysisResultDetailsElementResults } from '@/packages/features/user-analyses/src/types/analysis-results';
import { AnalysisResultLevel } from '@/packages/features/user-analyses/src/types/analysis-results';
import { ArrowDown } from 'lucide-react';
import { cn } from '@kit/ui/utils';
import type { AnalysisResultDetailsElementResults } from '@/packages/features/user-analyses/src/types/analysis-results';
import { AnalysisResultLevel } from '@/packages/features/user-analyses/src/types/analysis-results';
type AnalysisResultLevelBarResults = Pick<AnalysisResultDetailsElementResults, 'normLower' | 'normUpper' | 'responseValue'>;
type AnalysisResultLevelBarResults = Pick<
AnalysisResultDetailsElementResults,
'normLower' | 'normUpper' | 'responseValue'
>;
const Level = ({
isActive = false,
@@ -34,22 +37,29 @@ const Level = ({
{isActive && (
<div
className="absolute top-[-14px] left-1/2 -translate-x-1/2 rounded-[10px] bg-white p-[2px]"
{...(arrowLocation ? {
style: {
left: `${arrowLocation}%`,
...(arrowLocation > 92.5 && { left: '92.5%' }),
...(arrowLocation < 7.5 && { left: '7.5%' }),
}
} : {})}
{...(arrowLocation
? {
style: {
left: `${arrowLocation}%`,
...(arrowLocation > 92.5 && { left: '92.5%' }),
...(arrowLocation < 7.5 && { left: '7.5%' }),
},
}
: {})}
>
<ArrowDown strokeWidth={2} />
</div>
)}
{color === 'success' && typeof normRangeText === 'string' && (
<p className={cn("absolute bottom-[-18px] left-3/8 text-xs text-muted-foreground font-bold whitespace-nowrap", {
'opacity-60': isActive,
})}>
<p
className={cn(
'text-muted-foreground absolute bottom-[-18px] left-3/8 text-xs font-bold whitespace-nowrap',
{
'opacity-60': isActive,
},
)}
>
{normRangeText}
</p>
)}
@@ -59,11 +69,7 @@ const Level = ({
const AnalysisLevelBar = ({
level,
results: {
normLower: lower,
normUpper: upper,
responseValue: value,
},
results: { normLower: lower, normUpper: upper, responseValue: value },
normRangeText,
}: {
level: AnalysisResultLevel;
@@ -90,7 +96,7 @@ const AnalysisLevelBar = ({
return 100; // Beyond upper bound
}
// If only lower bound exists
// If only lower bound exists
if (upper === null && lower !== null) {
if (value >= lower) {
// Value is in normal range (above lower bound)
@@ -127,7 +133,7 @@ const AnalysisLevelBar = ({
// If pending results, show gray bar
if (isPending) {
return (
<div className="mt-4 flex h-3 w-60% sm:w-[35%] max-w-[360px] gap-1 sm:mt-0">
<div className="w-60% mt-4 flex h-3 max-w-[360px] gap-1 sm:mt-0 sm:w-[35%]">
<Level color="gray-200" isFirst isLast />
</div>
);
@@ -146,29 +152,25 @@ const AnalysisLevelBar = ({
const [warning, normal, critical] = [
{
isActive: isWarning,
color: "warning",
color: 'warning',
...(isWarning ? { arrowLocation } : {}),
},
{
isActive: isNormal,
color: "success",
color: 'success',
normRangeText,
...(isNormal ? { arrowLocation } : {}),
},
{
isActive: isCritical,
color: "destructive",
color: 'destructive',
isLast: true,
...(isCritical ? { arrowLocation } : {}),
},
] as const;
if (!hasLowerBound) {
return [
{ ...normal, isFirst: true },
warning,
critical,
] as const;
return [{ ...normal, isFirst: true }, warning, critical] as const;
}
return [
@@ -176,16 +178,27 @@ const AnalysisLevelBar = ({
normal,
{ ...critical, isLast: true },
] as const;
}, [isValueBelowLower, isValueAboveUpper, isValueInNormalRange, arrowLocation, normRangeText, isNormal, isWarning, isCritical]);
}, [
isValueBelowLower,
isValueAboveUpper,
isValueInNormalRange,
arrowLocation,
normRangeText,
isNormal,
isWarning,
isCritical,
]);
return (
<div className={cn(
"flex h-3 gap-1",
"mt-4 sm:mt-0",
"w-[60%] sm:w-[35%]",
"min-w-[50vw] sm:min-w-auto",
"max-w-[360px]",
)}>
<div
className={cn(
'flex h-3 gap-1',
'mt-4 sm:mt-0',
'w-[60%] sm:w-[35%]',
'min-w-[50vw] sm:min-w-auto',
'max-w-[360px]',
)}
>
<Level {...first} />
<Level {...second} />
<Level {...third} />

View File

@@ -1,15 +1,16 @@
'use client';
import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { format } from 'date-fns';
import { Info } from 'lucide-react';
import type {
AnalysisResultDetailsElement,
AnalysisResultsDetailsElementNested,
} from '@/packages/features/user-analyses/src/types/analysis-results';
import { AnalysisResultLevel } from '@/packages/features/user-analyses/src/types/analysis-results';
import { format } from 'date-fns';
import { Info } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { Trans } from '@kit/ui/trans';
import { cn } from '@kit/ui/utils';
@@ -64,7 +65,11 @@ const Analysis = ({
return null;
}
const { responseValue, responseValueIsNegative, responseValueIsWithinNorm } = results;
const {
responseValue,
responseValueIsNegative,
responseValueIsWithinNorm,
} = results;
if (responseValue === null || responseValue === undefined) {
if (hasIsNegative) {
if (responseValueIsNegative) {
@@ -107,7 +112,8 @@ const Analysis = ({
const isCancelled = Number(results?.status) === 5;
const nestedElements = results?.nestedElements ?? null;
const hasNestedElements = Array.isArray(nestedElements) && nestedElements.length > 0;
const hasNestedElements =
Array.isArray(nestedElements) && nestedElements.length > 0;
const normRangeText = (() => {
if (normLower === null && normUpper === null) {
@@ -118,9 +124,17 @@ const Analysis = ({
const hasTextualResponse = hasIsNegative || hasIsWithinNorm;
return (
<div className={cn("border-border rounded-lg border px-5", { 'ml-8': isNestedElement })}>
<div className="flex flex-col items-center justify-between gap-2 pt-3 pb-6 sm:py-3 sm:h-[65px] sm:flex-row sm:gap-0">
<div className={cn("flex items-center gap-2 font-semibold", { 'font-bold': isNestedElement })}>
<div
className={cn('border-border rounded-lg border px-5', {
'ml-8': isNestedElement,
})}
>
<div className="flex flex-col items-center justify-between gap-2 pt-3 pb-6 sm:h-[65px] sm:flex-row sm:gap-0 sm:py-3">
<div
className={cn('flex items-center gap-2 font-semibold', {
'font-bold': isNestedElement,
})}
>
{name}
{results?.responseTime && (
<div
@@ -147,7 +161,7 @@ const Analysis = ({
</div>
{isCancelled && (
<div className="text-red-600 font-semibold text-sm">
<div className="text-sm font-semibold text-red-600">
<Trans i18nKey="analysis-results:cancelled" />
</div>
)}
@@ -157,9 +171,15 @@ const Analysis = ({
<div className="flex items-center gap-3 sm:ml-auto">
<div
className={cn('font-semibold', {
'text-yellow-600': hasTextualResponse && analysisResultLevel === AnalysisResultLevel.WARNING,
'text-red-600': hasTextualResponse && analysisResultLevel === AnalysisResultLevel.CRITICAL,
'text-green-600': hasTextualResponse && analysisResultLevel === AnalysisResultLevel.NORMAL,
'text-yellow-600':
hasTextualResponse &&
analysisResultLevel === AnalysisResultLevel.WARNING,
'text-red-600':
hasTextualResponse &&
analysisResultLevel === AnalysisResultLevel.CRITICAL,
'text-green-600':
hasTextualResponse &&
analysisResultLevel === AnalysisResultLevel.NORMAL,
})}
>
{value}