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';
|
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)
|
// Entire fields to hide from search filter UI (by stable slug — labels may change via admin)
|
||||||
const normalizeKey = (s: string) =>
|
const EXCLUDED_FIELD_SLUGS = new Set([
|
||||||
s.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '');
|
'expertise_areas', // "What Sets Us Apart" — filter UI hidden by request; profile form still uses it
|
||||||
const EXCLUDED_FIELD_KEYS = new Set([
|
|
||||||
'what_sets_us_apart',
|
|
||||||
'what_sets_you_apart',
|
|
||||||
]);
|
]);
|
||||||
const isExcludedField = (field: { slug: string; name: string }) =>
|
const isExcludedField = (field: { slug: string }) =>
|
||||||
EXCLUDED_FIELD_KEYS.has(normalizeKey(field.slug)) ||
|
EXCLUDED_FIELD_SLUGS.has(field.slug);
|
||||||
EXCLUDED_FIELD_KEYS.has(normalizeKey(field.name));
|
|
||||||
|
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (isExcludedField(field)) continue;
|
if (isExcludedField(field)) continue;
|
||||||
@@ -375,7 +371,7 @@ export class ProfileFieldsService {
|
|||||||
select: { id: true, name: true, slug: true, fieldType: true },
|
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({
|
const fieldValues = await this.prisma.agentProfileFieldValue.findMany({
|
||||||
where: {
|
where: {
|
||||||
fieldId: expertiseField.id,
|
fieldId: expertiseField.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user