From 678630fa8e8b944f1af1acb0f4c55908480c5598 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 15 Apr 2026 23:45:12 +0530 Subject: [PATCH] feat: add support for RADIO field type in filtering logic by including textValue in agent field matching --- src/agents/agents.service.ts | 9 +++++++++ src/profile-fields/profile-fields.service.ts | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/agents/agents.service.ts b/src/agents/agents.service.ts index 63618d6..c6e2bb5 100644 --- a/src/agents/agents.service.ts +++ b/src/agents/agents.service.ts @@ -498,12 +498,17 @@ export class AgentsService { select: { agentProfileId: true, jsonValue: true, + textValue: true, }, }); const matchingIds = matchingValues .filter((fv) => { const jsonVal = fv.jsonValue as unknown; + // RADIO / SELECT values live in textValue (single string) + if (typeof fv.textValue === 'string' && fv.textValue) { + if (selectedValues.includes(fv.textValue)) return true; + } if (!Array.isArray(jsonVal)) return false; // Direct match (normalized option values stored in jsonVal) if (selectedValues.some((sv) => jsonVal.includes(sv))) return true; @@ -672,6 +677,10 @@ export class AgentsService { const agentFieldValues = (agent.fieldValues || []) as any[]; const fieldMatch = agentFieldValues.some((fv: any) => { if (fv.field?.slug !== filterSlug) return false; + // RADIO / SELECT values live in textValue + if (typeof fv.textValue === 'string' && fv.textValue) { + if (selectedValues.includes(fv.textValue)) return true; + } const jsonVal = fv.jsonValue as unknown; if (!Array.isArray(jsonVal)) return false; // Direct match (normalized option values already stored in jsonVal) diff --git a/src/profile-fields/profile-fields.service.ts b/src/profile-fields/profile-fields.service.ts index 66ab726..04ab87a 100644 --- a/src/profile-fields/profile-fields.service.ts +++ b/src/profile-fields/profile-fields.service.ts @@ -236,7 +236,12 @@ export class ProfileFieldsService { * De-duplicates by both slug AND name to handle duplicate fields with different slugs */ async getFilterableFields() { - const filterableTypes: FieldType[] = [FieldType.CHECKBOX_GROUP, FieldType.SELECT, FieldType.MULTI_SELECT]; + const filterableTypes: FieldType[] = [ + FieldType.CHECKBOX_GROUP, + FieldType.SELECT, + FieldType.MULTI_SELECT, + FieldType.RADIO, // experience-style single-choice fields (years_in_business, contracts_completed) + ]; const fields = await this.prisma.profileField.findMany({ where: {