refactor: update field exclusion logic to use stable slugs and hide expertise areas from search filters
This commit is contained in:
@@ -308,16 +308,12 @@ export class ProfileFieldsService {
|
||||
return opt.label.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '') === 'prefer_not_to_say';
|
||||
};
|
||||
|
||||
// Entire fields to hide from search filter UI (still usable on profile forms via admin)
|
||||
const normalizeKey = (s: string) =>
|
||||
s.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '');
|
||||
const EXCLUDED_FIELD_KEYS = new Set([
|
||||
'what_sets_us_apart',
|
||||
'what_sets_you_apart',
|
||||
// Entire fields to hide from search filter UI (by stable slug — labels may change via admin)
|
||||
const EXCLUDED_FIELD_SLUGS = new Set([
|
||||
'expertise_areas', // "What Sets Us Apart" — filter UI hidden by request; profile form still uses it
|
||||
]);
|
||||
const isExcludedField = (field: { slug: string; name: string }) =>
|
||||
EXCLUDED_FIELD_KEYS.has(normalizeKey(field.slug)) ||
|
||||
EXCLUDED_FIELD_KEYS.has(normalizeKey(field.name));
|
||||
const isExcludedField = (field: { slug: string }) =>
|
||||
EXCLUDED_FIELD_SLUGS.has(field.slug);
|
||||
|
||||
for (const field of fields) {
|
||||
if (isExcludedField(field)) continue;
|
||||
@@ -375,7 +371,7 @@ export class ProfileFieldsService {
|
||||
select: { id: true, name: true, slug: true, fieldType: true },
|
||||
});
|
||||
|
||||
if (expertiseField && !mergedFields.has(expertiseField.slug)) {
|
||||
if (expertiseField && !isExcludedField(expertiseField) && !mergedFields.has(expertiseField.slug)) {
|
||||
const fieldValues = await this.prisma.agentProfileFieldValue.findMany({
|
||||
where: {
|
||||
fieldId: expertiseField.id,
|
||||
|
||||
Reference in New Issue
Block a user