mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-07-19 18:21:54 +00:00
Updated Short URLs list so that it allows setting default orderBy from settings
This commit is contained in:
@@ -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}`,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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'> {
|
||||
|
||||
Reference in New Issue
Block a user