Skip to content

Commit

Permalink
refactor getTransformedValue
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 20, 2023
1 parent 1c534e7 commit 677171b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/QueryBuilder/QueryBuilder/helpers/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,16 @@ export const isQueryValid = (source) => {
};

export const getTransformedValue = (val) => {
if (typeof val === 'string') return val.split(',').map(item => item.trim());
// cover the case when user types comma-separated values instead multi-select
if (typeof val === 'string') {
return val.split(',').map(item => item.trim());
}

if (Array.isArray(val)) {
return val.map(({ value }) => value);
}

return Array.isArray(val) ? val.map(({ value }) => value) : val;
return val;
};

export const sourceToMongoQuery = (source) => {
Expand Down

0 comments on commit 677171b

Please sign in to comment.