mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-18 13:33:51 +00:00
Refactored shortUrlsListParams reducer to takle advantage of redux-actions
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { createAction, handleActions } from 'redux-actions';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { LIST_SHORT_URLS } from './shortUrlsList';
|
import { LIST_SHORT_URLS } from './shortUrlsList';
|
||||||
|
|
||||||
@@ -11,15 +12,9 @@ export const shortUrlsListParamsType = PropTypes.shape({
|
|||||||
|
|
||||||
const defaultState = { page: '1' };
|
const defaultState = { page: '1' };
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export default handleActions({
|
||||||
switch (action.type) {
|
[LIST_SHORT_URLS]: (state, { params }) => ({ ...state, ...params }),
|
||||||
case LIST_SHORT_URLS:
|
[RESET_SHORT_URL_PARAMS]: () => defaultState,
|
||||||
return { ...state, ...action.params };
|
}, defaultState);
|
||||||
case RESET_SHORT_URL_PARAMS:
|
|
||||||
return defaultState;
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const resetShortUrlParams = () => ({ type: RESET_SHORT_URL_PARAMS });
|
export const resetShortUrlParams = createAction(RESET_SHORT_URL_PARAMS);
|
||||||
|
|||||||
Reference in New Issue
Block a user