feat: add profile links to featured agents and professionals by updating CMS types and card components
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
|
import Link from 'next/link';
|
||||||
import type { FeaturesContent, FeaturedAgentItem } from '@/types/cms';
|
import type { FeaturesContent, FeaturedAgentItem } from '@/types/cms';
|
||||||
import { resolveImageUrl } from '@/services/cms.service';
|
import { resolveImageUrl } from '@/services/cms.service';
|
||||||
|
|
||||||
@@ -21,8 +22,8 @@ function AgentCard({ agent, className = '' }: { agent: FeaturedAgentItem; classN
|
|||||||
}
|
}
|
||||||
}, [agent.imageUrl]);
|
}, [agent.imageUrl]);
|
||||||
|
|
||||||
return (
|
const cardInner = (
|
||||||
<div className={`bg-white border border-[#00293d]/10 rounded-[15px] w-[254px] overflow-hidden ${className}`}>
|
<div className={`bg-white border border-[#00293d]/10 rounded-[15px] w-[254px] overflow-hidden ${agent.id ? 'hover:shadow-xl transition-shadow cursor-pointer' : ''} ${className}`}>
|
||||||
<div className="h-[161px] w-full overflow-hidden rounded-t-[15px] bg-gray-100 relative">
|
<div className="h-[161px] w-full overflow-hidden rounded-t-[15px] bg-gray-100 relative">
|
||||||
{imgSrc && (
|
{imgSrc && (
|
||||||
<img
|
<img
|
||||||
@@ -66,6 +67,11 @@ function AgentCard({ agent, className = '' }: { agent: FeaturedAgentItem; classN
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (agent.id) {
|
||||||
|
return <Link href={`/user/profile/${agent.id}`}>{cardInner}</Link>;
|
||||||
|
}
|
||||||
|
return cardInner;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FeaturesSection({ content }: { content?: FeaturesContent }) {
|
export function FeaturesSection({ content }: { content?: FeaturesContent }) {
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ async function resolveAvatarUrl(avatar: string | null): Promise<string> {
|
|||||||
|
|
||||||
interface DisplayProfessional {
|
interface DisplayProfessional {
|
||||||
id: string;
|
id: string;
|
||||||
|
profileId?: string;
|
||||||
name: string;
|
name: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
location: string;
|
location: string;
|
||||||
@@ -249,6 +250,7 @@ export function TopProfessionals({ content }: { content?: TopProfessionalsConten
|
|||||||
const imageUrl = await resolveAvatarUrl(entry.imageUrl || null);
|
const imageUrl = await resolveAvatarUrl(entry.imageUrl || null);
|
||||||
return {
|
return {
|
||||||
id: `cms-${index}`,
|
id: `cms-${index}`,
|
||||||
|
profileId: entry.id,
|
||||||
name: entry.name,
|
name: entry.name,
|
||||||
subtitle: entry.subtitle || '',
|
subtitle: entry.subtitle || '',
|
||||||
location: entry.location || '',
|
location: entry.location || '',
|
||||||
@@ -358,19 +360,31 @@ export function TopProfessionals({ content }: { content?: TopProfessionalsConten
|
|||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
) : displayData.length > 0 ? (
|
) : displayData.length > 0 ? (
|
||||||
displayData.map((professional) => (
|
displayData.map((professional) => {
|
||||||
<ProfessionalCard
|
const card = (
|
||||||
key={professional.id}
|
<ProfessionalCard
|
||||||
name={professional.name}
|
name={professional.name}
|
||||||
subtitle={professional.subtitle}
|
subtitle={professional.subtitle}
|
||||||
location={professional.location}
|
location={professional.location}
|
||||||
experience={professional.experience}
|
experience={professional.experience}
|
||||||
expertise={professional.expertise}
|
expertise={professional.expertise}
|
||||||
imageUrl={professional.imageUrl}
|
imageUrl={professional.imageUrl}
|
||||||
isVerified={professional.isVerified}
|
isVerified={professional.isVerified}
|
||||||
rating={professional.rating}
|
rating={professional.rating}
|
||||||
/>
|
/>
|
||||||
))
|
);
|
||||||
|
return professional.profileId ? (
|
||||||
|
<Link
|
||||||
|
key={professional.id}
|
||||||
|
href={`/user/profile/${professional.profileId}`}
|
||||||
|
className="hover:shadow-xl transition-shadow rounded-[15px]"
|
||||||
|
>
|
||||||
|
{card}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div key={professional.id}>{card}</div>
|
||||||
|
);
|
||||||
|
})
|
||||||
) : (
|
) : (
|
||||||
// No data message
|
// No data message
|
||||||
<div className="col-span-3 flex items-center justify-center py-12">
|
<div className="col-span-3 flex items-center justify-center py-12">
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export interface FeatureItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface FeaturedAgentItem {
|
export interface FeaturedAgentItem {
|
||||||
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
role: string;
|
role: string;
|
||||||
rating: string;
|
rating: string;
|
||||||
@@ -28,6 +29,7 @@ export interface FeaturesContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfessionalItem {
|
export interface ProfessionalItem {
|
||||||
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
location: string;
|
location: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user