Skip to content

Commit 8252a10

Browse files
committed
fix: use combine operator & and |` (#2938)
Resolves #2939 **Changes:** Updates the filter combination logic in BAIPropertyFilter to: - Return `undefined` instead of empty string when merging empty filter values - Change operator types from 'and'/'or' to '&'/'|' to match backend expectations - Standardize filter combination to use '&' operator consistently
1 parent 937ceac commit 8252a10

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

react/src/components/BAIPropertyFilter.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ export function mergeFilterValues(
9494
filterStrings: Array<string | undefined>,
9595
operator: string = '&',
9696
) {
97-
return _.join(
97+
const mergedFilter = _.join(
9898
_.map(filterEmptyItem(filterStrings), (str) => `(${str})`),
9999
operator,
100100
);
101+
return !!mergedFilter ? mergedFilter : undefined;
101102
}
102103

103104
/**
@@ -129,7 +130,7 @@ export function parseFilterValue(filter: string) {
129130
* @param operator - The logical operator to use ('and' or 'or').
130131
* @returns The combined filter string.
131132
*/
132-
function combineFilters(filters: string[], operator: 'and' | 'or'): string {
133+
function combineFilters(filters: string[], operator: '&' | '|'): string {
133134
return filters.join(` ${operator} `);
134135
}
135136

@@ -194,7 +195,7 @@ const BAIPropertyFilter: React.FC<BAIPropertyFilterProps> = ({
194195
item.type === 'string' ? `"${item.value}"` : item.value;
195196
return `${item.property} ${item.operator} ${valueStringInResult}`;
196197
});
197-
setValue(combineFilters(filterStrings, 'and')); // Change 'and' to 'or' if needed
198+
setValue(combineFilters(filterStrings, '&'));
198199
}
199200
}, [list, setValue]);
200201

0 commit comments

Comments
 (0)