Skip to content

Commit

Permalink
fix: use combine operator & and |`
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Dec 11, 2024
1 parent 937ceac commit ab9b64b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions react/src/components/BAIPropertyFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ export function mergeFilterValues(
filterStrings: Array<string | undefined>,
operator: string = '&',
) {
return _.join(
const mergedFilter = _.join(
_.map(filterEmptyItem(filterStrings), (str) => `(${str})`),
operator,
);
return !!mergedFilter ? mergedFilter : undefined;
}

/**
Expand Down Expand Up @@ -129,7 +130,7 @@ export function parseFilterValue(filter: string) {
* @param operator - The logical operator to use ('and' or 'or').
* @returns The combined filter string.
*/
function combineFilters(filters: string[], operator: 'and' | 'or'): string {
function combineFilters(filters: string[], operator: '&' | '|'): string {
return filters.join(` ${operator} `);
}

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

Expand Down

0 comments on commit ab9b64b

Please sign in to comment.