@ammarkhalidfarooq/dashboard-package 0.2.5 → 0.2.7

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,19 +1807,71 @@ 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;
1825
+ var totalVisData = Array.isArray(performanceData === null || performanceData === void 0 ? void 0 : performanceData.totalVisits) ? performanceData.totalVisits : [];
1826
+ var totalVisValues = totalVisData.length > 0 ? totalVisData.map(function (item) {
1827
+ return item.value;
1828
+ }) : visitorsData;
1829
+ var totalVisCategories = totalVisData.length > 0 ? totalVisData.map(function (item) {
1830
+ return item.date;
1831
+ }) : categories;
1832
+ var totalVisTotal = totalVisData.length > 0 ? totalVisValues.reduce(function (sum, val) {
1833
+ return sum + val;
1834
+ }, 0) : 1200;
1835
+ var upSellData = Array.isArray(performanceData === null || performanceData === void 0 ? void 0 : performanceData.upSellRaisedAmount) ? performanceData.upSellRaisedAmount : [];
1836
+ var upSellValues = upSellData.length > 0 ? upSellData.map(function (item) {
1837
+ return item.value;
1838
+ }) : revenueData;
1839
+ var upSellCategories = upSellData.length > 0 ? upSellData.map(function (item) {
1840
+ return item.date;
1841
+ }) : categories;
1842
+ var upSellTotal = upSellData.length > 0 ? upSellValues.reduce(function (sum, val) {
1843
+ return sum + val;
1844
+ }, 0) : 11050;
1845
+ var downSellData = Array.isArray(performanceData === null || performanceData === void 0 ? void 0 : performanceData.downSellRaisedAmount) ? performanceData.downSellRaisedAmount : [];
1846
+ var downSellValues = downSellData.length > 0 ? downSellData.map(function (item) {
1847
+ return item.value;
1848
+ }) : revenueData;
1849
+ var downSellCategories = downSellData.length > 0 ? downSellData.map(function (item) {
1850
+ return item.date;
1851
+ }) : categories;
1852
+ var downSellTotal = downSellData.length > 0 ? downSellValues.reduce(function (sum, val) {
1853
+ return sum + val;
1854
+ }, 0) : 1200;
1855
+ var abandonedData = Array.isArray(performanceData === null || performanceData === void 0 ? void 0 : performanceData.abandonedDonationRecoveryCount) ? performanceData.abandonedDonationRecoveryCount : [];
1856
+ var abandonedValues = abandonedData.length > 0 ? abandonedData.map(function (item) {
1857
+ return item.value;
1858
+ }) : visitorsData;
1859
+ var abandonedCategories = abandonedData.length > 0 ? abandonedData.map(function (item) {
1860
+ return item.date;
1861
+ }) : categories;
1862
+ var abandonedTotal = abandonedData.length > 0 ? abandonedValues.reduce(function (sum, val) {
1863
+ return sum + val;
1864
+ }, 0) : 14;
1810
1865
  var primaryCharts = [{
1811
1866
  label: 'Revenue per Visitor',
1812
- value: '$5.12',
1813
- data: revenueData,
1814
- categories: categories
1867
+ value: performanceData !== null && performanceData !== void 0 && performanceData.revenuePerVisitor ? "$".concat(revPerVisTotal.toFixed(2)) : '$5.12',
1868
+ data: revPerVisValues,
1869
+ categories: revPerVisCategories
1815
1870
  }, {
1816
1871
  label: 'Visitors',
1817
- value: '1200',
1818
- data: visitorsData,
1819
- categories: categories
1872
+ value: performanceData !== null && performanceData !== void 0 && performanceData.totalVisits ? totalVisTotal.toLocaleString() : '1200',
1873
+ data: totalVisValues,
1874
+ categories: totalVisCategories
1820
1875
  }];
1821
1876
  var secondaryCharts = [{
1822
1877
  label: 'Upsell Acceptance Rate',
@@ -1825,9 +1880,9 @@ var PerformanceSection = function PerformanceSection(_ref) {
1825
1880
  categories: categories
1826
1881
  }, {
1827
1882
  label: 'Upsell Raised Amount',
1828
- value: '$1,1050',
1829
- data: revenueData,
1830
- categories: categories
1883
+ value: performanceData !== null && performanceData !== void 0 && performanceData.upSellRaisedAmount ? "$".concat(upSellTotal.toLocaleString()) : '$1,1050',
1884
+ data: upSellValues,
1885
+ categories: upSellCategories
1831
1886
  }];
1832
1887
  var tertiaryCharts = [{
1833
1888
  label: 'Downsell Acceptance Rate',
@@ -1836,15 +1891,15 @@ var PerformanceSection = function PerformanceSection(_ref) {
1836
1891
  categories: categories
1837
1892
  }, {
1838
1893
  label: 'Downsell Raised Amount',
1839
- value: '$1,200',
1840
- data: revenueData,
1841
- categories: categories
1894
+ value: performanceData !== null && performanceData !== void 0 && performanceData.downSellRaisedAmount ? "$".concat(downSellTotal.toLocaleString()) : '$1,200',
1895
+ data: downSellValues,
1896
+ categories: downSellCategories
1842
1897
  }];
1843
1898
  var quaternaryCharts = [{
1844
1899
  label: 'Abandoned Donation Recovery',
1845
- value: '14',
1846
- data: visitorsData,
1847
- categories: categories
1900
+ value: performanceData !== null && performanceData !== void 0 && performanceData.abandonedDonationRecoveryCount ? abandonedTotal.toLocaleString() : '14',
1901
+ data: abandonedValues,
1902
+ categories: abandonedCategories
1848
1903
  }];
1849
1904
  return /*#__PURE__*/jsxRuntime.jsxs(Box, {
1850
1905
  sx: {