import { LIFECYCLE_LABELS, SIGNAL_LABELS, NEXT_ACTION_KIND_LABELS, } from '../constants/operating.js' import { MILESTONE_STATUS_LABELS } from '../constants/status.js' import { methodDescriptionForKey } from '../utils/archetypes.js' import { ArchetypeSteeringHints } from './ArchetypeSteeringHints.jsx' import { Link } from 'react-router-dom' import { scopedPath } from '../utils/routes.js' function formatDate(iso) { if (!iso) return '—' try { return new Date(iso).toLocaleDateString('de-DE') } catch { return iso } } export function SteeringSnapshotPanel({ snapshot, loading, error, methods = [], canManageMethod = false, onMethodChange, methodBusy = false, }) { if (loading) { return (

Steuerungszustand wird geladen …

) } if (error || !snapshot) { return (

Steuerungszustand

{error || 'Snapshot nicht verfügbar — bitte Seite neu laden (Strg+F5).'}

) } const { lifecycle_state, lifecycle_label, method_key, method_label, archetype_key, archetype_label, steering_guidance, attention_items = [], signals = [], counts, upcoming_milestones = [], next_actions = [], active_work_cycle = null, } = snapshot const displayLabel = lifecycle_label || LIFECYCLE_LABELS[lifecycle_state] || lifecycle_state const statPills = [ { label: 'Offen', value: counts.actions_open, warn: false }, { label: 'Blockiert', value: counts.actions_blocked, warn: counts.actions_blocked > 0 }, { label: 'Review', value: counts.actions_review_required, warn: counts.actions_review_required > 0 }, { label: 'Blocker', value: counts.blockers_open, warn: counts.blockers_open > 0 }, ] const methodDescription = methodDescriptionForKey(method_key, methods) function nextActionLink(item) { if (item.action_id) { return { to: `/actions/${item.action_id}`, label: 'Arbeitspaket öffnen' } } if (item.backlog_item_id && item.initiative_id) { return { to: scopedPath('/plan/inbox', { initiativeId: item.initiative_id }), label: 'Zum Eingang', } } if (item.kind === 'create_action' && item.initiative_id) { return { to: scopedPath('/plan/work', { initiativeId: item.initiative_id }), label: 'Arbeitspaket anlegen', } } return null } return (

Leitfrage

Wo stehe ich — und was ist als Nächstes dran?

{steering_guidance && (

{steering_guidance}

)}
{displayLabel}
{(archetype_label || archetype_key) && (

Archetyp: {archetype_label || archetype_key}

)} {(method_label || canManageMethod) && (

Methode: {canManageMethod && methods.length > 0 ? ( ) : ( {method_label || method_key} )} {methodDescription && ( {methodDescription} )}

)} {active_work_cycle && (

Aktive Zeitbox: {active_work_cycle.title} {active_work_cycle.goal_description && ( {' '} — {active_work_cycle.goal_description} )}

)}
{(attention_items?.length > 0 || signals?.length > 0) && (

Aufmerksamkeit:{' '} {(attention_items.length > 0 ? attention_items.map((a) => a.label) : signals.map((s) => SIGNAL_LABELS[s] || s) ).join(' · ')}

)}
{next_actions.length > 0 && (

Nächste Schritte

    {next_actions.map((item, i) => { const link = nextActionLink(item) return (
  1. {i + 1} {item.title} {NEXT_ACTION_KIND_LABELS[item.kind] || item.kind} {item.recommended_action ? ` — ${item.recommended_action}` : ''}
    {link && ( {link.label} )}
  2. )})}
)} {upcoming_milestones.length > 0 && (

Meilenstein-Horizont

    {upcoming_milestones.map((ms) => (
  • {ms.title} {MILESTONE_STATUS_LABELS[ms.status] || ms.status} {ms.target_date ? ` · Ziel: ${formatDate(ms.target_date)}` : ''}
  • ))}
)}
{(counts.unlinked_blockers > 0 || counts.unlinked_evidence > 0) && (

{counts.unlinked_blockers > 0 && `${counts.unlinked_blockers} Blocker ohne Maßnahme`} {counts.unlinked_blockers > 0 && counts.unlinked_evidence > 0 && ' · '} {counts.unlinked_evidence > 0 && `${counts.unlinked_evidence} Nachweise ohne Maßnahme`} {' — unter „Erweitert“ verknüpfen oder aufräumen.'}

)}
) }