feat: add support for RADIO field type in filtering logic by including textValue in agent field matching
This commit is contained in:
@@ -498,12 +498,17 @@ export class AgentsService {
|
|||||||
select: {
|
select: {
|
||||||
agentProfileId: true,
|
agentProfileId: true,
|
||||||
jsonValue: true,
|
jsonValue: true,
|
||||||
|
textValue: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const matchingIds = matchingValues
|
const matchingIds = matchingValues
|
||||||
.filter((fv) => {
|
.filter((fv) => {
|
||||||
const jsonVal = fv.jsonValue as unknown;
|
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;
|
if (!Array.isArray(jsonVal)) return false;
|
||||||
// Direct match (normalized option values stored in jsonVal)
|
// Direct match (normalized option values stored in jsonVal)
|
||||||
if (selectedValues.some((sv) => jsonVal.includes(sv))) return true;
|
if (selectedValues.some((sv) => jsonVal.includes(sv))) return true;
|
||||||
@@ -672,6 +677,10 @@ export class AgentsService {
|
|||||||
const agentFieldValues = (agent.fieldValues || []) as any[];
|
const agentFieldValues = (agent.fieldValues || []) as any[];
|
||||||
const fieldMatch = agentFieldValues.some((fv: any) => {
|
const fieldMatch = agentFieldValues.some((fv: any) => {
|
||||||
if (fv.field?.slug !== filterSlug) return false;
|
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;
|
const jsonVal = fv.jsonValue as unknown;
|
||||||
if (!Array.isArray(jsonVal)) return false;
|
if (!Array.isArray(jsonVal)) return false;
|
||||||
// Direct match (normalized option values already stored in jsonVal)
|
// Direct match (normalized option values already stored in jsonVal)
|
||||||
|
|||||||
@@ -236,7 +236,12 @@ export class ProfileFieldsService {
|
|||||||
* De-duplicates by both slug AND name to handle duplicate fields with different slugs
|
* De-duplicates by both slug AND name to handle duplicate fields with different slugs
|
||||||
*/
|
*/
|
||||||
async getFilterableFields() {
|
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({
|
const fields = await this.prisma.profileField.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
Reference in New Issue
Block a user