refactor: consolidate duplicated UI score/color/badge logic into lib/

- Add matchScoreHex(), criterionScoreColor(), criterionScoreTextColor() to lib/utils.ts
- Add RESULT_TYPE_META (labels + colors) to lib/ds.ts as single source of truth
- Remove 5 local scoreColor() functions: StrongMatchMiniCard, MatchListCard,
  pipelineUtils (re-exported as matchScoreHex), CriterionRow, ScoreBreakdownPanel,
  ScoreInlineBreakdown
- Remove local RESULT_TYPE_META/TYPE_META from MatchCardHeader, ResultTypeBadge;
  remove RESULT_TYPE_LABEL/COLOR from pipelineConstants — all now use lib/ds.ts
- Replace local confidenceColor() in MatchCardHeader, ConfidenceFieldBadge,
  ReliabilityScorePanel with confidenceHex() from lib/utils.ts
- Replace local qualityColor() in propertyHelpers, DataQualityWidget with
  dataQualityColor() from lib/utils.ts
- Fix FUTURE_AVAILABILITY label inconsistency ('Future'/'Zukunft' → 'Zukunftssignal')
- Fix EXTERNAL_MARKET label inconsistency ('Direktinserat' → 'Plattform')
- tsc --noEmit passes with zero errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Sutter
2026-05-24 01:47:08 +02:00
parent 5d53f35dea
commit 86bdf142b4
16 changed files with 60 additions and 138 deletions
+5 -25
View File
@@ -1,4 +1,6 @@
import type { AssetType, AvailabilityStatus, ResultType } from '../../domain/enums'
import { RESULT_TYPE_META } from '../../lib/ds'
import { dataQualityColor } from '../../lib/utils'
export function getAssetTypeLabel(type: AssetType): string {
const labels: Record<string, string> = {
@@ -51,33 +53,11 @@ export function getAvailabilityChipColor(status: AvailabilityStatus): 'success'
}
export function getResultTypeLabel(type: ResultType): string {
const labels: Record<string, string> = {
VERIFIED_PORTFOLIO: 'Portfolio',
EXTERNAL_MARKET: 'Direktinserat',
MAISON_WORK: 'Maison Work',
FUTURE_AVAILABILITY: 'Zukunft',
}
return labels[type] ?? type
return RESULT_TYPE_META[type]?.label ?? type
}
export function getResultTypeColor(type: ResultType): string {
const colors: Record<string, string> = {
VERIFIED_PORTFOLIO: '#1e3a5f',
EXTERNAL_MARKET: '#1a7a4a',
MAISON_WORK: '#0369a1',
FUTURE_AVAILABILITY: '#7c3aed',
}
return colors[type] ?? '#6b7280'
return RESULT_TYPE_META[type]?.color ?? '#6b7280'
}
export function qualityColor(score: number): 'success' | 'warning' | 'error' {
if (score >= 0.8) return 'success'
if (score >= 0.6) return 'warning'
return 'error'
}
export function confidenceColor(score: number): string {
if (score >= 0.85) return '#1a7a4a'
if (score >= 0.65) return '#1e3a5f'
return '#d97706'
}
export const qualityColor = dataQualityColor