'use client' import type { ScoreSnapshot } from './types' interface TrendTabProps { scoreHistory: ScoreSnapshot[] savingSnapshot: boolean saveSnapshot: () => Promise } export function TrendTab({ scoreHistory, savingSnapshot, saveSnapshot }: TrendTabProps) { return (

Score-Verlauf

{scoreHistory.length === 0 ? (

Noch keine Score-Snapshots vorhanden.

Klicken Sie auf "Aktuellen Score speichern", um den ersten Datenpunkt zu erstellen.

) : ( <> {/* Simple SVG Line Chart */}
{/* Grid lines */} {[0, 25, 50, 75, 100].map(pct => ( ))} {/* Score line */} { const x = scoreHistory.length === 1 ? 400 : (i / (scoreHistory.length - 1)) * 780 + 10 const y = 200 - (s.score / 100) * 200 return `${x},${y}` }).join(' ')} /> {/* Points */} {scoreHistory.map((s, i) => { const x = scoreHistory.length === 1 ? 400 : (i / (scoreHistory.length - 1)) * 780 + 10 const y = 200 - (s.score / 100) * 200 return ( ) })} {/* Y-axis labels */}
100% 75% 50% 25% 0%
{/* Snapshot Table */}
{scoreHistory.slice().reverse().map(snap => ( ))}
Datum Score Controls Bestanden
{new Date(snap.snapshot_date).toLocaleDateString('de-DE')} = 80 ? 'text-green-600' : snap.score >= 60 ? 'text-yellow-600' : 'text-red-600' }`}> {typeof snap.score === 'number' ? snap.score.toFixed(1) : snap.score}% {snap.controls_total} {snap.controls_pass}
)}
) }