<commit_before>import React from 'react'
import Post from '../components/Post'
import { graphql } from 'react-apollo'
import {withRouter, routeParams} from 'react-router'
import gql from 'graphql-tag'



class PostView extends React.Component {
  static propTypes = {
    data: React.PropTypes.object,
    makeBid: React.PropTypes.func
  }

  state = {
    pointCost: 5,
  }

  render () {
    if (this.props.data.loading) {
      return (<div>Loading</div>)
    }
    return (
      <div className='w-100 flex justify-center'>
        {console.log(this.props.data)}
        <div className="well">
          <h1>Title: {this.props.data.Post.title}</h1>
          <p>description: {this.props.data.Post.description}</p>
          <p>point cost: {this.props.data.Post.pointCost}</p>
          <p>Finish Date: {this.props.data.Post.finish}</p>
          <img src={this.props.data.Post.imageUrl} />
          <p>Outcome: {this.props.data.Post.outcomes}</p>
          <button onClick={this.handleYes}>BID YES ${this.props.data.Post.pointCost}</button>
          <button onClick={this.handleNo}>BID NO ${this.props.data.Post.pointCost}</button>
        </div>
      </div>
    )
  }
  handleYes = () => {
    const {pointCost} = this.state.pointCost
    this.props.makeBid({variables: {pointCost}})
      .then(() => {
        this.props.router.replace('/')
      })
  }
  handleNo = () => {
    const {pointCost} = this.state.pointCost
    this.props.makeBid({variables: {pointCost}})
      .then(() => {
        this.props.router.replace('/')
      })
  }
}
const Path = location.pathname.substr(1);

const makeBid = gql`
  mutation makeBid($pointCost: Int!) {
    createUserChoice(pointCost: $pointCost) {
      pointCost
    }
  }`

const PostQuery = gql`
  query {
    Post(id:"${Path}") {
      id
      title
      description
      pointCost
      finish
      imageUrl
      outcomes
    }
  }
`

export default graphql(makeBid, {name: 'makeBid'})(graphql(PostQuery)(withRouter(PostView)))<commit_msg>adding choice<commit_after>import React from 'react'
import Post from '../components/Post'
import { graphql } from 'react-apollo'
import {withRouter, routeParams} from 'react-router'
import gql from 'graphql-tag'



class PostView extends React.Component {
  static propTypes = {
    data: React.PropTypes.object,
    createUserChoice: React.PropTypes.func
  }

  state = {
    outcomeChoice: false,
  }

  render () {
    if (this.props.data.loading) {
      return (<div>Loading</div>)
    }
    return (
      <div className='w-100 flex justify-center'>
        {console.log(this.props.data)}
        <div className="well">
          <h1>Title: {this.props.data.Post.title}</h1>
          <p>description: {this.props.data.Post.description}</p>
          <p>point cost: {this.props.data.Post.pointCost}</p>
          <p>Finish Date: {this.props.data.Post.finish}</p>
          <img src={this.props.data.Post.imageUrl} />
          <p>Outcome: {this.props.data.Post.outcomes}</p>
          <button onClick={this.handleYes}>BID YES ${this.props.data.Post.pointCost}</button>
          <button onClick={this.handleNo}>BID NO ${this.props.data.Post.pointCost}</button>
        </div>
      </div>
    )
  }
  handleYes = () => {
    const variables = {
      outcomeChoice: this.state.outcomeChoice
    }
    this.props.createUserChoice({ variables })
      .then((response) => {
          this.props.router.replace('/')
      }).catch((e) => {
        console.error(e)
        this.props.router.replace('/')
      })
  }
  handleNo = () => {
    const {pointCost} = this.state.pointCost
    this.props.makeBid({variables: {pointCost}})
      .then(() => {
        this.props.router.replace('/')
      })
  }
}
const Path = location.pathname.substr(1);

const createUserChoice = gql`
  mutation ($outcomeChoice: Boolean!) {
    createUserChoice(outcomeChoice: $outcomeChoice) {
      id
    }
  }
  `

const PostQuery = gql`
  query {
    Post(id:"${Path}") {
      id
      title
      description
      pointCost
      finish
      imageUrl
      outcomes
    }
  }
`

export default graphql(createUserChoice, {name: 'createUserChoice'})(graphql(PostQuery)(withRouter(PostView)))
{'fraction_non_alphanumeric': 0.1568627450980392, 'fraction_numerical': 0.0031085604973696795, 'mean_word_length': 2.599827882960413, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3278430', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1363, 'n_words': 236}