'use client' import React, { useState } from 'react' import TOMControlPanel from '@/components/sdk/obligations/TOMControlPanel' import { PRIORITY_COLORS, PRIORITY_LABELS, STATUS_COLORS, STATUS_LABELS, STATUS_NEXT, type Obligation, } from '../_types' export default function ObligationCard({ obligation, onStatusChange, onDetails, }: { obligation: Obligation onStatusChange: (id: string, status: string) => Promise onDetails: () => void }) { const [saving, setSaving] = useState(false) const [showTOM, setShowTOM] = useState(false) const daysUntil = obligation.deadline ? Math.ceil((new Date(obligation.deadline).getTime() - Date.now()) / 86400000) : null const handleMark = async (e: React.MouseEvent) => { e.stopPropagation() setSaving(true) await onStatusChange(obligation.id, STATUS_NEXT[obligation.status]) setSaving(false) } return (
{PRIORITY_LABELS[obligation.priority]} {STATUS_LABELS[obligation.status]} {obligation.source_article && ( {obligation.source} {obligation.source_article} )}

{obligation.title}

{obligation.description && (

{obligation.description}

)}
{obligation.responsible && 👤 {obligation.responsible}} {obligation.deadline && ( 📅 {new Date(obligation.deadline).toLocaleDateString('de-DE')} {daysUntil !== null && ` (${daysUntil < 0 ? `${Math.abs(daysUntil)}d überfällig` : `${daysUntil}d`})`} )}
e.stopPropagation()}> {obligation.status !== 'completed' && ( )}
{showTOM && (
e.stopPropagation()}> setShowTOM(false)} />
)}
) }