import React from "react"; import { Link, withRouter } from 'react-router-dom' import Modal from './modal' import * as api from '../../api' import numberFormatter from '../../number-formatter' import Bar from '../bar' import {parseQuery} from '../../query' class ReferrersModal extends React.Component { constructor(props) { super(props) this.state = {loading: true} } componentDidMount() { const query = parseQuery(this.props.location.search, this.props.site) api.get(`/api/stats/${this.props.site.domain}/referrers`, query, {limit: 100}) .then((res) => this.setState({loading: false, referrers: res})) } renderReferrer(referrer) { return (
{ referrer.name } {numberFormatter(referrer.count)}
) } renderBody() { if (this.state.loading) { return (
) } else if (this.state.referrers) { return (

Referrers

by new visitors
{ this.state.referrers.map(this.renderReferrer.bind(this)) }
) } } render() { return ( { this.renderBody() } ) } } export default withRouter(ReferrersModal)