diff --git a/client/components/Editor.js b/client/components/Editor.js index f2321b7..ac59bb9 100644 --- a/client/components/Editor.js +++ b/client/components/Editor.js @@ -1,8 +1,10 @@ import React from 'react' +import {connect} from 'react-redux' import {UnControlled} from 'react-codemirror2' import {transformCodeMirrorChange} from '../javascriptstuff/otoffsetfuncs' import connection from '../connect' import {operationsfunc} from '../javascriptstuff/operationsfunc' +import {withRouter} from 'react-router-dom' require('codemirror/mode/javascript/javascript') @@ -20,7 +22,14 @@ export class Editor extends React.Component { } componentDidMount() { - this.doc = connection.get('demo', 'inputbox') + console.log(this.props.match.params) + //this.doc = connection.get('demo', 'inputbox') + this.doc = connection.get( + this.props.match.params.user, + this.props.match.params.docname + ) + console.log(this.doc.collection) + console.log(this.doc.id) this.doc.subscribe(err => { if (err) throw err @@ -61,3 +70,5 @@ export class Editor extends React.Component { return this.editor ? main : loading } } + +export default withRouter(connect(null, null)(Editor)) diff --git a/client/components/MyForm.js b/client/components/MyForm.js new file mode 100644 index 0000000..9cf2124 --- /dev/null +++ b/client/components/MyForm.js @@ -0,0 +1,86 @@ +import React, {Component} from 'react' +import {connect} from 'react-redux' +//import connection from '../connect' +import {withRouter} from 'react-router-dom' +import {getDocsThunk, updateDocThunk} from '../store/doc' +import {Container, Form, TextArea, Button} from 'semantic-ui-react' + +//Props has username availabe, so why dont we +//make a query to the database to check all documents +//with username and also +//make a thunk that posts new ones and routes to them here + +export class MyForm extends Component { + constructor(props) { + super(props) + + this.state = { + doc: '', + userId: '' + } + + this.handleChange = this.handleChange.bind(this) + this.handleSubmit = this.handleSubmit.bind(this) + } + + componentDidMount() { + //stuff + //this.props.docs() + } + + handleChange(event) { + this.setState({ + [event.target.name]: event.target.value + }) + } + + handleSubmit(event) { + event.preventDefault() + let userId = this.state.userId + let docname = this.state.doc + this.props.props.history.push(`/docs/${userId}/${docname}`) + } + + render() { + let main = ( + +
+