32 lines
731 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|