'use client' import { memo } from 'react' import { highlightText } from '@/lib/utils' import Link from 'next/link' import { Calendar, Tag, AlertCircle } from 'lucide-react' import EmptyState from './EmptyState' interface SearchResultsProps { results: Array<{ id: string title: string description: string | null completed: boolean priority: string dueDate: Date | null tags: any notes: string | null list: { id: string title: string color: string } }> query: string onClose?: () => void } function SearchResults({ results, query, onClose }: SearchResultsProps) { if (!query.trim()) { return null } if (results.length === 0) { return ( ) } const priorityColors = { low: 'bg-green-100 text-green-700 border-green-200', medium: 'bg-yellow-100 text-yellow-700 border-yellow-200', high: 'bg-red-100 text-red-700 border-red-200', } return (

Found {results.length} {results.length === 1 ? 'task' : 'tasks'}

{results.map((item) => { const tags = Array.isArray(item.tags) ? item.tags : [] const isOverdue = item.dueDate && new Date(item.dueDate) < new Date() && !item.completed const priorityColor = priorityColors[item.priority as keyof typeof priorityColors] || priorityColors.medium return ( {/* List Badge */}
{item.list.title}
{/* Title with highlighting */}

{/* Description with highlighting */} {item.description && (

)} {/* Notes with highlighting (if matches) */} {item.notes && item.notes.toLowerCase().includes(query.toLowerCase()) && (

)} {/* Metadata */}

{/* Priority Badge */} {item.priority.charAt(0).toUpperCase() + item.priority.slice(1)} {/* Due Date */} {item.dueDate && ( {new Date(item.dueDate).toLocaleDateString('en-US', { month: 'short', day: 'numeric', })} {isOverdue && ' (Overdue)'} )} {/* Tags with highlighting */} {tags.length > 0 && (
{tags.length > 2 && ( {` +${tags.length - 2}`} )}
)}
) })}

) } export default memo(SearchResults)