@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.cjs.js CHANGED
@@ -573,7 +573,9 @@ var Dashboard = function Dashboard(_ref) {
573
573
  _ref$categories = _ref.categories,
574
574
  categories = _ref$categories === void 0 ? ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"] : _ref$categories,
575
575
  _ref$apiData = _ref.apiData,
576
- apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
576
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
577
+ _ref$performanceData = _ref.performanceData,
578
+ performanceData = _ref$performanceData === void 0 ? {} : _ref$performanceData;
577
579
  var _React$useState = React.useState(initialMetric),
578
580
  _React$useState2 = _slicedToArray(_React$useState, 2),
579
581
  metric = _React$useState2[0];
@@ -650,7 +652,8 @@ var Dashboard = function Dashboard(_ref) {
650
652
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
651
653
  }),
652
654
  children: /*#__PURE__*/jsxRuntime.jsx(PerformanceSection$1, {
653
- apiData: apiData
655
+ apiData: apiData,
656
+ performanceData: performanceData
654
657
  })
655
658
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
656
659
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
@@ -1804,14 +1807,26 @@ var index$5 = /*#__PURE__*/Object.freeze({
1804
1807
 
1805
1808
  var PerformanceSection = function PerformanceSection(_ref) {
1806
1809
  _ref.title;
1810
+ var _ref$performanceData = _ref.performanceData,
1811
+ performanceData = _ref$performanceData === void 0 ? {} : _ref$performanceData;
1807
1812
  var revenueData = [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000];
1808
1813
  var visitorsData = [100, 200, 150, 250, 300, 275, 325, 350, 280];
1809
1814
  var categories = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'];
1815
+ var revPerVisData = Array.isArray(performanceData === null || performanceData === void 0 ? void 0 : performanceData.revenuePerVisitor) ? performanceData.revenuePerVisitor : [];
1816
+ var revPerVisValues = revPerVisData.length > 0 ? revPerVisData.map(function (item) {
1817
+ return item.value;
1818
+ }) : revenueData;
1819
+ var revPerVisCategories = revPerVisData.length > 0 ? revPerVisData.map(function (item) {
1820
+ return item.date;
1821
+ }) : categories;
1822
+ var revPerVisTotal = revPerVisData.length > 0 ? revPerVisValues.reduce(function (sum, val) {
1823
+ return sum + val;
1824
+ }, 0) / revPerVisValues.length : 5.12;
1810
1825
  var primaryCharts = [{
1811
1826
  label: 'Revenue per Visitor',
1812
- value: '$5.12',
1813
- data: revenueData,
1814
- categories: categories
1827
+ value: performanceData !== null && performanceData !== void 0 && performanceData.revenuePerVisitor ? "$".concat(revPerVisTotal.toFixed(2)) : '$5.12',
1828
+ data: revPerVisValues,
1829
+ categories: revPerVisCategories
1815
1830
  }, {
1816
1831
  label: 'Visitors',
1817
1832
  value: '1200',