diff --git a/smart-hut/src/components/modalform.js b/smart-hut/src/components/modalform.js index a8cb88d..d5e891e 100644 --- a/smart-hut/src/components/modalform.js +++ b/smart-hut/src/components/modalform.js @@ -16,10 +16,10 @@ export default class ModalWindow extends Component { this.state = { id: "", selectedIcon: "", - name: "", - img: "", - openModal: false, - }; + name: this.props.type === 'new' ? '' : this.props.idRoom.name, + img: this.props.type === 'new' ? '' : this.props.idRoom.images, + openModal: false + } this.addRoomModal = this.addRoomModal.bind(this); this.updateIcon = this.updateIcon.bind(this); @@ -59,10 +59,16 @@ export default class ModalWindow extends Component { this.setState({ [nam]: val }); }; - closeModal = (e) => { - this.setState({ openModal: false }); - this.updateIcon("home"); - }; + let nam = event.target.name; + let val = event.target.value; + this.setState({[nam]: val}); + console.log(this.state); + } + + closeModal = (e) => { + this.setState({openModal:false}); + this.updateIcon('home'); + } openModal = (e) => { this.setState({ openModal: true }); @@ -87,85 +93,64 @@ export default class ModalWindow extends Component { ADD ROOM - ) : ( - - )} - - - {this.props.type === "new" ? ( - - ) : ( - - )} - + : + + } + + + { + this.props.type === "new" ? + + : + + } + - -
- {this.props.type === "new" ? "Add new room" : "Modify room"} -
- -
-

Insert the name of the room:

- - - -

Insert an image of the room:

- - - -
+ +
{this.props.type === "new" ? "Add new room" : "Modify room" }
+ +
+

Insert the name of the room:

+ + + +

Insert an image of the room:

+ + + +
-
-

Select an icon:

- -
+
+

Select an icon:

+ +
- {this.props.type === "modify" ? ( - - ) : null} -
- - + {this.props.type === "modify" ? + : null } + +
+ + + + +