diff --git a/src/app/dashboard/cms/page.tsx b/src/app/dashboard/cms/page.tsx index f616949..801638a 100644 --- a/src/app/dashboard/cms/page.tsx +++ b/src/app/dashboard/cms/page.tsx @@ -223,7 +223,7 @@ export default function CmsPage() { return () => document.removeEventListener('mousedown', handleClickOutside); }, []); - // Agent search with debounce + // Agent search with debounce — searches only verified agents function handleAgentSearch(query: string) { setAgentSearchQuery(query); if (agentSearchTimeout.current) clearTimeout(agentSearchTimeout.current); @@ -236,7 +236,7 @@ export default function CmsPage() { setShowAgentDropdown(true); agentSearchTimeout.current = setTimeout(async () => { try { - const res = await usersService.getUsers({ role: 'AGENT', search: query, limit: 10 }); + const res = await usersService.getUsers({ role: 'AGENT', search: query, limit: 10, verificationStatus: 'APPROVED' }); setAgentSearchResults(res.users); } catch { setAgentSearchResults([]); @@ -263,6 +263,26 @@ export default function CmsPage() { setShowAgentDropdown(false); } + // Select agent for Featured Agent Cards (different format) + function selectFeaturedAgent(user: User) { + const data = editContent as FeaturesContent; + if ((data.featuredAgents || []).length >= 3) return; + const profile = user.profile; + const agent = user.agentProfile; + const name = profile ? `${profile.firstName} ${profile.lastName}`.trim() : ''; + const role = agent?.agentType?.name || agent?.headline || ''; + const location = profile ? [profile.city, profile.state].filter(Boolean).join(', ') : ''; + const experience = agent?.yearsOfExperience ? `${agent.yearsOfExperience}+ years in real estate.` : ''; + const rating = ''; + const imageUrl = profile?.avatar || ''; + + const newAgent: FeaturedAgentItem = { name, role, rating, location, experience, imageUrl }; + setEditContent({ ...data, featuredAgents: [...(data.featuredAgents || []), newAgent] }); + setAgentSearchQuery(''); + setAgentSearchResults([]); + setShowAgentDropdown(false); + } + // Helpers function recordFor(pageSlug: string, sectionKey: string): CmsContentRecord | undefined { const source = pageSlug === 'about' ? aboutRecords : pageSlug === 'faq' ? faqRecords : records; @@ -442,6 +462,51 @@ export default function CmsPage() { {/* Featured Agents Tab */} {featuresTab === 'agents' && (