import React from 'react'; import { Doughnut, HorizontalBar } from 'react-chartjs-2'; import { connect } from 'react-redux'; import { pick } from 'ramda'; import { Card, CardBody, CardHeader } from 'reactstrap'; import { getShortUrlVisits } from './reducers/shortUrlVisits'; import VisitsParser from '../visits/services/VisitsParser'; import preloader from '@fortawesome/fontawesome-free-solid/faCircleNotch'; import FontAwesomeIcon from '@fortawesome/react-fontawesome'; export class ShortUrlsVisits extends React.Component { state = { startDate: '', endDate: '' }; componentDidMount() { const { match: { params } } = this.props; this.props.getShortUrlVisits(params.shortCode, this.state); } render() { const { match: { params }, selectedServer, visitsParser, shortUrlVisits: { visits, loading, error } } = this.props; const serverUrl = selectedServer ? selectedServer.url : ''; const shortUrl = `${serverUrl}/${params.shortCode}`; const generateGraphData = (stats, label, isBarChart) => ({ labels: Object.keys(stats), datasets: [ { label, data: Object.values(stats), backgroundColor: isBarChart ? 'rgba(200, 26, 80, 0.2)' : [], borderColor: isBarChart ? 'rgba(200, 26, 80, 1)' : [], } ] }); const renderGraphCard = (title, stats, isBarChart = true) =>