diff --git a/smart-hut/public/avatar3.png b/smart-hut/public/avatar3.png index ec160b5..6831d07 100644 Binary files a/smart-hut/public/avatar3.png and b/smart-hut/public/avatar3.png differ diff --git a/smart-hut/public/smart-home.png b/smart-hut/public/smart-home.png index d2681ce..376516e 100644 Binary files a/smart-hut/public/smart-home.png and b/smart-hut/public/smart-home.png differ diff --git a/smart-hut/src/components/SelectIcons.js b/smart-hut/src/components/SelectIcons.js index f1a7994..f3839a8 100644 --- a/smart-hut/src/components/SelectIcons.js +++ b/smart-hut/src/components/SelectIcons.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Button, Grid } from 'semantic-ui-react' +import { Button, Grid, Responsive } from 'semantic-ui-react' export default class SelectIcons extends Component { @@ -30,7 +30,7 @@ export default class SelectIcons extends Component { ['paw', 'tree', 'utensils', 'male', 'female', 'life ring outline']]; return ( - + { myicons.map((e, i) => { return ( diff --git a/smart-hut/src/components/modalform.js b/smart-hut/src/components/modalform.js index 699da5d..1851fed 100644 --- a/smart-hut/src/components/modalform.js +++ b/smart-hut/src/components/modalform.js @@ -1,18 +1,25 @@ import React, { Component } from 'react'; -import { Button, Header, Modal, Form, Input, Icon, Responsive } from 'semantic-ui-react' +import { Button, Header, Modal, Form, Input, Icon, Responsive, Image } from 'semantic-ui-react'; import SelectIcons from "./SelectIcons"; +const NO_IMAGE="https://react.semantic-ui.com/images/wireframe/image.png"; + export default class ModalWindow extends Component { constructor(props) { super(props); + +console.table(this.props); + this.state = { id : "", selectedIcon: "", name: "", - img: "", + img: this.props.type === "new" ? null : this.props.idRoom.image, openModal: false - } + }; + + this.fileInputRef = React.createRef(); this.addRoomModal = this.addRoomModal.bind(this); this.updateIcon = this.updateIcon.bind(this); @@ -63,6 +70,16 @@ export default class ModalWindow extends Component { this.setState({selectedIcon : e}) } + getBase64(file, callback) { + let reader = new FileReader(); + reader.readAsDataURL(file.target.files[0]); + reader.onload = () => { + this.state.img = reader.result; + this.setState(this.state); + }; + reader.onerror = console.error; + } + render(){ const spaceDiv = { @@ -112,8 +129,15 @@ export default class ModalWindow extends Component {

Insert an image of the room:

- + + this.fileInputRef.current.click()}/> + + +