diff --git a/src/containers/OpenTicket/OpenTicket.js b/src/containers/OpenTicket/OpenTicket.js
index 4a207ad..2d6d058 100644
--- a/src/containers/OpenTicket/OpenTicket.js
+++ b/src/containers/OpenTicket/OpenTicket.js
@@ -1,9 +1,16 @@
import React, { Component } from 'react';
+import {
+ Row,
+ Col,
+ Form,
+ FormGroup,
+ Label,
+ Input,
+ Button
+} from 'reactstrap';
import Card from '../../components/Card';
-import InsertForm from '../../components/InsertForm';
-import MessageCard from '../MessageCard';
-
+import DropDown from '../../components/DropDown';
class OpenTicket extends Component {
constructor(props) {
@@ -17,13 +24,35 @@ class OpenTicket extends Component {
email: '',
type: '',
subject: '',
- message: ''
+ message: '',
+ categories: [],
+ categoriesLoaded: false
};
this.handleInputChange = this.handleInputChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
+ componentDidMount() {
+ fetch("http://localhost:3001/categories", {
+ method: 'GET',
+ headers: { 'Content-Type': 'application/json' }
+ })
+ .then((res) => {
+ return res.json();
+ })
+ .then((json) => {
+ this.setState({
+ categories: json
+ });
+ })
+ .catch((err) => {
+ this.setState({
+ ticketErr: err.message
+ });
+ });
+ }
+
handleInputChange(event) {
const target = event.target;
const name = target.name;
@@ -39,12 +68,12 @@ class OpenTicket extends Component {
const { ticketId, ticketErr, ...rest } = this.state;
- if(!rest.firstName || !rest.lastName || !rest.email || !rest.message
- || rest.type === '---' || !rest.subject ) {
- alert('Form is invalid');
- return;
+ if (!rest.firstName || !rest.lastName || !rest.email || !rest.message
+ || rest.type === '---' || !rest.subject) {
+ alert('Form is invalid');
+ return;
- }
+ }
fetch("http://localhost:3001/tickets", {
method: 'POST',
@@ -56,53 +85,163 @@ class OpenTicket extends Component {
})
.then((json) => {
this.setState({
- ticketId: json.id
+ ticketId: json.id
});
})
.catch((err) => {
this.setState({
ticketErr: err.message
+ });
});
- });
}
render() {
+
+
if (this.state.ticketId) {
return (
- {`Ticket ID: ${this.state.ticketId}`} {this.state.ticketErr}