<commit_before>import React from 'react'
import './tracker.css'
import OrderNumberForm from './OrderNumberForm'
import OrderHistoryModel from '../model/OrderHistoryModel'

class Tracker extends React.Component {
  constructor (props) {
    super(props)
    this.state = { step: '', legs: [] }
    this.renderLeg = this.renderLeg.bind(this)
  }

  render () {
    return <div id='tracker'>
      { this.renderStep() }
    </div>
  }

  renderStep () {
    if (this.state.step === 'show-tracking-info') {
      return this.renderTrackingInfo()
    } else {
      return this.renderSearchForm()
    }
  }

  renderSearchForm () {
    let onOrderNumberEntered = function () {
      this.setState({ step: 'show-tracking-info' })
      this.loadOrderHistory()
    }.bind(this)
    return <div id='tracker-ui' className='form'>
      <OrderNumberForm onOrderNumberEntered={onOrderNumberEntered} />
    </div>
  }

  async loadOrderHistory () {
    let model = await OrderHistoryModel.create()
    let legs = await model.getLegs()
    this.setState({legs: legs})
  }

  renderTrackingInfo () {
    return <div id='tracker-ui' className='results'>
      { this.state.legs.map(this.renderLeg) }
    </div>
  }

  renderLeg (leg) {
    return <tr key={leg.id}>
      <td>From {leg.from.geolocation} to {leg.to.geolocation}</td>
      <td>{leg.mode}</td>
      <td className='numeric'>{leg.co2emission}</td>
    </tr>
  }
}<commit_msg>Show tracker search bar on tracker result screen.<commit_after>import React from 'react'
import './tracker.css'
import OrderNumberForm from './OrderNumberForm'
import OrderHistoryModel from '../model/OrderHistoryModel'

class Tracker extends React.Component {
  constructor (props) {
    super(props)
    this.state = { step: '', legs: [] }
    this.onOrderNumberEntered = this.onOrderNumberEntered.bind(this)
    this.renderLeg = this.renderLeg.bind(this)
  }

  render () {
    return <div id='tracker'>
      { this.renderStep() }
    </div>
  }

  renderStep () {
    if (this.state.step === 'show-tracking-info') {
      return this.renderTrackingInfo()
    } else {
      return this.renderSearchForm()
    }
  }

  renderSearchForm () {
    return <div id='tracker-ui' className='form'>
      <OrderNumberForm onOrderNumberEntered={this.onOrderNumberEntered} />
    </div>
  }

  onOrderNumberEntered () {
    this.setState({ step: 'show-tracking-info' })
    this.loadOrderHistory()
  }

  async loadOrderHistory () {
    let model = await OrderHistoryModel.create()
    let legs = await model.getLegs()
    this.setState({legs: legs})
  }

  renderTrackingInfo () {
    return <div id='tracker-ui' className='results'>
      <OrderNumberForm onOrderNumberEntered={this.onOrderNumberEntered} />
      { this.state.legs.map(this.renderLeg) }
    </div>
  }

  renderLeg (leg) {
    return <tr key={leg.id}>
      <td>From {leg.from.geolocation} to {leg.to.geolocation}</td>
      <td>{leg.mode}</td>
      <td className='numeric'>{leg.co2emission}</td>
    </tr>
  }
}
{'fraction_non_alphanumeric': 0.14909939959973315, 'fraction_numerical': 0.00066711140760507, 'mean_word_length': 3.1422651933701657, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '4329083', 'n_tokens_mistral': 990, 'n_tokens_neox': 970, 'n_words': 186}