member_webapp/@overflow/probe/store/trash/detail/detail.reducer.ts

50 lines
818 B
TypeScript
Raw Normal View History

2018-04-06 11:02:18 +00:00
import {
Read,
ReadFailure,
ReadSuccess,
ActionType,
Actions,
} from './detail.action';
import {
State,
initialState,
} from './detail.state';
2018-05-02 08:09:39 +00:00
import { Probe } from '@overflow/commons-typescript/model/probe';
2018-04-06 11:02:18 +00: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,
probe: action.payload,
};
}
case ActionType.ReadFailure: {
return {
...state,
error: action.payload,
isPending: false,
probe: null,
};
}
default: {
return state;
}
}
}