mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-03-14 02:08:41 +03:00
Refactored shortUrlsListParams reducer to takle advantage of redux-actions
This commit is contained in:
parent
4a09d99322
commit
4894ab9035
1 changed files with 6 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
|||
import { createAction, handleActions } from 'redux-actions';
|
||||
import PropTypes from 'prop-types';
|
||||
import { LIST_SHORT_URLS } from './shortUrlsList';
|
||||
|
||||
|
@ -11,15 +12,9 @@ export const shortUrlsListParamsType = PropTypes.shape({
|
|||
|
||||
const defaultState = { page: '1' };
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
case LIST_SHORT_URLS:
|
||||
return { ...state, ...action.params };
|
||||
case RESET_SHORT_URL_PARAMS:
|
||||
return defaultState;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
export default handleActions({
|
||||
[LIST_SHORT_URLS]: (state, { params }) => ({ ...state, ...params }),
|
||||
[RESET_SHORT_URL_PARAMS]: () => defaultState,
|
||||
}, defaultState);
|
||||
|
||||
export const resetShortUrlParams = () => ({ type: RESET_SHORT_URL_PARAMS });
|
||||
export const resetShortUrlParams = createAction(RESET_SHORT_URL_PARAMS);
|
||||
|
|
Loading…
Add table
Reference in a new issue