49 lines
858 B
TypeScript
49 lines
858 B
TypeScript
|
import {
|
||
|
Actions,
|
||
|
ActionType,
|
||
|
Setting,
|
||
|
} from './setting.action';
|
||
|
|
||
|
import {
|
||
|
State,
|
||
|
initialState,
|
||
|
} from './setting.state';
|
||
|
|
||
|
import { DiscoveryStartInfo } from '../../model';
|
||
|
|
||
|
export function reducer(state = initialState, action: Actions): State {
|
||
|
switch (action.type) {
|
||
|
case ActionType.Setting: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: null,
|
||
|
isPending: true,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
case ActionType.SettingSuccess: {
|
||
|
return {
|
||
|
...state,
|
||
|
isStart: true,
|
||
|
error: null,
|
||
|
isPending: false,
|
||
|
discoveryStartInfo: action.payload,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
case ActionType.SettingFailure: {
|
||
|
return {
|
||
|
...state,
|
||
|
isStart: false,
|
||
|
error: action.payload,
|
||
|
isPending: false,
|
||
|
discoveryStartInfo: null,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
default: {
|
||
|
return state;
|
||
|
}
|
||
|
}
|
||
|
}
|