member_webapp/@overflow/sensor/store/regist/regist.reducer.ts
crusader d59d9379f9 ing
2018-05-24 15:44:13 +09:00

46 lines
858 B
TypeScript

import {
Actions,
ActionType,
} from './regist.action';
import {
State,
initialState,
} from './regist.state';
import { Sensor } from '@overflow/commons-typescript/model/sensor';
export function reducer(state = initialState, action: Actions): State {
switch (action.type) {
case ActionType.Regist: {
return {
...state,
error: null,
pending: true,
};
}
case ActionType.RegistSuccess: {
return {
...state,
error: null,
pending: false,
sensor: action.payload
};
}
case ActionType.RegistFailure: {
return {
...state,
error: action.payload,
pending: false,
sensor: null,
};
}
default: {
return state;
}
}
}