import produce from 'immer' ; import { ActionType , createReducer } from 'typesafe-actions' ; import { SharedStateType } from '../interface' ; import * as actions from './actions' ; type Action = ActionType < typeof actions > ; const initialState = { routerLink : '' , errorMessage : null , } ; const reducer = createReducer < SharedStateType , Action > ( initialState ) . handleAction ( actions . navigate , ( state , action ) => produce ( state , ( nexState ) => { nexState . routerLink = action . payload ; } ) ) . handleAction ( actions . setError , ( state , action ) => produce ( state , ( nexState ) => { nexState . errorMessage = action . payload ; } ) ) ; export { reducer as SharedReducer } ;