39 lines
766 B
TypeScript
Raw Normal View History

2018-04-19 19:26:39 +09:00
import { Actions, ActionType } from './detail.action';
import { State, initialState } from './detail.state';
2018-05-02 17:09:39 +09:00
import { Infra } from '@overflow/commons-typescript/model/infra';
2018-04-19 19:26:39 +09:00
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Read: {
return {
...state,
error: null,
isPending: true,
};
}
case ActionType.ReadSuccess: {
return {
...state,
error: null,
isPending: false,
infra: action.payload
};
}
case ActionType.ReadFailure: {
return {
...state,
error: action.payload,
isPending: false,
infra: null
};
}
default: {
return state;
}
}
}