{"size": 2923, "ext": "js", "max_stars_repo_path": "client/components/Upload.js", "max_stars_repo_name": "lendr2/lendr2.github.io", "max_stars_repo_stars_event_min_datetime": "2017-01-07T18:53:14.000Z", "max_stars_repo_stars_event_max_datetime": "2017-01-08T19:31:56.000Z", "max_issues_repo_path": "client/components/Upload.js", "max_issues_repo_name": "lendr2/lendr2.github.io", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/components/Upload.js", "max_forks_repo_name": "lendr2/lendr2.github.io", "max_forks_repo_forks_event_min_datetime": "2016-10-31T18:01:26.000Z", "max_forks_repo_forks_event_max_datetime": "2016-10-31T18:01:55.000Z"}
{"max_stars_count": 8, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 37.961038961, "max_line_length": 98, "alphanum_fraction": 0.5880944235}
import React, { Component } from 'react';
import { Router, Route, Link, browserHistory } from 'react-router';
const cookieParser = require('cookie-parser');

class Upload extends Component {
  uploadItem(event) {
    event.preventDefault();
    const item = event.target.elements[0].value;
    const type = event.target.elements[1].value;
    const description = event.target.elements[2].value;
    const imageURL = event.target.elements[3].value;
    const dueDate = event.target.elements[4].value;
    const owneremail = event.target.elements[5].value;
    const ownerName = document.cookie.split('=').pop();

    $.post('/uploadItem',
      {
        itemname: item,
        itemtype: type,
        itemdescription: description,
        itempictureurl: imageURL,
        datedue: dueDate,
        ownername: ownerName,
        owneremail: owneremail
      })
      .done((data) => {
        browserHistory.push('/browse');
      })
      .fail((error) => console.log('Error with uploadItem:', error));
  }

  render() {
    return (
      <div className="upload-form">
        <form onSubmit={this.uploadItem}>
          <div className="form-group">
            <label for="item">Item:</label>
            <input type="text" className="form-control" name="item" placeholder="item" />
          </div>
          <div className="form-group">
            <label for="type">Type:</label>
            <select name="type" className="form-control">
              <option value="business">business</option>
              <option value="clothes">clothes</option>
              <option value="electronics">electronics</option>
              <option value="homegoods">home goods</option>
              <option value="music">music</option>
              <option value="sporting">sporting</option>
              <option value="transportation">transportation</option>
              <option value="unclassifiable">unclassifiable</option>
            </select>
          </div>
          <div className="form-group">
            <label for="description">Description:</label>
            <textarea className="form-control" name="description" placeholder="description" />
          </div>
          <div className="form-group">
            <label for="imageURL">Image URL:</label>
            <input type="text" className="form-control" name="imageURL" placeholder="image URL" />
          </div>
          <div className="form-group">
            <label for="duedate">Due Date:</label>
            <input type="date" className="form-control" name="duedate" placeholder="due date" />
          </div>
          <div className="form-group">
            <label for="email">Email:</label>
            <input type="email" className="form-control" name="email" placeholder="email" />
          </div>
          <button type="submit" className="btn btn-primary">Submit</button>
        </form>
      </div>
    );
  }
}

export default Upload;
