Skip to content

Commit

Permalink
fix: handle operator case change in api and ui (#5835)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikrantgupta25 authored Sep 2, 2024
1 parent e4753e6 commit 709c286
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import { PLACEHOLDER } from '../QueryBuilderSearch/constant';
import { TypographyText } from '../QueryBuilderSearch/style';
import {
checkCommaInValue,
getOperatorFromValue,
getOperatorValue,
getTagToken,
isInNInOperator,
} from '../QueryBuilderSearch/utils';
Expand Down Expand Up @@ -103,8 +105,8 @@ function getInitTags(query: IBuilderQuery): ITag[] {
return query.filters.items.map((item) => ({
id: item.id,
key: item.key as BaseAutocompleteData,
op: item.op,
value: `${item.value}`,
op: getOperatorFromValue(item.op),
value: item.value,
}));
}

Expand Down Expand Up @@ -332,7 +334,7 @@ function QueryBuilderSearchV2(
{
key: currentFilterItem?.key,
op: currentFilterItem?.op,
value: tagValue.join(','),
value: tagValue,
} as ITag,
]);
return;
Expand Down Expand Up @@ -700,17 +702,28 @@ function QueryBuilderSearchV2(
items: [],
};
tags.forEach((tag) => {
const computedTagValue =
tag.value &&
Array.isArray(tag.value) &&
tag.value[tag.value.length - 1] === ''
? tag.value?.slice(0, -1)
: tag.value ?? '';
filterTags.items.push({
id: tag.id || uuid().slice(0, 8),
key: tag.key,
op: tag.op,
value: tag.value,
op: getOperatorValue(tag.op),
value: computedTagValue,
});
});

if (!isEqual(query.filters, filterTags)) {
onChange(filterTags);
setTags(filterTags.items as ITag[]);
setTags(
filterTags.items.map((tag) => ({
...tag,
op: getOperatorFromValue(tag.op),
})) as ITag[],
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tags]);
Expand Down

0 comments on commit 709c286

Please sign in to comment.