diff --git a/src/components/home/HeroSection.tsx b/src/components/home/HeroSection.tsx index 90fa434..830be28 100644 --- a/src/components/home/HeroSection.tsx +++ b/src/components/home/HeroSection.tsx @@ -1,39 +1,39 @@ 'use client'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import Image from 'next/image'; - -const propertyTypes = [ - { value: '', label: 'Types' }, - { value: 'professionals', label: 'Professionals' }, - { value: 'lenders', label: 'Lenders' }, -]; - -const categories = [ - { value: '', label: 'Categories' }, - { value: 'luxury-homes', label: 'Luxury Homes' }, - { value: 'commercial', label: 'Commercial' }, - { value: 'mortgages', label: 'Mortgages' }, -]; +import { agentsService, AgentType } from '@/services/agents.service'; export function HeroSection() { const router = useRouter(); + const [agentTypes, setAgentTypes] = useState([]); const [searchParams, setSearchParams] = useState({ type: '', name: '', location: '', - category: '', }); 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); - if (searchParams.category) params.set('category', searchParams.category); router.push(`/user/profiles?${params.toString()}`); }; @@ -45,8 +45,8 @@ export function HeroSection() { setOpenDropdown(openDropdown === dropdown ? null : dropdown); }; - const selectOption = (field: 'type' | 'category', value: string, label: string) => { - setSearchParams({ ...searchParams, [field]: value }); + const selectType = (value: string) => { + setSearchParams({ ...searchParams, type: value }); setOpenDropdown(null); }; @@ -79,13 +79,13 @@ export function HeroSection() {
{/* Type Select */} -
+
{openDropdown === 'type' && ( -
- {propertyTypes.slice(1).map((type, index, arr) => ( +
+ {agentTypes.map((type, index, arr) => ( ))}
@@ -132,38 +132,6 @@ export function HeroSection() { />
- {/* Category Select */} -
- - {openDropdown === 'category' && ( -
- {categories.slice(1).map((cat, index, arr) => ( - - ))} -
- )} -
- {/* Search Button */}