import { Col, Row, notification, Card, Spin } from "antd" import React from "react" import { Chart, Geom, Tooltip as BizTooltip } from "bizcharts" import * as cs from "./constants" class Dashboard extends React.PureComponent { state = { stats: null, loading: true } campaignTypes = [ "running", "finished", "paused", "draft", "scheduled", "cancelled" ] componentDidMount = () => { this.props.pageTitle("Dashboard") this.props .request(cs.Routes.GetDashboarcStats, cs.MethodGet) .then(resp => { this.setState({ stats: resp.data.data, loading: false }) }) .catch(e => { notification["error"]({ message: "Error", description: e.message }) this.setState({ loading: false }) }) } orZero(v) { return v ? v : 0 } render() { return (

Welcome


{this.state.stats && (

{this.orZero(this.state.stats.subscribers.enabled)}

{this.orZero( this.state.stats.subscribers.blacklisted )}

{this.orZero(this.state.stats.orphan_subscribers)}

{this.orZero(this.state.stats.lists.public)}

{this.orZero(this.state.stats.lists.private)}


{this.state.stats.campaign_views.reduce( (total, v) => total + v.count, 0 )}{" "} views

{this.state.stats.link_clicks.reduce( (total, v) => total + v.count, 0 )}{" "} clicks

{this.campaignTypes.map(key => (

{key}

{this.state.stats.campaigns.hasOwnProperty(key) ? this.state.stats.campaigns[key] : 0}

))}
)}
) } } export default Dashboard