import React from 'react'; import * as storage from '../../storage' import Visits from './pages' import EntryPages from './entry-pages' import ExitPages from './exit-pages' 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 = storage.getItem(this.tabKey) this.state = { mode: storedTab || 'pages' } } setMode(mode) { return () => { storage.setItem(this.tabKey, mode) this.setState({mode}) } } renderContent() { switch(this.state.mode) { case "entry-pages": return case "exit-pages": return case "pages": default: return } } renderPill(name, mode) { const isActive = this.state.mode === mode if (isActive) { return (
  • {name}
  • ) } return (
  • {name}
  • ) } render() { return (
    {/* Header Container */}

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

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