diff --git a/src/components/Tutorial/Builder/Textfield.js b/src/components/Tutorial/Builder/Textfield.js new file mode 100644 index 0000000..7636a96 --- /dev/null +++ b/src/components/Tutorial/Builder/Textfield.js @@ -0,0 +1,53 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import { tutorialTitle, changeContent } from '../../../actions/tutorialBuilderActions'; + +import Button from '@material-ui/core/Button'; +import OutlinedInput from '@material-ui/core/OutlinedInput'; +import InputLabel from '@material-ui/core/InputLabel'; +import FormControl from '@material-ui/core/FormControl'; +import FormHelperText from '@material-ui/core/FormHelperText'; + +class Textfield extends Component { + + // handleChange = (e) => { + // var value = e.target.value; + // if(value.replace(/\s/g,'') !== ''){ + // this.setState({[e.target.name]: value, error: false}); + // } + // else { + // this.setState({[e.target.name]: value, error: true}); + // } + // }; + + render() { + return ( + + {this.props.label} + {this.props.property === 'title' ? + this.props.tutorialTitle(e.target.value) + : this.props.changeContent(this.props.index, this.props.property, e.target.value) + }} + /> + {/* {this.state.error ? Gib einen Titel für das Tutorial ein. : null}*/} + + ); + }; +} + +Textfield.propTypes = { + tutorialTitle: PropTypes.func.isRequired, + changeContent: PropTypes.func.isRequired +}; + +export default connect(null, { tutorialTitle, changeContent })(Textfield); diff --git a/src/components/Tutorial/Builder/Title.js b/src/components/Tutorial/Builder/Title.js deleted file mode 100644 index c9a598a..0000000 --- a/src/components/Tutorial/Builder/Title.js +++ /dev/null @@ -1,45 +0,0 @@ -import React, { Component } from 'react'; - -import Button from '@material-ui/core/Button'; -import OutlinedInput from '@material-ui/core/OutlinedInput'; -import InputLabel from '@material-ui/core/InputLabel'; -import FormControl from '@material-ui/core/FormControl'; -import FormHelperText from '@material-ui/core/FormHelperText'; - -class Title extends Component { - - state = { - title: '', - error: false - } - - handleChange = (e) => { - var value = e.target.value; - if(value.replace(/\s/g,'') !== ''){ - this.setState({[e.target.name]: value, error: false}); - } - else { - this.setState({[e.target.name]: value, error: true}); - } - }; - - render() { - return ( - - Titel - - {this.state.error ? Gib einen Titel für das Tutorial ein. : null} - - ); - }; -} - -export default Title;