'use client'; import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import Image from 'next/image'; import { agentsService, AgentType } from '@/services/agents.service'; export function HeroSection() { const router = useRouter(); const [agentTypes, setAgentTypes] = useState([]); const [searchParams, setSearchParams] = useState({ type: '', name: '', location: '', }); const [openDropdown, setOpenDropdown] = useState(null); // Fetch agent types on mount useEffect(() => { const fetchAgentTypes = async () => { try { const types = await agentsService.getAgentTypes(); setAgentTypes(types); } catch (error) { console.error('Failed to fetch agent types:', error); } }; fetchAgentTypes(); }, []); const handleSearch = () => { const params = new URLSearchParams(); if (searchParams.type) params.set('type', searchParams.type); if (searchParams.name) params.set('name', searchParams.name); if (searchParams.location) params.set('location', searchParams.location); router.push(`/user/profiles?${params.toString()}`); }; const handleSeeAllAgents = () => { router.push('/user/profiles'); }; const toggleDropdown = (dropdown: string) => { setOpenDropdown(openDropdown === dropdown ? null : dropdown); }; const selectType = (value: string) => { setSearchParams({ ...searchParams, type: value }); setOpenDropdown(null); }; return (
{/* Background Image */}
{/* Headline */}

“Discover verified, top-rated real estate professionals to guide your buying, selling, or investing journey.”

Discover verified, top-rated real estate professionals

{/* Search Form */}
{/* Type Select */}
{openDropdown === 'type' && (
{agentTypes.map((type, index, arr) => ( ))}
)}
{/* Name Input */}
setSearchParams({ ...searchParams, name: e.target.value })} className="w-full h-[42px] px-4 rounded-[7px] border border-[#00293d]/10 bg-white font-serif text-sm text-[#00293d] placeholder:text-[#00293d] focus:outline-none" />
{/* Location Input */}
setSearchParams({ ...searchParams, location: e.target.value })} className="w-full h-[42px] px-4 rounded-[7px] border border-[#00293d]/10 bg-white font-serif text-sm text-[#00293d] placeholder:text-[#00293d] focus:outline-none" />
{/* Search Button */}
{/* Bottom Section - pushed to bottom */}
{/* See All Agents Button */}
{/* Helper Text */}

Connect with trusted local agents to explore homes, compare options, and make smarter decisions.

); }