@@ -113,27 +113,25 @@ const authErrorReducer: Reducer<AuthErrorState, ReduxAction> = (state = initialA
113113} ;
114114
115115const authReducer : Reducer < AuthState , ReduxAction > = ( state = initialAuthState , action ) => {
116- switch ( action . type ) {
117- case ActionTypes . LOGIN : {
118- const loginAction = action as LoginAction ;
119- if ( loginAction . error ) {
120- return {
121- token : null ,
122- maintenance_organization : null ,
123- login_id : null
124- } ;
125- }
126- const { maintenance_organization, token, login_identifier} = loginAction . payload ;
127-
116+ if ( action . type === ActionTypes . LOGIN ) {
117+ const loginAction = action as LoginAction ;
118+ if ( loginAction . error ) {
128119 return {
129- maintenance_organization ,
130- token ,
131- login_id : login_identifier
120+ token : null ,
121+ maintenance_organization : null ,
122+ login_id : null
132123 } ;
133124 }
134- default :
135- return state ;
125+ const { maintenance_organization, token, login_identifier} = loginAction . payload ;
126+
127+ return {
128+ maintenance_organization,
129+ token,
130+ login_id : login_identifier
131+ } ;
136132 }
133+
134+ return state ;
137135} ;
138136
139137function observationPath ( { unitId, property} : { unitId : string ; property : string } ) : string {
@@ -234,66 +232,60 @@ const updateFlushReducer: Reducer<boolean, ReduxAction> = (state = manuallyFlush
234232} ;
235233
236234const serviceGroupReducer : Reducer < string , ReduxAction > = ( state = serviceGroup , action ) => {
237- switch ( action . type ) {
238- case ActionTypes . SELECT_SERVICE_GROUP :
239- return ( action as SelectServiceGroupAction ) . payload ;
240- default :
241- return state ;
235+ if ( action . type === ActionTypes . SELECT_SERVICE_GROUP ) {
236+ return ( action as SelectServiceGroupAction ) . payload ;
242237 }
238+
239+ return state ;
243240} ;
244241
245242const initialUserLocation : any = null ;
246243
247244const userLocationReducer : Reducer < any , ReduxAction > = ( state = initialUserLocation , action ) => {
248- switch ( action . type ) {
249- case ActionTypes . SET_USER_LOCATION :
250- return ( action as SetUserLocationAction ) . payload ;
251- default :
252- return state ;
245+ if ( action . type === ActionTypes . SET_USER_LOCATION ) {
246+ return ( action as SetUserLocationAction ) . payload ;
253247 }
248+
249+ return state ;
254250} ;
255251
256252const initialUnitsByUpdateTime : string [ ] = [ ] ;
257253const unitsByUpdateTimeReducer : Reducer < string [ ] , ReduxAction > = ( state = initialUnitsByUpdateTime , action ) => {
258- switch ( action . type ) {
259- case ActionTypes . POST_OBSERVATION : {
260- const postAction = action as PostObservationAction ;
261-
262- if ( postAction . error === true ) {
263- return state ;
264- }
265-
266- return _ . uniq ( [ postAction . meta . unitId , ...state ] ) . slice ( 0 , 20 ) ;
267- }
268- default :
254+ if ( action . type === ActionTypes . POST_OBSERVATION ) {
255+ const postAction = action as PostObservationAction ;
256+
257+ if ( postAction . error === true ) {
269258 return state ;
259+ }
260+
261+ return _ . uniq ( [ postAction . meta . unitId , ...state ] ) . slice ( 0 , 20 ) ;
270262 }
263+
264+ return state ;
271265} ;
272266
273267const initialUnitsByUpdateCount : UnitsByUpdateCountState = { } ;
274268const unitsByUpdateCountReducer : Reducer < UnitsByUpdateCountState , ReduxAction > = (
275269 state = initialUnitsByUpdateCount ,
276270 action
277271) => {
278- switch ( action . type ) {
279- case ActionTypes . POST_OBSERVATION : {
280- const postAction = action as PostObservationAction ;
281-
282- if ( postAction . error === true ) {
283- return state ;
284- }
272+ if ( action . type === ActionTypes . POST_OBSERVATION ) {
273+ const postAction = action as PostObservationAction ;
285274
286- const { unitId } = postAction . meta ;
287- const existingCount = ( state [ unitId ] || { } ) . count || 0 ;
288-
289- return {
290- ...state ,
291- [ unitId ] : { count : existingCount + 1 , id : unitId }
292- } ;
293- }
294- default :
275+ if ( postAction . error === true ) {
295276 return state ;
277+ }
278+
279+ const { unitId } = postAction . meta ;
280+ const existingCount = state [ unitId ] ?. count || 0 ;
281+
282+ return {
283+ ...state ,
284+ [ unitId ] : { count : existingCount + 1 , id : unitId }
285+ } ;
296286 }
287+
288+ return state ;
297289} ;
298290
299291export default combineReducers ( {
0 commit comments