import React, { Component } from "react"; import { Button, Header, Modal, Icon, Responsive } from "semantic-ui-react"; import { connect } from "react-redux"; import { RemoteService } from "../remote"; import { appActions } from "../storeActions"; //import { update } from "immutability-helper"; class HostModal extends Component { constructor(props) { super(props); this.state = this.initialState; this.setInitialState(); this.addHostModal = this.addHostModal.bind(this); this.modifyHostModal = this.modifyHostModal.bind(this); this.deleteHost = this.deleteHost.bind(this); } get initialState() { return { //INITIAL STATE HERE }; } setInitialState() { this.setState(this.initialState); } get type() { return !this.props.id ? "new" : "modify"; } addHostModal = (e) => { /*let data = { // DATA HERE };*/ // TODO CALL TO REMOTE SERVER TO ADD SCENE /*this.props .saveRoom(data, null) .then(() => { this.setInitialState(); this.closeModal(); }) .catch((err) => console.error("error in creating room", err));*/ }; modifyHostModal = (e) => { /* let data = { // DATA HERE };*/ // TODO CALL TO REMOTE SERVER TO MODIFY SCENE /*this.props .saveRoom(data, this.props.id) .then(() => { this.setInitialState(); this.closeModal(); }) .catch((err) => console.error("error in updating room", err));*/ }; deleteHost = (e) => { // TODO CALL TO REMOTE SERVER TO DELETE SCENE /* this.props .deleteRoom(this.props.id) .then(() => this.closeModal()) .catch((err) => console.error("error in deleting room", err));*/ }; changeSomething = (event) => { let nam = event.target.name; let val = event.target.value; this.setState({ [nam]: val }); }; closeModal = (e) => { this.setState({ openModal: false }); }; openModal = (e) => { this.setState({ openModal: true }); }; render() { return (
{!this.props.nicolaStop ? (
{this.type === "new" ? ( ) : ( )} {this.type === "new" ? ( ) : ( )}
) : null}
{this.type === "new" ? "Add new hosts" : "Modify hosts"}
{ //TODO FORM TO ADD OR MODIFY SCENE } {this.type === "modify" ? ( ) : null}
); } } const setActiveHost = (activeHost) => { return (dispatch) => dispatch(appActions.setActiveHost(activeHost)); }; const mapStateToProps = (state, ownProps) => ({ hostss: ownProps.id ? state.hostss[ownProps.id] : null, }); const HostModalContainer = connect( mapStateToProps, { ...RemoteService, setActiveHost }, null, { forwardRef: true } )(HostModal); export default HostModalContainer;