"use client"; import { useNavigate } from "react-router-dom"; import { motion, AnimatePresence } from "framer-motion"; import type { SearchResult } from "@/types/search"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import AnimatedImage from "@/components/ui/animated-image"; interface SearchResultsProps { results: SearchResult[]; isLoading: boolean; hasSearched?: boolean; } export default function SearchResults({ results, isLoading, hasSearched = false, }: SearchResultsProps) { const navigate = useNavigate(); // Define animation variants const container = { hidden: { opacity: 0 }, show: { opacity: 1, transition: { staggerChildren: 0.1, }, }, }; const item = { hidden: { opacity: 0, y: 20 }, show: { opacity: 1, y: 0, transition: { duration: 0.5 } }, }; if (isLoading) { return (

Search Results

{[...Array(6)].map((_, i) => (
))}
); } if (results.length === 0 && hasSearched) { return (

No Results Found

Try adjusting your search criteria to find more records.

); } if (results.length === 0) { return null; } return (

Search Results ({results.length})

{results.map((person) => ( navigate(`/migrants/${person.person_id}`)}>
{person.full_name}

{person.migration?.date_of_arrival_nt ? `Arrived ${new Date(person.migration.date_of_arrival_nt).getFullYear()}` : 'Date unknown'}

From:{" "} {person.place_of_birth || 'Unknown'}, Italy

Settled in:{" "} {person.residence?.town_or_city || 'Unknown'}, NT

Occupation:{" "} {person.occupation || 'Unknown'}

))}
); }