import React from 'react'; import { Link } from 'react-router-dom' import Visits from './pages' import EntryPages from './entry-pages' import ExitPages from './exit-pages' import FadeIn from '../../fade-in' const labelFor = { 'pages': 'Top Pages', 'entry-pages': 'Entry Pages', 'exit-pages': 'Exit Pages', } export default class Pages extends React.Component { constructor(props) { super(props) this.tabKey = 'pageTab__' + props.site.domain const storedTab = window.localStorage[this.tabKey] this.state = { mode: storedTab || 'pages' } } renderContent() { if (this.state.mode === 'pages') { return } else if (this.state.mode === 'entry-pages') { return } else if (this.state.mode === 'exit-pages') { return } } setMode(mode) { return () => { window.localStorage[this.tabKey] = mode this.setState({mode}) } } renderPill(name, mode) { const isActive = this.state.mode === mode if (isActive) { return
  • {name}
  • } else { return
  • {name}
  • } } render() { const filters = this.props.query.filters return (

    {labelFor[this.state.mode] || 'Page Visits'}

      { this.renderPill('Top Pages', 'pages') } { this.renderPill('Entry Pages', 'entry-pages') } { this.renderPill('Exit Pages', 'exit-pages') }
    { this.renderContent() }
    ) } }