import { CheckSquare, Square, ChevronRight, Flag, Calendar } from 'lucide-react'
import type { TodoItem } from '../../types'
import { katColor, PRIO_CONFIG, type Member } from './todoListModel'
/** A single task row in the todo list. Pure presentation; all behaviour is
* delegated to onSelect/onToggle so TodoListPanel stays a layout component. */
export default function TodoRow({ item, members, categories, today, isSelected, canEdit, formatDate, onSelect, onToggle }: {
item: TodoItem
members: Member[]
categories: string[]
today: string
isSelected: boolean
canEdit: boolean
formatDate: (d: string) => string
onSelect: (id: number | null) => void
onToggle: (id: number, checked: boolean) => void
}) {
const done = !!item.checked
const assignedUser = members.find(m => m.id === item.assigned_user_id)
const isOverdue = item.due_date && !done && item.due_date < today
const catColor = item.category ? katColor(item.category, categories) : null
return (
onSelect(isSelected ? null : item.id)}
style={{
display: 'flex', alignItems: 'center', gap: 10, padding: '10px 20px',
borderBottom: '1px solid var(--border-faint)', cursor: 'pointer',
background: isSelected ? 'var(--bg-hover)' : 'transparent',
transition: 'background 0.1s',
}}
onMouseEnter={e => { if (!isSelected) e.currentTarget.style.background = 'rgba(0,0,0,0.02)' }}
onMouseLeave={e => { if (!isSelected) e.currentTarget.style.background = 'transparent' }}>
{/* Checkbox */}
{/* Content */}
{item.name}
{/* Description preview */}
{item.description && (
{item.description}
)}
{/* Inline badges */}
{(item.priority || item.due_date || catColor || assignedUser) && (
{item.priority > 0 && PRIO_CONFIG[item.priority] && (
{PRIO_CONFIG[item.priority].label}
)}
{item.due_date && (
{formatDate(item.due_date)}
)}
{catColor && (
{item.category}
)}
{assignedUser && (
{assignedUser.avatar ? (
) : (
{assignedUser.username.charAt(0).toUpperCase()}
)}
{assignedUser.username}
)}
)}
{/* Chevron */}
)
}