'use client'
import { highlightText } from '@/lib/utils'
import Link from 'next/link'
import { Calendar, Tag, AlertCircle } from 'lucide-react'
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
}
export default function SearchResults({ results, query, onClose }: SearchResultsProps) {
if (!query.trim()) {
return null
}
if (results.length === 0) {
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 */}
{/* 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}`}
)}
)}
)
})}
)
}