2018-04-06 11:02:18 +00:00
|
|
|
import {
|
|
|
|
Actions,
|
|
|
|
ActionType,
|
|
|
|
} from './regist.action';
|
|
|
|
|
|
|
|
import {
|
|
|
|
State,
|
|
|
|
initialState,
|
|
|
|
} from './regist.state';
|
|
|
|
|
2018-05-02 08:09:39 +00:00
|
|
|
import { Sensor } from '@overflow/commons-typescript/model/sensor';
|
2018-04-06 11:02:18 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|