import React from 'react';
import * as storage from '../../util/storage'
import * as url from '../../util/url'
import * as api from '../../api'
import ListReport from './../reports/list'
function EntryPages({query, site}) {
function fetchData() {
return api.get(url.apiPath(site, '/entry-pages'), query, {limit: 9})
}
function externalLinkDest(page) {
return url.externalLinkForPage(site.domain, page.name)
}
return (
)
}
function ExitPages({query, site}) {
function fetchData() {
return api.get(url.apiPath(site, '/exit-pages'), query, {limit: 9})
}
function externalLinkDest(page) {
return url.externalLinkForPage(site.domain, page.name)
}
return (
)
}
function TopPages({query, site}) {
function fetchData() {
return api.get(url.apiPath(site, '/pages'), query, {limit: 9})
}
function externalLinkDest(page) {
return url.externalLinkForPage(site.domain, page.name)
}
return (
)
}
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() }
)
}
}