55 lines
938 B
TypeScript
Raw Normal View History

2018-04-27 16:31:27 +09:00
import {
ActionType,
Actions,
} from './modify.action';
import {
State,
initialState,
} from './modify.state';
2018-05-02 17:09:39 +09:00
import { Probe } from '@overflow/commons-typescript/model/probe';
2018-04-27 16:31:27 +09:00
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Modify: {
return {
...state,
error: null,
isPending: true,
};
}
case ActionType.ModifySuccess: {
return {
...state,
error: null,
isPending: false,
2018-04-29 19:43:14 +09:00
modifiedProbe: action.payload,
2018-04-27 16:31:27 +09:00
};
}
case ActionType.ModifyFailure: {
return {
...state,
error: action.payload,
isPending: false,
2018-04-29 19:43:14 +09:00
modifiedProbe: null,
2018-04-27 16:31:27 +09:00
};
}
2018-05-02 12:59:45 +09:00
case ActionType.ModifyDisplayName: {
return {
...state,
error: null,
isPending: true,
};
}
2018-04-27 16:31:27 +09:00
default: {
return state;
}
}
}