fix(ui): remove starting underscore from the metada which were added to avoid coflicting with existing filter keys

This commit is contained in:
Shekar Siri 2024-06-27 19:35:18 +02:00
parent 094b3a7c06
commit d958549d64

View file

@ -146,12 +146,21 @@ function FilterAutoComplete(props: Props) {
}, [value]) }, [value])
const loadOptions = (inputValue: string, callback: (options: []) => void) => { const loadOptions = (inputValue: string, callback: (options: []) => void) => {
// remove underscore from params const _params = Object.keys(params).reduce((acc: any, key: string) => {
const _params: Record<string, string> = {} // all metadata keys start with underscore to avoid conflicts with predefined filter keys
const keys = Object.keys(params); // they should be removed before sending to the server
keys.forEach((key) => { if (key === 'type' && params[key] === 'metadata') {
_params[key.replace('_', '')] = params[key]; 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() new APIClient()
[method?.toLocaleLowerCase()](endpoint, { ..._params, q: inputValue }) [method?.toLocaleLowerCase()](endpoint, { ..._params, q: inputValue })