mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-28 04:36:45 +00:00
Updated short URL list params so that it requests dateCreated DESC ordering by default
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { faCaretDown as caretDownIcon, faCaretUp as caretUpIcon } from '@fortawesome/free-solid-svg-icons';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { head, isEmpty, keys, values } from 'ramda';
|
||||
import React, { useState, useEffect, FC } from 'react';
|
||||
import React, { FC, useEffect, useState } from 'react';
|
||||
import qs from 'qs';
|
||||
import { RouteComponentProps } from 'react-router';
|
||||
import SortingDropdown from '../utils/SortingDropdown';
|
||||
@@ -11,17 +11,9 @@ import { boundToMercureHub } from '../mercure/helpers/boundToMercureHub';
|
||||
import { ShortUrlsList as ShortUrlsListState } from './reducers/shortUrlsList';
|
||||
import { ShortUrlsRowProps } from './helpers/ShortUrlsRow';
|
||||
import { ShortUrl } from './data';
|
||||
import { ShortUrlsListParams } from './reducers/shortUrlsListParams';
|
||||
import { OrderableFields, ShortUrlsListParams, SORTABLE_FIELDS } from './reducers/shortUrlsListParams';
|
||||
import './ShortUrlsList.scss';
|
||||
|
||||
export const SORTABLE_FIELDS = {
|
||||
dateCreated: 'Created at',
|
||||
shortCode: 'Short URL',
|
||||
longUrl: 'Long URL',
|
||||
visits: 'Visits',
|
||||
};
|
||||
type OrderableFields = keyof typeof SORTABLE_FIELDS;
|
||||
|
||||
interface RouteParams {
|
||||
page: string;
|
||||
serverId: string;
|
||||
|
||||
@@ -4,16 +4,28 @@ import { LIST_SHORT_URLS, ListShortUrlsAction } from './shortUrlsList';
|
||||
|
||||
export const RESET_SHORT_URL_PARAMS = 'shlink/shortUrlsListParams/RESET_SHORT_URL_PARAMS';
|
||||
|
||||
export const SORTABLE_FIELDS = {
|
||||
dateCreated: 'Created at',
|
||||
shortCode: 'Short URL',
|
||||
longUrl: 'Long URL',
|
||||
visits: 'Visits',
|
||||
};
|
||||
|
||||
export type OrderableFields = keyof typeof SORTABLE_FIELDS;
|
||||
|
||||
export interface ShortUrlsListParams {
|
||||
page?: string;
|
||||
tags?: string[];
|
||||
searchTerm?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
orderBy?: Record<string, OrderDir>;
|
||||
orderBy?: Partial<Record<OrderableFields, OrderDir>>;
|
||||
}
|
||||
|
||||
const initialState: ShortUrlsListParams = { page: '1' };
|
||||
const initialState: ShortUrlsListParams = {
|
||||
page: '1',
|
||||
orderBy: { dateCreated: 'DESC' },
|
||||
};
|
||||
|
||||
export default buildReducer<ShortUrlsListParams, ListShortUrlsAction>({
|
||||
[LIST_SHORT_URLS]: (state, { params }) => ({ ...state, ...params }),
|
||||
|
||||
Reference in New Issue
Block a user