import { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { getInitiativeExecutionGraphState } from '../api/executionPlan.js' import { LoadingState } from './LoadingState.jsx' import { ErrorState } from './ErrorState.jsx' import { EmptyState } from './EmptyState.jsx' import { StatusBadge } from './StatusBadge.jsx' import { ExecutionFlowBadge } from './ExecutionFlowBadge.jsx' import { buildCriticalPathSteps, summarizeCriticalPath, } from '../utils/executionGraph.js' import { actionPath, scopedPath } from '../utils/routes.js' export function CriticalPathPanel({ initiativeId, actions = [], graphState: kernelGraphState = null, graphLoading = false, scopeRoadmapItemId = null, embedded = true, }) { const useKernelGraph = kernelGraphState != null || graphLoading const [fallbackGraphState, setFallbackGraphState] = useState(null) const [fallbackLoading, setFallbackLoading] = useState(!useKernelGraph) const [error, setError] = useState(null) useEffect(() => { if (!initiativeId || useKernelGraph) { setFallbackGraphState(null) setFallbackLoading(false) return undefined } let cancelled = false setFallbackLoading(true) setError(null) getInitiativeExecutionGraphState(initiativeId, { scopeRoadmapItemId: scopeRoadmapItemId || undefined, }) .then((data) => { if (!cancelled) setFallbackGraphState(data) }) .catch((err) => { if (!cancelled) setError(err.message) }) .finally(() => { if (!cancelled) setFallbackLoading(false) }) return () => { cancelled = true } }, [initiativeId, scopeRoadmapItemId, useKernelGraph]) const graphState = useKernelGraph ? kernelGraphState : fallbackGraphState const loading = useKernelGraph ? graphLoading : fallbackLoading const steps = buildCriticalPathSteps(graphState, actions) const summary = summarizeCriticalPath(graphState, actions) const body = ( <> {loading && } {!loading && error && ( window.location.reload()} /> )} {!loading && !error && steps.length === 0 && ( )} {!loading && !error && steps.length > 0 && ( <>

{summary.message}

    {steps.map((step) => (
  1. {step.index}
    {step.title}

    {step.reason}

  2. ))}

Graph unter{' '} Plan → Zielzustände {' '}pflegen.

)} ) if (embedded) { return (

Kritischer Pfad

Abhängigkeitspfad im aktiven Gate-Horizont — Steuerungsantwort für lineare Vorhaben (A2).

{body}
) } return body }