2018-05-26 09:08:40 +00:00
|
|
|
import { ActionType, Actions } from '../../entity/probe';
|
|
|
|
import {
|
|
|
|
State,
|
|
|
|
initialState,
|
2018-05-28 09:58:13 +00:00
|
|
|
probeListContainerAdapter
|
2018-05-26 09:08:40 +00:00
|
|
|
} 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: {
|
2018-05-28 09:58:13 +00:00
|
|
|
return probeListContainerAdapter.setOne(action.payload, {...state, pending: false});
|
2018-05-26 09:08:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case ActionType.ReadFailure: {
|
2018-05-28 09:58:13 +00:00
|
|
|
return probeListContainerAdapter.setError(action.payload, {...state, pending: false});
|
2018-05-26 09:08:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|