50 lines
806 B
TypeScript
50 lines
806 B
TypeScript
|
import {
|
||
|
Remove,
|
||
|
RemoveFailure,
|
||
|
RemoveSuccess,
|
||
|
ActionType,
|
||
|
Actions,
|
||
|
} from './remove.action';
|
||
|
|
||
|
import {
|
||
|
State,
|
||
|
initialState,
|
||
|
} from './remove.state';
|
||
|
|
||
|
import { Probe } from '../../model';
|
||
|
|
||
|
|
||
|
export function reducer(state = initialState, action: Actions): State {
|
||
|
switch (action.type) {
|
||
|
case ActionType.Remove: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: null,
|
||
|
isPending: true,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
case ActionType.RemoveSuccess: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: null,
|
||
|
isPending: false,
|
||
|
succeed: action.payload,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
case ActionType.RemoveFailure: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: action.payload,
|
||
|
isPending: false,
|
||
|
succeed: false,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
default: {
|
||
|
return state;
|
||
|
}
|
||
|
}
|
||
|
}
|