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}`,
};
};

View File

@@ -1,7 +1,7 @@
import { Visit } from '../../visits/types';
import { OptionalString } from '../../utils/utils';
import { ShortUrl, ShortUrlMeta } from '../../short-urls/data';
import { OrderBy } from '../../short-urls/reducers/shortUrlsListParams';
import { ShortUrlsOrder } from '../../short-urls/reducers/shortUrlsListParams';
export interface ShlinkShortUrlsResponse {
data: ShortUrl[];
@@ -94,7 +94,7 @@ export interface ShlinkShortUrlsListParams {
searchTerm?: string;
startDate?: string;
endDate?: string;
orderBy?: OrderBy;
orderBy?: ShortUrlsOrder;
}
export interface ShlinkShortUrlsListNormalizedParams extends Omit<ShlinkShortUrlsListParams, 'orderBy'> {