import React, { useMemo, useState } from 'react' function SkillBar({ skill, maxShare }) { const pct = maxShare > 0 ? Math.min(100, (skill.share_percent / maxShare) * 100) : 0 return (
  • {skill.skill_name} {skill.share_percent}%
  • ) } /** * Gewichtetes Fähigkeiten-Profil (Phase 3) — Anzeige für Planungsartefakte. */ export default function SkillProfilePanel({ profile, slots = null, loading = false, error = '', title = 'Fähigkeiten-Profil', hint = 'Aus verknüpften Übungen berechnet (Dauer, Vorkommen, Primär-Fähigkeit, Intensität).', defaultExpanded = true, }) { const [expanded, setExpanded] = useState(defaultExpanded) const [slotOpenId, setSlotOpenId] = useState(null) const skills = profile?.skills || [] const maxShare = useMemo( () => Math.max(...skills.map((s) => s.share_percent || 0), 1), [skills] ) if (loading) { return (

    Fähigkeiten-Profil wird berechnet…

    ) } if (error) { return (

    {error}

    ) } const noData = !profile || (profile.exercise_occurrence_count === 0 && profile.distinct_exercise_count === 0) return (
    {expanded ? (

    {hint}

    {noData ? (

    Noch keine Übungen mit Fähigkeiten-Verknüpfung — lege Übungen im Ablauf an und verknüpfe Fähigkeiten in der Übungsbearbeitung.

    ) : profile.exercises_with_skills_count === 0 ? (

    {profile.distinct_exercise_count} Übung{profile.distinct_exercise_count === 1 ? '' : 'en'} im Ablauf, aber keine Fähigkeiten an den Übungen hinterlegt.

    ) : ( <>
    {profile.distinct_exercise_count} Übungen {skills.length} Fähigkeiten {profile.exercise_occurrence_count} Positionen
    {profile.by_category?.length > 1 ? (
    Nach Kategorie
    {profile.by_category.slice(0, 6).map((c) => ( {c.category} {c.share_percent}% ))}
    ) : null} )} {slots && slots.length > 0 ? (
    Pro Session
      {slots.map((sl) => { const open = slotOpenId === sl.slot_id const top = sl.profile?.skills?.[0] return (
    • {open && sl.profile?.skills?.length > 0 ? (
        {sl.profile.skills.slice(0, 6).map((sk) => ( x.share_percent || 0), 1 )} /> ))}
      ) : null}
    • ) })}
    ) : null}
    ) : null}
    ) }