import React from 'react'; import superagent from 'superagent'; import constants from '../CloudApi/Constants.js'; import MenuPageWrapper from '../Wrappers/MenuPageWrapper.jsx'; import { Segment, Header, Image, Icon, Message, Button, Table, Form, Label } from 'semantic-ui-react' export default class CreateRoom extends React.Component { constructor(props) { super(props); this.state = { version: '0.95.0', name: null, description: null, category: constants.RoomCategories[0].value, environment: constants.RoomEnvironments[0].value, size: constants.RoomSizes[0].value, content: null, messages: [], loading: false }; } onChange(e, { name, value }) { this.setState({ [name]: value }) } onAddContent(e) { e.preventDefault(); this.setState({content : { type: "fileId", value: "aaa1" }}); } onContentTypeChanged(e, { name, value }) { this.setState({content: { type: value, value: this.state.content.value }}); } onContentChanged(e, { name, value }) { this.setState({content: { type: this.state.content.type, value }}); } onRemoveContent(e) { this.setState({ content : null }); } async onCreateRoom(e) { e.preventDefault(); try { const payload = { version: this.state.version, name: this.state.name, description: this.state.description, category: this.state.category, environment: this.state.environment, size: this.state.size, content: { [this.state.content.type]: this.state.content.value }, visibility: "Public" }; this.setState({loading: true}); const room = await superagent.post(`/api/create_room`).accept('json').send(payload); console.log(room); } catch (e) { console.log(e); } this.setState({ loading: false }); } render() { return ( {this.state.messages.map(message => { return ( ) })}
Content (optional)
{this.state.content && ( )}