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
+9
View File
@@ -60,3 +60,12 @@ export function scoreToDataQualityLevel(score: number): DataQualityLevel {
if (score > 0) return 'LOW'
return 'INCOMPLETE'
}
// ── Result type meta — single source for labels + colors ─────────────────────
export const RESULT_TYPE_META: Record<string, { label: string; color: string; bg: string }> = {
VERIFIED_PORTFOLIO: { label: 'Plattform', color: '#1e3a5f', bg: 'rgba(30,58,95,0.10)' },
EXTERNAL_MARKET: { label: 'Plattform', color: '#1e3a5f', bg: 'rgba(30,58,95,0.10)' },
MAISON_WORK: { label: 'Maison Work', color: '#0369a1', bg: 'rgba(3,105,161,0.10)' },
FUTURE_AVAILABILITY: { label: 'Zukunftssignal', color: '#7c3aed', bg: 'rgba(109,40,217,0.10)' },
}
+14
View File
@@ -83,6 +83,20 @@ export function probabilityHex(prob: number): string {
return '#c0392b'
}
export function matchScoreHex(score: number): string {
if (score >= SCORE_STRONG) return '#1a7a4a'
if (score >= SCORE_MODERATE) return '#d97706'
return '#c0392b'
}
export function criterionScoreColor(score: number): 'success' | 'warning' | 'error' {
return score >= 70 ? 'success' : score >= 50 ? 'warning' : 'error'
}
export function criterionScoreTextColor(score: number): string {
return score >= 70 ? '#1a7a4a' : score >= 50 ? '#d97706' : '#c0392b'
}
// ── Misc ──────────────────────────────────────────────────────────────────────
export function clamp(value: number, min: number, max: number): number {