import { Reducer } from 'redux' ; import producer from 'immer' ; import { ITagsState , TagsStateTypes } from './tagsTypes' ; import { RootAction } from '../storeTypes' ; const initialState = { actives : [ ] , data : { } , isFetched : false , } ; export const tagsReducer = ( state = initialState , action ) => producer ( state , draft => { switch ( action . type ) { case TagsStateTypes . LOAD : draft . data = action . payload ; draft . isFetched = true ; return ; case TagsStateTypes . SET_ACTIVES : draft . actives = action . payload ; return ; } } ) ;