All files / comparison_chart/components/ChartAndFooter index.jsx

37.5% Statements 3/8
0% Branches 0/6
0% Functions 0/1
37.5% Lines 3/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55                      1x                                                 1x       1x                            
import React from 'react';
import PropTypes from 'prop-types';
 
import {
  ChartStateNoData as NoData,
  ChartStateLoading as Loading,
} from '@bufferapp/analyze-shared-components';
 
import Chart from '../Chart';
import Footer from '../Footer';
 
const ChartAndFooter = ({
  loading,
  metrics,
  metricKey,
  profiles,
}) => {
  if (loading) {
    return <Loading active noBorder large />;
  } else if (!metrics || !metrics[metricKey]) {
    return <NoData />;
  }
  return (<div>
    <Chart
      metricKey={metricKey}
      profilesMetricData={metrics[metricKey].profilesMetricData}
      profiles={profiles}
    />
    <Footer
      profileTotals={metrics[metricKey].profileTotals}
      profiles={profiles}
      metricKey={metricKey}
    />
  </div>);
};
 
ChartAndFooter.defaultProps = {
  loading: false,
};
 
ChartAndFooter.propTypes = {
  loading: PropTypes.bool,
  metrics: PropTypes.shape({}).isRequired,
  metricKey: PropTypes.string.isRequired,
  profiles: PropTypes.arrayOf(PropTypes.shape({
    id: PropTypes.string.isRequired,
    username: PropTypes.string.isRequired,
    avatarUrl: PropTypes.string.isRequired,
    service: PropTypes.string.isRequired,
  })).isRequired,
};
 
export default ChartAndFooter;