import React, { Component } from 'react'
import { Redirect } from 'react-router-dom'

/* IMPORT HOME VIEW */
import HomeV from './HomeV'

class HomeC extends Component {
  constructor (props) {
    super(props)
    this.state = {
      toStatistics: false
    }
  }

  handleStatsRedirect= () => {
    this.setState({
      toStatistics: true
    })
  }
  render () {
    if (this.state.toStatistics === true) {
      return <Redirect to='/statistics' />
    }
    return (
      <HomeV statsSubmit={this.handleStatsRedirect} />
    )
  }
}

export default HomeC

/* SIDE NOTE
<Redirect to='/statistics' />
doesn't keep the history of the pages you've visited
so if you were to hit back it will take you to
the previous page visited. It's a weird bug that if
I was to use Link instead of redirect then it would
save the history */
