import { Link } from 'react-router-dom' import { RECURRING_STATUS_LABELS } from '../constants/status.js' import { EmptyState } from './EmptyState.jsx' import { scopedPath } from '../utils/routes.js' function formatDueAt(iso) { if (!iso) return null try { return new Date(iso).toLocaleString('de-DE') } catch { return iso } } function activeMaturityStages(roadmapItems = []) { return [...roadmapItems] .filter((item) => item.item_type === 'maturity_stage' && item.status === 'active') .sort((a, b) => (a.sort_order ?? 0) - (b.sort_order ?? 0)) } function practicesForStage(recurringItems = [], stageId) { if (!stageId) { return (recurringItems || []).filter((item) => item.roadmap_item_id) } return (recurringItems || []).filter((item) => item.roadmap_item_id === stageId) } export function RecurringRhythmPanel({ initiativeId, roadmapItems = [], recurringItems = [], canManage = false, embedded = true, }) { const stages = activeMaturityStages(roadmapItems) const stagePractices = stages.flatMap((stage) => practicesForStage(recurringItems, stage.id), ) const active = stagePractices.filter((item) => item.status === 'active') const paused = stagePractices.filter((item) => item.status === 'paused') const body = stages.length === 0 ? ( ) : stagePractices.length === 0 ? ( ) : ( <>

{stages.length} aktive Gate(s) — {active.length} Übung(en) aktiv {paused.length > 0 ? `, ${paused.length} pausiert` : ''}.

{canManage ? 'Übungen anlegen und Rhythmus pflegen am ' : 'Übungen am '} Zielzustand (Gate-Detail) {' '}— Activity Set pro Gate. Heute erledigen unter{' '} Ausführen → Today .

) if (!embedded) return body return (

Übungen der aktiven Gates

Activity Sets aller aktiven Work-Gates — Join-Knoten haben keine Übungen (A1).

{body}
) }