diff --git a/src/app/(user)/user/profiles/page.tsx b/src/app/(user)/user/profiles/page.tsx index 503674f..6ee2803 100644 --- a/src/app/(user)/user/profiles/page.tsx +++ b/src/app/(user)/user/profiles/page.tsx @@ -191,66 +191,27 @@ function ProfileCard({ profile, resolvedAvatarUrl }: ProfileCardProps) { return null; }; - // Extract expertise tags from fieldValues - only include expertise-related fields + // Extract expertise tags — ONLY from the about_me_expertise field (matches admin filter source) const getExpertiseTags = (): string[] => { const tags: string[] = []; + if (!profile.fieldValues || profile.fieldValues.length === 0) return tags; - // Only include expertise-related field slugs (matching profileDataMapper.ts) - const expertiseFieldSlugs = [ - 'about_me_expertise', - 'expertise_areas', - 'specializations', - 'areas_of_expertise', - 'expertise', - ]; + const fv = profile.fieldValues.find((f) => f.field.slug === 'about_me_expertise'); + if (!fv) return tags; - // Add from fieldValues - only expertise-related fields - if (profile.fieldValues && profile.fieldValues.length > 0) { - profile.fieldValues.forEach((fv) => { - // Only include expertise-related fields - if (!expertiseFieldSlugs.includes(fv.field.slug)) { - return; - } - - const value = fv.jsonValue; - if (Array.isArray(value)) { - // For multi-select fields, add all selected values - value.forEach((v) => { - if (typeof v === 'string' && v.trim()) { - // Convert snake_case to Title Case for display - const displayValue = v - .split('_') - .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) - .join(' '); - if (!tags.includes(displayValue)) { - tags.push(displayValue); - } - } - }); - } else if (typeof value === 'string' && value.trim()) { - if (!tags.includes(value)) { - tags.push(value); - } - } - }); - } - - // Add from specializations array (legacy field) - if (profile.specializations && profile.specializations.length > 0) { - profile.specializations.forEach((spec) => { - if (!tags.includes(spec)) { - tags.push(spec); - } - }); - } - - // Add from languages array - if (profile.languages && profile.languages.length > 0) { - profile.languages.forEach((lang) => { - if (!tags.includes(lang)) { - tags.push(lang); + const value = fv.jsonValue; + if (Array.isArray(value)) { + value.forEach((v) => { + if (typeof v === 'string' && v.trim()) { + const displayValue = v + .split('_') + .map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()) + .join(' '); + if (!tags.includes(displayValue)) tags.push(displayValue); } }); + } else if (typeof value === 'string' && value.trim() && !tags.includes(value)) { + tags.push(value); } return tags;