member_webapp/@overflow/probe/store/container/probe-detail/probe-detail.reducer.ts
2018-05-28 18:58:13 +09:00

32 lines
731 B
TypeScript

import { ActionType, Actions } from '../../entity/probe';
import {
State,
initialState,
probeListContainerAdapter
} from './probe-detail.state';
import { Probe } from '@overflow/commons-typescript/model/probe';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Read: {
return {
...state,
pending: true,
};
}
case ActionType.ReadSuccess: {
return probeListContainerAdapter.setOne(action.payload, {...state, pending: false});
}
case ActionType.ReadFailure: {
return probeListContainerAdapter.setError(action.payload, {...state, pending: false});
}
default: {
return state;
}
}
}