Updated Short URLs list so that it allows setting default orderBy from settings

This commit is contained in:
Alejandro Celaya
2021-12-24 13:14:13 +01:00
parent d8442e435d
commit 57075c581d
12 changed files with 69 additions and 69 deletions

View File

@@ -24,12 +24,11 @@ const buildShlinkBaseUrl = (url: string, apiVersion: number) => url ? `${url}/re
const rejectNilProps = reject(isNil);
const normalizeOrderByInParams = (params: ShlinkShortUrlsListParams): ShlinkShortUrlsListNormalizedParams => {
const { orderBy = {}, ...rest } = params;
const [ firstKey ] = Object.keys(orderBy);
const [ firstValue ] = Object.values(orderBy);
const { field, dir } = orderBy;
return !firstValue ? rest : {
return !dir ? rest : {
...rest,
orderBy: `${firstKey}-${firstValue}`,
orderBy: `${field}-${dir}`,
};
};