'use client'; import { useState, useEffect } from 'react'; import Image from 'next/image'; import type { FeaturesContent, FeaturedAgentItem } from '@/types/cms'; import { resolveImageUrl } from '@/services/cms.service'; const defaultContent: FeaturesContent = { title: 'Find Trusted Real Estate Professionals On Demand', subtitle: 'Quickly connect with the right agents exactly when you need them.', features: [ { iconPath: '/assets/icons/hourglass-icon.svg', title: 'Hire Quickly', description: 'Connect with experienced local real estate agents who match your needs and preferences. Our simple process helps you get started quickly and move forward without delays or unnecessary complexity.', }, { iconPath: '/assets/icons/verified-badge-icon.svg', title: 'Verified Agents', description: 'All agents are carefully identity-verified and background-checked to ensure trust and safety. You can confidently work with professionals who meet quality and reliability standards.', }, { iconPath: '/assets/icons/star-orange-icon.svg', title: 'Top Rated', description: 'Work with highly rated agents known for strong expertise and positive client feedback. Their consistent performance helps you make informed and confident property decisions.', }, { iconPath: '/assets/icons/trusted-people-icon.svg', title: 'Trusted by Thousands', 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' }, ], }; 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]); return (
{agent.role}
Experience: {agent.experience}
)}{data.subtitle}
{feature.description}