@ammarkhalidfarooq/dashboard-package 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -571,7 +571,9 @@ var Dashboard = function Dashboard(_ref) {
571
571
  _ref$categories = _ref.categories,
572
572
  categories = _ref$categories === void 0 ? ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"] : _ref$categories,
573
573
  _ref$apiData = _ref.apiData,
574
- apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
574
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
575
+ _ref$performanceData = _ref.performanceData,
576
+ performanceData = _ref$performanceData === void 0 ? {} : _ref$performanceData;
575
577
  var _React$useState = React.useState(initialMetric),
576
578
  _React$useState2 = _slicedToArray(_React$useState, 2),
577
579
  metric = _React$useState2[0];
@@ -648,7 +650,8 @@ var Dashboard = function Dashboard(_ref) {
648
650
  children: /*#__PURE__*/jsx(CircularProgress, {})
649
651
  }),
650
652
  children: /*#__PURE__*/jsx(PerformanceSection$1, {
651
- apiData: apiData
653
+ apiData: apiData,
654
+ performanceData: performanceData
652
655
  })
653
656
  }), /*#__PURE__*/jsx(Suspense, {
654
657
  fallback: /*#__PURE__*/jsx(Box, {
@@ -1802,14 +1805,26 @@ var index$5 = /*#__PURE__*/Object.freeze({
1802
1805
 
1803
1806
  var PerformanceSection = function PerformanceSection(_ref) {
1804
1807
  _ref.title;
1808
+ var _ref$performanceData = _ref.performanceData,
1809
+ performanceData = _ref$performanceData === void 0 ? {} : _ref$performanceData;
1805
1810
  var revenueData = [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000];
1806
1811
  var visitorsData = [100, 200, 150, 250, 300, 275, 325, 350, 280];
1807
1812
  var categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'];
1813
+ var revPerVisData = Array.isArray(performanceData === null || performanceData === void 0 ? void 0 : performanceData.revenuePerVisitor) ? performanceData.revenuePerVisitor : [];
1814
+ var revPerVisValues = revPerVisData.length > 0 ? revPerVisData.map(function (item) {
1815
+ return item.value;
1816
+ }) : revenueData;
1817
+ var revPerVisCategories = revPerVisData.length > 0 ? revPerVisData.map(function (item) {
1818
+ return item.date;
1819
+ }) : categories;
1820
+ var revPerVisTotal = revPerVisData.length > 0 ? revPerVisValues.reduce(function (sum, val) {
1821
+ return sum + val;
1822
+ }, 0) / revPerVisValues.length : 5.12;
1808
1823
  var primaryCharts = [{
1809
1824
  label: 'Revenue per Visitor',
1810
- value: '$5.12',
1811
- data: revenueData,
1812
- categories: categories
1825
+ value: performanceData !== null && performanceData !== void 0 && performanceData.revenuePerVisitor ? "$".concat(revPerVisTotal.toFixed(2)) : '$5.12',
1826
+ data: revPerVisValues,
1827
+ categories: revPerVisCategories
1813
1828
  }, {
1814
1829
  label: 'Visitors',
1815
1830
  value: '1200',