import { useCallback, useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { listWorkspaceTodayActions } from '../api/workspace.js' import { StatusBadge } from '../components/StatusBadge.jsx' import { PriorityBadge } from '../components/PriorityBadge.jsx' import { EmptyState } from '../components/EmptyState.jsx' import { ErrorState } from '../components/ErrorState.jsx' import { LoadingState } from '../components/LoadingState.jsx' import { WidgetCard } from '../components/WidgetCard.jsx' import { actionPath, scopedPath } from '../utils/routes.js' function formatDue(iso) { if (!iso) return null try { return new Date(iso).toLocaleString('de-DE', { day: '2-digit', month: '2-digit', hour: '2-digit', minute: '2-digit', }) } catch { return iso } } export function WorkspaceTodayWidget() { const [actions, setActions] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) const load = useCallback(async () => { setLoading(true) setError(null) try { const data = await listWorkspaceTodayActions(10) setActions(Array.isArray(data) ? data : []) } catch (err) { setError(err.message) } finally { setLoading(false) } }, []) useEffect(() => { load() }, [load]) return ( Aktualisieren } footer={ actions.length > 0 ? ( Alle meine Maßnahmen → ) : null } > {loading && } {!loading && error && } {!loading && !error && actions.length === 0 && ( )} {!loading && !error && actions.length > 0 && (
    {actions.map((action) => (
  • {action.is_overdue && ( Überfällig )} {action.title} {action.initiative_title && ( {action.initiative_title} )} {action.due_at && ( Fällig: {formatDue(action.due_at)} )}
    Öffnen
  • ))}
)}
) }