diff --git a/src/containers/OpenTicket/OpenTicket.js b/src/containers/OpenTicket/OpenTicket.js new file mode 100644 index 0000000..490d34c --- /dev/null +++ b/src/containers/OpenTicket/OpenTicket.js @@ -0,0 +1,179 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; +import { + Col, + Row, + Button, + Form, + FormGroup, + Label, + Input +} from 'reactstrap'; + +import Card from '../../components/Card'; + +class OpenTicket extends Component { + constructor(props) { + super(props); + + this.state = { + id: '', + firstName: '', + lastName: '', + email: '', + type: '', + subject: '', + message: '' + }; + + this.handleInputChange = this.handleInputChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + handleInputChange(event) { + const target = event.target; + const name = target.name; + const value = target.type === 'checkbox' ? target.checked : target.value; + + this.setState({ + [name]: value + }); + } + + handleSubmit(event) { + event.preventDefault(); + + const { id, ...rest } = this.state; + + fetch("http://localhost:3001/tickets", { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(rest) + }) + .then((res) => { + return res.json(); + }) + .then((json) => { + this.setState({ + id: json.id + }); + }); + } + + render() { + + if (this.state.id) { + return ( +
+ Go to home} /> +
+ ); + + } + + let FormOpenTicket = ( +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
); + + return ( +
+ + +
+ ); + } +} + +export default OpenTicket; \ No newline at end of file