diff --git a/smart-hut/src/App.js b/smart-hut/src/App.js index 003ee6c..2b2ec7a 100644 --- a/smart-hut/src/App.js +++ b/smart-hut/src/App.js @@ -84,12 +84,11 @@ class App extends Component { this.setState({ error: res.data.message, }); - return this.state.error; + return res.status; } }) .catch((err) => { - console.log(err); - return { status: "Errore" }; + return err; }); } diff --git a/smart-hut/src/components/dashboard/devices/NewDevice.js b/smart-hut/src/components/dashboard/devices/NewDevice.js index 6829eff..56640cd 100644 --- a/smart-hut/src/components/dashboard/devices/NewDevice.js +++ b/smart-hut/src/components/dashboard/devices/NewDevice.js @@ -36,6 +36,7 @@ export default class NewDevice extends Component { step: 1, openModal: false, motion: false, + name: "", }; this.baseState = this.state; this.createDevice = this.createDevice.bind(this); @@ -95,22 +96,47 @@ export default class NewDevice extends Component { }; switch (this.state.typeOfDevice) { + case "regularLight": + if (this.state.name === "") { + data.params["name"] = "Regular Light"; + } + break; + case "smartPlug": + if (this.state.name === "") { + data.params["name"] = "Smart Plug"; + } + break; case "dimmableLight": + if (this.state.name === "") { + data.params["name"] = "Dimmable Light"; + } data.params["intensity"] = 1; break; case "sensor": + if (this.state.name === "") { + data.params["name"] = "Sensor"; + } if (!this.state.motion) { data.params["sensor"] = this.state.typeOfSensor; data.params["value"] = 0; } break; case "switch": + if (this.state.name === "") { + data.params["name"] = "Switch"; + } data.params["lights"] = this.state.lightsAttached; break; case "buttonDimmer": + if (this.state.name === "") { + data.params["name"] = "Button Dimmer"; + } data.params["lights"] = this.state.lightsAttached; break; case "knobDimmer": + if (this.state.name === "") { + data.params["name"] = "Knob Dimmer"; + } data.params["lights"] = this.state.lightsAttached; break; default: @@ -254,7 +280,7 @@ export default class NewDevice extends Component { ); const switchOptions = (