1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-21 22:05:38 -04:00

Convert Log Events to React Query

This commit is contained in:
Mark McDowall
2025-02-27 20:20:56 -08:00
parent 5d7c94f8e9
commit 5342416659
20 changed files with 585 additions and 261 deletions
@@ -0,0 +1,37 @@
import { PropertyFilter } from 'App/State/AppState';
export interface QueryParams {
[key: string]: string | number | boolean | PropertyFilter[] | undefined;
}
const getQueryString = (queryParams?: QueryParams) => {
if (!queryParams) {
return '';
}
const filteredParams = Object.keys(queryParams).reduce<
Record<string, string>
>((acc, key) => {
const value = queryParams[key];
if (value == null) {
return acc;
}
if (Array.isArray(value)) {
value.forEach((filter) => {
acc[filter.key] = String(filter.value);
});
} else {
acc[key] = String(value);
}
return acc;
}, {});
const paramsString = new URLSearchParams(filteredParams).toString();
return `?${paramsString}`;
};
export default getQueryString;