File size: 1,185 Bytes
75c7554
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const SCORE_COLORS = {
  reward:           '#6366f1',
  soc_readiness:    '#22d3ee',
  ps_adherence:     '#f59e0b',
  cycle_discipline: '#10b981',
  arb_accuracy:     '#a78bfa',
  consistency:      '#f43f5e',
}

const LABELS = {
  reward:           'Reward',
  soc_readiness:    'SOC Readiness',
  ps_adherence:     'Peak Shaving',
  cycle_discipline: 'Cycle Discipline',
  arb_accuracy:     'Arb. Accuracy',
  consistency:      'Consistency',
}

export default function ScoreBreakdown({ scores }) {
  if (!scores) return null
  const keys = Object.keys(LABELS)

  return (
    <div>
      {keys.map(k => {
        const val = scores[k] ?? 0
        const color = SCORE_COLORS[k] || '#6366f1'
        return (
          <div className="score-row" key={k}>
            <span className="score-label">{LABELS[k]}</span>
            <div className="score-track">
              <div
                className="score-fill"
                style={{ width: `${Math.max(0, Math.min(1, val)) * 100}%`, background: color }}
              />
            </div>
            <span className="score-val" style={{ color }}>{val.toFixed(2)}</span>
          </div>
        )
      })}
    </div>
  )
}