46 lines
858 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|