import { Link } from 'react-router-dom' import { useMemo, useState } from 'react' import { EmptyState } from './EmptyState.jsx' import { StatusBadge } from './StatusBadge.jsx' import { PriorityBadge } from './PriorityBadge.jsx' import { Modal } from './Modal.jsx' import { ActionForm } from './ActionForm.jsx' import { ActionTaskPanel } from './ActionTaskPanel.jsx' import { gateTitleById } from './GateSelect.jsx' import { buildProjectPath, collectProjectSubtreeIds } from '../utils/projectTree.js' import { actionPath } from '../utils/routes.js' import { formatBlockedByTitles, getActionExecutionMeta, sortActionsForExecutionPlan, } from '../utils/executionGraph.js' import { ExecutionFlowBadge } from './ExecutionFlowBadge.jsx' function formatProjectContext(projects, projectId) { if (!projectId) return 'Direkt am Vorhaben' const path = buildProjectPath(projects, projectId) return path.map((p) => p.title).join(' → ') } export function PlanActionsSection({ actions, projects = [], roadmapItems = [], scopeProjectId = '', hideDone, onHideDoneChange, canManage, onCreateAction, actors, actorsLoading, actorsError, actorsUsedFallback, onReloadActors, busy, executionGraph = null, sectionTitle = 'Arbeit', sectionLead = 'Committete Arbeitspakete und zugehörige Aufgaben — Ausführung über die Objektseite.', }) { const [showCreate, setShowCreate] = useState(false) const [expandedActions, setExpandedActions] = useState(() => new Set()) const visibleActions = useMemo(() => { let list = hideDone ? actions.filter((a) => a.status !== 'done' && a.status !== 'discarded') : [...actions] if (scopeProjectId) { const subtreeIds = collectProjectSubtreeIds(projects, scopeProjectId) list = list.filter((a) => a.project_id && subtreeIds.has(a.project_id)) } return sortActionsForExecutionPlan(list) }, [actions, hideDone, scopeProjectId, projects]) async function handleCreate(payload) { await onCreateAction(payload) setShowCreate(false) } function toggleActionTasks(actionId) { setExpandedActions((prev) => { const next = new Set(prev) if (next.has(actionId)) next.delete(actionId) else next.add(actionId) return next }) } return (

{sectionTitle}

{sectionLead}

{canManage && ( )}
{scopeProjectId && (

Gefiltert nach Projekt im Scope — Scope oben leeren für alle Arbeitspakete.

)} {visibleActions.length === 0 && ( )} setShowCreate(false)} size="lg"> setShowCreate(false)} busy={busy} submitLabel="Anlegen" />
) }