diff --git a/src/tags/reducers/tagDelete.js b/src/tags/reducers/tagDelete.js index 03c42947..1940fafe 100644 --- a/src/tags/reducers/tagDelete.js +++ b/src/tags/reducers/tagDelete.js @@ -1,11 +1,12 @@ +import { handleActions } from 'redux-actions'; import PropTypes from 'prop-types'; -/* eslint-disable padding-line-between-statements, newline-after-var */ +/* eslint-disable padding-line-between-statements */ export const DELETE_TAG_START = 'shlink/deleteTag/DELETE_TAG_START'; export const DELETE_TAG_ERROR = 'shlink/deleteTag/DELETE_TAG_ERROR'; export const DELETE_TAG = 'shlink/deleteTag/DELETE_TAG'; export const TAG_DELETED = 'shlink/deleteTag/TAG_DELETED'; -/* eslint-enable padding-line-between-statements, newline-after-var */ +/* eslint-enable padding-line-between-statements */ export const tagDeleteType = PropTypes.shape({ deleting: PropTypes.bool, @@ -17,27 +18,11 @@ const defaultState = { error: false, }; -export default function reducer(state = defaultState, action) { - switch (action.type) { - case DELETE_TAG_START: - return { - deleting: true, - error: false, - }; - case DELETE_TAG_ERROR: - return { - deleting: false, - error: true, - }; - case DELETE_TAG: - return { - deleting: false, - error: false, - }; - default: - return state; - } -} +export default handleActions({ + [DELETE_TAG_START]: () => ({ deleting: true, error: false }), + [DELETE_TAG_ERROR]: () => ({ deleting: false, error: true }), + [DELETE_TAG]: () => ({ deleting: false, error: false }), +}, defaultState); export const deleteTag = (buildShlinkApiClient) => (tag) => async (dispatch, getState) => { dispatch({ type: DELETE_TAG_START });