diff --git a/frontend/src/components/finops/workflow-compare-card.tsx b/frontend/src/components/finops/workflow-compare-card.tsx index 2637703..17d295f 100644 --- a/frontend/src/components/finops/workflow-compare-card.tsx +++ b/frontend/src/components/finops/workflow-compare-card.tsx @@ -1,7 +1,7 @@ import { useState } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" -import { formatCost, formatLabel, formatPercent } from "@/lib/utils" +import { formatCost, formatLabel, formatMetric, formatPercent } from "@/lib/utils" import type { QualityAttributionRow, WorkflowCostBreakdown } from "@/types/api" type CompareDimension = "workflow_archetype" | "workflow_fingerprint" @@ -20,10 +20,6 @@ function displayLabel(value: string, dimension: CompareDimension) { return dimension === "workflow_archetype" ? formatLabel(value) : value } -function formatMetric(value: number | null | undefined, digits = 1): string { - return value == null ? "-" : value.toFixed(digits) -} - export function WorkflowCompareCard({ workflowCosts, qualityRows, diff --git a/frontend/src/components/quality/claude-pr-comparison.tsx b/frontend/src/components/quality/claude-pr-comparison.tsx index 4d53336..c440b8a 100644 --- a/frontend/src/components/quality/claude-pr-comparison.tsx +++ b/frontend/src/components/quality/claude-pr-comparison.tsx @@ -1,7 +1,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { CardSkeleton } from "@/components/shared/loading-skeleton" import { useClaudePRComparison } from "@/hooks/use-api-queries" -import { cn } from "@/lib/utils" +import { cn, formatMetric } from "@/lib/utils" import { GitPullRequest } from "lucide-react" import type { PRGroupMetrics } from "@/types/api" @@ -11,9 +11,9 @@ interface ClaudePRComparisonProps { endDate?: string } -function formatMetric(value: number | null, suffix = ""): string { - if (value == null) return "-" - return `${value.toFixed(1)}${suffix}` +function formatMetricWithSuffix(value: number | null, suffix = ""): string { + const base = formatMetric(value) + return base === "-" ? base : `${base}${suffix}` } function DeltaIndicator({ value }: { value: number | null }) { @@ -56,8 +56,8 @@ function MetricRow({ return (