-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: lowercase operators support in the where clause is upda…
- Loading branch information
1 parent
0d3cbb1
commit f3c00e1
Showing
7 changed files
with
99 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 21 additions & 13 deletions
34
frontend/src/hooks/queryBuilder/useSetCurrentKeyAndOperator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
import { getTagToken } from 'container/QueryBuilder/filters/QueryBuilderSearch/utils'; | ||
import { useMemo, useRef } from 'react'; | ||
import { | ||
getRemovePrefixFromKey, | ||
getTagToken, | ||
} from 'container/QueryBuilder/filters/QueryBuilderSearch/utils'; | ||
import { useMemo } from 'react'; | ||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse'; | ||
|
||
type ICurrentKeyAndOperator = [string, string, string[]]; | ||
|
||
export const useSetCurrentKeyAndOperator = ( | ||
value: string, | ||
keys: BaseAutocompleteData[], | ||
): ICurrentKeyAndOperator => { | ||
const keyRef = useRef<string>(''); | ||
const operatorRef = useRef<string>(''); | ||
|
||
const result = useMemo(() => { | ||
const [key, operator, result] = useMemo(() => { | ||
let key = ''; | ||
let operator = ''; | ||
let result: string[] = []; | ||
const { tagKey, tagOperator, tagValue } = getTagToken(value); | ||
const isSuggestKey = keys?.some( | ||
(el) => el?.key === getRemovePrefixFromKey(tagKey), | ||
); | ||
if (isSuggestKey || keys.length === 0) { | ||
key = tagKey || ''; | ||
operator = tagOperator || ''; | ||
result = tagValue || []; | ||
} | ||
|
||
keyRef.current = tagKey || ''; | ||
operatorRef.current = tagOperator || ''; | ||
result = tagValue || []; | ||
|
||
return result; | ||
}, [value]); | ||
return [key, operator, result]; | ||
}, [value, keys]); | ||
|
||
return [keyRef.current, operatorRef.current, result]; | ||
return [key, operator, result]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters