Replaced usages of defaultState by initialState

This commit is contained in:
Alejandro Celaya
2019-03-17 10:11:20 +01:00
parent 5bb9d15e27
commit 232c059e4f
8 changed files with 21 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ export const createShortUrlResultType = PropTypes.shape({
error: PropTypes.bool,
});
const defaultState = {
const initialState = {
result: null,
saving: false,
error: false,
@@ -26,8 +26,8 @@ export default handleActions({
[CREATE_SHORT_URL_START]: (state) => ({ ...state, saving: true, error: false }),
[CREATE_SHORT_URL_ERROR]: (state) => ({ ...state, saving: false, error: true }),
[CREATE_SHORT_URL]: (state, { result }) => ({ result, saving: false, error: false }),
[RESET_CREATE_SHORT_URL]: () => defaultState,
}, defaultState);
[RESET_CREATE_SHORT_URL]: () => initialState,
}, initialState);
export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => {
dispatch({ type: CREATE_SHORT_URL_START });

View File

@@ -19,7 +19,7 @@ export const shortUrlDeletionType = PropTypes.shape({
}).isRequired,
});
const defaultState = {
const initialState = {
shortCode: '',
loading: false,
error: false,
@@ -30,8 +30,8 @@ export default handleActions({
[DELETE_SHORT_URL_START]: (state) => ({ ...state, loading: true, error: false }),
[DELETE_SHORT_URL_ERROR]: (state, { errorData }) => ({ ...state, errorData, loading: false, error: true }),
[DELETE_SHORT_URL]: (state, { shortCode }) => ({ ...state, shortCode, loading: false, error: false }),
[RESET_DELETE_SHORT_URL]: () => defaultState,
}, defaultState);
[RESET_DELETE_SHORT_URL]: () => initialState,
}, initialState);
export const deleteShortUrl = (buildShlinkApiClient) => (shortCode) => async (dispatch, getState) => {
dispatch({ type: DELETE_SHORT_URL_START });

View File

@@ -17,7 +17,7 @@ export const shortUrlTagsType = PropTypes.shape({
error: PropTypes.bool.isRequired,
});
const defaultState = {
const initialState = {
shortCode: null,
tags: [],
saving: false,
@@ -28,8 +28,8 @@ export default handleActions({
[EDIT_SHORT_URL_TAGS_START]: (state) => ({ ...state, saving: true, error: false }),
[EDIT_SHORT_URL_TAGS_ERROR]: (state) => ({ ...state, saving: false, error: true }),
[EDIT_SHORT_URL_TAGS]: (state, action) => ({ ...pick([ 'shortCode', 'tags' ], action), saving: false, error: false }),
[RESET_EDIT_SHORT_URL_TAGS]: () => defaultState,
}, defaultState);
[RESET_EDIT_SHORT_URL_TAGS]: () => initialState,
}, initialState);
export const editShortUrlTags = (buildShlinkApiClient) => (shortCode, tags) => async (dispatch, getState) => {
dispatch({ type: EDIT_SHORT_URL_TAGS_START });

View File

@@ -10,11 +10,11 @@ export const shortUrlsListParamsType = PropTypes.shape({
searchTerm: PropTypes.string,
});
const defaultState = { page: '1' };
const initialState = { page: '1' };
export default handleActions({
[LIST_SHORT_URLS]: (state, { params }) => ({ ...state, ...params }),
[RESET_SHORT_URL_PARAMS]: () => defaultState,
}, defaultState);
[RESET_SHORT_URL_PARAMS]: () => initialState,
}, initialState);
export const resetShortUrlParams = createAction(RESET_SHORT_URL_PARAMS);