fix devide default name

This commit is contained in:
britea 2020-03-26 11:11:44 +01:00
parent 49ba4283bf
commit 573ffe1661

View file

@ -36,7 +36,7 @@ export default class NewDevice extends Component {
step: 1,
openModal: false,
motion: false,
name: "",
deviceName: "",
};
this.baseState = this.state;
this.createDevice = this.createDevice.bind(this);
@ -97,23 +97,23 @@ export default class NewDevice extends Component {
switch (this.state.typeOfDevice) {
case "regularLight":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Regular Light";
}
break;
case "smartPlug":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Smart Plug";
}
break;
case "dimmableLight":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Dimmable Light";
}
data.params["intensity"] = 0;
break;
case "sensor":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Sensor";
}
if (!this.state.motion) {
@ -122,19 +122,19 @@ export default class NewDevice extends Component {
}
break;
case "switch":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Switch";
}
data.params["lights"] = this.state.lightsAttached;
break;
case "buttonDimmer":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Button Dimmer";
}
data.params["lights"] = this.state.lightsAttached;
break;
case "knobDimmer":
if (this.state.name === "") {
if (this.state.deviceName === "") {
data.params["name"] = "Knob Dimmer";
}
data.params["lights"] = this.state.lightsAttached;
@ -142,7 +142,7 @@ export default class NewDevice extends Component {
default:
break;
}
console.log(data);
this.props.addDevice(data);
this.resetState();
}