'use client' import { Deadline } from '@/types' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { cn } from '@/lib/utils' import { isDeadlineOverdue, DEADLINE_TYPE_LABELS, PRIORITY_LABELS, PRIORITY_COLORS, } from '@/lib/calendar/utils' import { CheckCircle, Circle, Clock, AlertTriangle, Trash2, Edit2 } from 'lucide-react' interface DeadlineCardProps { deadline: Deadline onToggle: (deadline: Deadline) => void onEdit?: (deadline: Deadline) => void onDelete?: (deadline: Deadline) => void compact?: boolean } export function DeadlineCard({ deadline, onToggle, onEdit, onDelete, compact = false, }: DeadlineCardProps) { const overdue = isDeadlineOverdue(deadline) const completed = deadline.is_completed const priorityStyle = PRIORITY_COLORS[deadline.priority] const formatDueDate = () => { const date = new Date(deadline.due_date) const formatted = date.toLocaleDateString('sv-SE', { day: 'numeric', month: 'short', }) if (deadline.due_time) { return `${formatted} kl. ${deadline.due_time.slice(0, 5)}` } return formatted } if (compact) { return (

{deadline.title}

{deadline.priority !== 'normal' && !completed && (
)}
) } return (

{deadline.title}

{formatDueDate()}

{deadline.customer && (

{deadline.customer.name}

)}
{DEADLINE_TYPE_LABELS[deadline.deadline_type]} {!completed && deadline.priority !== 'normal' && ( {PRIORITY_LABELS[deadline.priority]} )} {overdue && !completed && ( Förfallen )}
{deadline.notes && (

{deadline.notes}

)}
{(onEdit || onDelete) && (
{onEdit && ( )} {onDelete && ( )}
)}
) }