Skip to content

Commit

Permalink
fix(ui): remove starting underscore from the metada which were added …
Browse files Browse the repository at this point in the history
…to avoid coflicting with existing filter keys
  • Loading branch information
shekarsiri committed May 30, 2024
1 parent 8213162 commit 8196162
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,21 @@ function FilterAutoComplete(props: Props) {
}, [value])

const loadOptions = (inputValue: string, callback: (options: []) => void) => {
// remove underscore from params
const _params: Record<string, string> = {}
const keys = Object.keys(params);
keys.forEach((key) => {
_params[key.replace('_', '')] = params[key];
})
const _params = Object.keys(params).reduce((acc: any, key: string) => {
// all metadata keys start with underscore to avoid conflicts with predefined filter keys
// they should be removed before sending to the server
if (key === 'type' && params[key] === 'metadata') {
acc['key'] = params['key'].replace(/^_/, '');
acc['type'] = 'metadata';
}
return acc;
}, {});

// const _params: Record<string, string> = {}
// const keys = Object.keys(params);
// keys.forEach((key) => {
// _params[key.replace('_', '')] = params[key];
// })

new APIClient()
[method?.toLocaleLowerCase()](endpoint, { ..._params, q: inputValue })
Expand Down

0 comments on commit 8196162

Please sign in to comment.