member_webapp/@overflow/discovery/store/setting/setting.reducer.ts

49 lines
891 B
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import {
Actions,
ActionType,
Setting,
} from './setting.action';
import {
State,
initialState,
} from './setting.state';
2018-05-02 08:09:39 +00:00
import { DiscoveryStartInfo } from '@overflow/commons-typescript/model/discovery';
2018-04-06 11:02:18 +00:00
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Setting: {
return {
...state,
error: null,
isPending: true,
};
}
case ActionType.SettingSuccess: {
return {
...state,
isStart: true,
error: null,
isPending: false,
discoveryStartInfo: action.payload,
};
}
case ActionType.SettingFailure: {
return {
...state,
isStart: false,
error: action.payload,
isPending: false,
discoveryStartInfo: null,
};
}
default: {
return state;
}
}
}