mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-08-02 17:11:51 +00:00
Moved management of filtering options to own reducer
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { LIST_SHORT_URLS } from '../../reducers/types';
|
||||
import { LIST_SHORT_URLS, UPDATE_SHORT_URLS_LIST } from '../../reducers/types';
|
||||
import ServersService from '../../servers/services';
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
|
||||
export default function shortUrlsListReducer(state = [], action) {
|
||||
switch (action.type) {
|
||||
case LIST_SHORT_URLS:
|
||||
case UPDATE_SHORT_URLS_LIST:
|
||||
return action.shortUrls;
|
||||
default:
|
||||
return state;
|
||||
@@ -20,3 +21,10 @@ export const listShortUrls = (serverId, params = {}) => {
|
||||
dispatch({ type: LIST_SHORT_URLS, shortUrls, selectedServer });
|
||||
};
|
||||
};
|
||||
|
||||
export const updateShortUrlsList = (params = {}) => {
|
||||
return async dispatch => {
|
||||
const shortUrls = await ShlinkApiClient.listShortUrls(params);
|
||||
dispatch({ type: UPDATE_SHORT_URLS_LIST, shortUrls, params });
|
||||
};
|
||||
};
|
||||
|
||||
10
src/short-urls/reducers/shortUrlsListParams.js
Normal file
10
src/short-urls/reducers/shortUrlsListParams.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { UPDATE_SHORT_URLS_LIST } from '../../reducers/types';
|
||||
|
||||
export default function shortUrlsListReducer(state = { page: 1 }, action) {
|
||||
switch (action.type) {
|
||||
case UPDATE_SHORT_URLS_LIST:
|
||||
return { ...state, ...action.params };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user