diff --git a/src/components/home/FeaturesSection.tsx b/src/components/home/FeaturesSection.tsx index 686f2e8..894c536 100644 --- a/src/components/home/FeaturesSection.tsx +++ b/src/components/home/FeaturesSection.tsx @@ -1,7 +1,9 @@ 'use client'; +import { useState, useEffect } from 'react'; import Image from 'next/image'; -import type { FeaturesContent } from '@/types/cms'; +import type { FeaturesContent, FeaturedAgentItem } from '@/types/cms'; +import { resolveImageUrl } from '@/services/cms.service'; const defaultContent: FeaturesContent = { title: 'Find Trusted Real Estate Professionals On Demand', @@ -28,108 +30,70 @@ const defaultContent: FeaturesContent = { description: 'Thousands of buyers, sellers, and renters trust our platform to find reliable agents. Our professionals help people navigate property journeys with confidence and ease.', }, ], + featuredAgents: [ + { name: 'Anderson', role: 'Rental & Investment Consultant', rating: '4.9', location: 'New York', experience: '7+ years in the real estate industry.', imageUrl: '/assets/images/agent-anderson.jpg' }, + { name: 'Deepak', role: 'Rental & Investment Consultant', rating: '4.9', location: 'New York', experience: '7+ years in the real estate industry.', imageUrl: '/assets/images/agent-deepak.jpg' }, + { name: 'Daniel', role: 'Rental & Investment Consultant', rating: '4.9', location: 'New York', experience: '7+ years in the real estate industry.', imageUrl: '/assets/images/agent-daniel.jpg' }, + ], }; -const agents = [ - { - name: 'Anderson', - role: 'Rental & Investment Consultant', - rating: '4.9', - location: 'New York', - experience: '7+ years in the real estate industry.', - image: '/assets/images/agent-anderson.jpg', - position: 'top-left', - }, - { - name: 'Deepak', - role: 'Rental & Investment Consultant', - rating: '4.9', - location: 'New York', - experience: '7+ years in the real estate industry.', - image: '/assets/images/agent-deepak.jpg', - position: 'top-right', - }, - { - name: 'Daniel', - role: 'Rental & Investment Consultant', - rating: '4.9', - location: 'New York', - experience: '7+ years in the real estate industry.', - image: '/assets/images/agent-daniel.jpg', - position: 'bottom-center', - }, -]; +function AgentCard({ agent, className = '' }: { agent: FeaturedAgentItem; className?: string }) { + const [imgLoaded, setImgLoaded] = useState(false); + const [imgSrc, setImgSrc] = useState(agent.imageUrl); + + useEffect(() => { + // Only resolve if it's an S3 key (not a URL or local path) + if (agent.imageUrl && !agent.imageUrl.startsWith('http') && !agent.imageUrl.startsWith('/')) { + resolveImageUrl(agent.imageUrl).then((url) => { + if (url) setImgSrc(url); + }); + } else { + setImgSrc(agent.imageUrl); + } + }, [agent.imageUrl]); -function AgentCard({ agent, className = '' }: { agent: typeof agents[0]; className?: string }) { return (
- {agent.role} -
- - {/* Verified & Rating */} +{agent.role}
- Experience: - {agent.experience} -
+ )} + {agent.experience && ( ++ Experience: + {agent.experience} +
+ )}- {data.subtitle} -
+{data.subtitle}
- {feature.description} -
+{feature.description}