Added short URLs orderBy handling to the query state

This commit is contained in:
Alejandro Celaya
2021-12-25 19:51:25 +01:00
parent 91f319df65
commit 49c841ca07
12 changed files with 94 additions and 52 deletions

View File

@@ -19,17 +19,14 @@ import {
ShlinkShortUrlsListNormalizedParams,
} from '../types';
import { stringifyQuery } from '../../utils/helpers/query';
import { orderToString } from '../../utils/helpers/ordering';
const buildShlinkBaseUrl = (url: string, apiVersion: number) => url ? `${url}/rest/v${apiVersion}` : '';
const rejectNilProps = reject(isNil);
const normalizeOrderByInParams = (params: ShlinkShortUrlsListParams): ShlinkShortUrlsListNormalizedParams => {
const { orderBy = {}, ...rest } = params;
const { field, dir } = orderBy;
return !dir ? rest : {
...rest,
orderBy: `${field}-${dir}`,
};
return { ...rest, orderBy: orderToString(orderBy) };
};
export default class ShlinkApiClient {