50 lines
789 B
TypeScript
50 lines
789 B
TypeScript
|
import {
|
||
|
Read,
|
||
|
ReadFailure,
|
||
|
ReadSuccess,
|
||
|
ActionType,
|
||
|
Actions,
|
||
|
} from './detail.action';
|
||
|
|
||
|
import {
|
||
|
State,
|
||
|
initialState,
|
||
|
} from './detail.state';
|
||
|
|
||
|
import { Probe } from '../../model';
|
||
|
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|