import { useCallback, useEffect, useState } from 'react' import { createActionTask, deleteTask, listActionTasks, updateTask, } from '../api/tasks.js' import { TASK_STATUSES, TASK_STATUS_LABELS } from '../constants/status.js' import { EmptyState } from './EmptyState.jsx' export function TasksSection({ actionId, canManage }) { const [tasks, setTasks] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const [busy, setBusy] = useState(false) const [title, setTitle] = useState('') const load = useCallback(async () => { if (!actionId) return setLoading(true) setError(null) try { setTasks(await listActionTasks(actionId)) } catch (err) { setError(err.message) } finally { setLoading(false) } }, [actionId]) useEffect(() => { load() }, [load]) async function handleCreate(e) { e.preventDefault() if (!title.trim()) return setBusy(true) try { await createActionTask(actionId, { title: title.trim() }) setTitle('') await load() } catch (err) { setError(err.message) } finally { setBusy(false) } } async function handleStatus(taskId, status) { setBusy(true) try { await updateTask(taskId, { status }) await load() } catch (err) { setError(err.message) } finally { setBusy(false) } } async function handleDelete(taskId) { setBusy(true) try { await deleteTask(taskId) await load() } catch (err) { setError(err.message) } finally { setBusy(false) } } if (loading) return
Tasks werden geladen…
return (Kleinste ausführbare Schritte — später Zuordnung zu Gates (Zielerreichung).
{error}
} {canManage && ( )} {tasks.length === 0 && (