refactor: restrict expertise tag extraction to only the about_me_expertise field
This commit is contained in:
@@ -191,67 +191,28 @@ function ProfileCard({ profile, resolvedAvatarUrl }: ProfileCardProps) {
|
|||||||
return null;
|
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 getExpertiseTags = (): string[] => {
|
||||||
const tags: string[] = [];
|
const tags: string[] = [];
|
||||||
|
if (!profile.fieldValues || profile.fieldValues.length === 0) return tags;
|
||||||
|
|
||||||
// Only include expertise-related field slugs (matching profileDataMapper.ts)
|
const fv = profile.fieldValues.find((f) => f.field.slug === 'about_me_expertise');
|
||||||
const expertiseFieldSlugs = [
|
if (!fv) return tags;
|
||||||
'about_me_expertise',
|
|
||||||
'expertise_areas',
|
|
||||||
'specializations',
|
|
||||||
'areas_of_expertise',
|
|
||||||
'expertise',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 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;
|
const value = fv.jsonValue;
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
// For multi-select fields, add all selected values
|
|
||||||
value.forEach((v) => {
|
value.forEach((v) => {
|
||||||
if (typeof v === 'string' && v.trim()) {
|
if (typeof v === 'string' && v.trim()) {
|
||||||
// Convert snake_case to Title Case for display
|
|
||||||
const displayValue = v
|
const displayValue = v
|
||||||
.split('_')
|
.split('_')
|
||||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
||||||
.join(' ');
|
.join(' ');
|
||||||
if (!tags.includes(displayValue)) {
|
if (!tags.includes(displayValue)) tags.push(displayValue);
|
||||||
tags.push(displayValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (typeof value === 'string' && value.trim()) {
|
} else if (typeof value === 'string' && value.trim() && !tags.includes(value)) {
|
||||||
if (!tags.includes(value)) {
|
|
||||||
tags.push(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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return tags;
|
return tags;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user