@ammarkhalidfarooq/dashboard-package 0.1.2 → 0.1.5

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
@@ -91,6 +91,15 @@ function _toPropertyKey(t) {
91
91
  var i = _toPrimitive(t, "string");
92
92
  return "symbol" == typeof i ? i : i + "";
93
93
  }
94
+ function _typeof(o) {
95
+ "@babel/helpers - typeof";
96
+
97
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
98
+ return typeof o;
99
+ } : function (o) {
100
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
101
+ }, _typeof(o);
102
+ }
94
103
  function _unsupportedIterableToArray(r, a) {
95
104
  if (r) {
96
105
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
@@ -369,12 +378,18 @@ var RevenueChart = function RevenueChart(_ref) {
369
378
  if (isRadial) {
370
379
  var _series$;
371
380
  // For donut/pie, series must be a simple array of numbers
372
- chartSeries = Array.isArray(data) ? data : (series === null || series === void 0 || (_series$ = series[0]) === null || _series$ === void 0 ? void 0 : _series$.data) || [];
381
+ var processedData = Array.isArray(data) ? data.map(function (v) {
382
+ return _typeof(v) === 'object' && v !== null ? v.value : v;
383
+ }) : [];
384
+ chartSeries = processedData.length > 0 ? processedData : (series === null || series === void 0 || (_series$ = series[0]) === null || _series$ === void 0 ? void 0 : _series$.data) || [];
373
385
  } else {
374
386
  // For bar/line/area, series must be an array of objects [{ name: '', data: [] }]
387
+ var _processedData = Array.isArray(data) ? data.map(function (v) {
388
+ return _typeof(v) === 'object' && v !== null ? v.value : v;
389
+ }) : [];
375
390
  chartSeries = Array.isArray(series) ? series : [{
376
391
  name: metric || "Value",
377
- data: Array.isArray(data) ? data : []
392
+ data: _processedData
378
393
  }];
379
394
  }
380
395
  return /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
@@ -448,14 +463,14 @@ var RenderChartCard = function RenderChartCard(_ref) {
448
463
  color: "#000000",
449
464
  mb: 0.5
450
465
  },
451
- children: item.value
466
+ children: _typeof(item.value) === 'object' && item.value !== null ? item.value.value !== undefined ? item.value.value : JSON.stringify(item.value) : item.value
452
467
  }), item.subValue && /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
453
468
  variant: "subtitle2",
454
469
  sx: {
455
470
  color: "#000000",
456
471
  fontWeight: 600
457
472
  },
458
- children: item.subValue
473
+ children: _typeof(item.subValue) === 'object' && item.subValue !== null ? JSON.stringify(item.subValue) : item.subValue
459
474
  })]
460
475
  }), /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
461
476
  sx: {
@@ -556,7 +571,9 @@ var Dashboard = function Dashboard(_ref) {
556
571
  _ref$donationsData = _ref.donationsData,
557
572
  donationsData = _ref$donationsData === void 0 ? [15, 22, 18, 30, 25, 35, 42, 45, 28] : _ref$donationsData,
558
573
  _ref$categories = _ref.categories,
559
- categories = _ref$categories === void 0 ? ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"] : _ref$categories;
574
+ categories = _ref$categories === void 0 ? ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"] : _ref$categories,
575
+ _ref$apiData = _ref.apiData,
576
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
560
577
  var _React$useState = React.useState(initialMetric),
561
578
  _React$useState2 = _slicedToArray(_React$useState, 2),
562
579
  metric = _React$useState2[0];
@@ -621,7 +638,9 @@ var Dashboard = function Dashboard(_ref) {
621
638
  },
622
639
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
623
640
  }),
624
- children: /*#__PURE__*/jsxRuntime.jsx(NewOverview$1, {})
641
+ children: /*#__PURE__*/jsxRuntime.jsx(NewOverview$1, {
642
+ apiData: apiData
643
+ })
625
644
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
626
645
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
627
646
  sx: {
@@ -630,7 +649,9 @@ var Dashboard = function Dashboard(_ref) {
630
649
  },
631
650
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
632
651
  }),
633
- children: /*#__PURE__*/jsxRuntime.jsx(PerformanceSection$1, {})
652
+ children: /*#__PURE__*/jsxRuntime.jsx(PerformanceSection$1, {
653
+ apiData: apiData
654
+ })
634
655
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
635
656
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
636
657
  sx: {
@@ -639,7 +660,9 @@ var Dashboard = function Dashboard(_ref) {
639
660
  },
640
661
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
641
662
  }),
642
- children: /*#__PURE__*/jsxRuntime.jsx(RecurringPlans$1, {})
663
+ children: /*#__PURE__*/jsxRuntime.jsx(RecurringPlans$1, {
664
+ apiData: apiData
665
+ })
643
666
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
644
667
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
645
668
  sx: {
@@ -648,7 +671,9 @@ var Dashboard = function Dashboard(_ref) {
648
671
  },
649
672
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
650
673
  }),
651
- children: /*#__PURE__*/jsxRuntime.jsx(RecurringRevenueSection$1, {})
674
+ children: /*#__PURE__*/jsxRuntime.jsx(RecurringRevenueSection$1, {
675
+ apiData: apiData
676
+ })
652
677
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
653
678
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
654
679
  sx: {
@@ -657,7 +682,9 @@ var Dashboard = function Dashboard(_ref) {
657
682
  },
658
683
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
659
684
  }),
660
- children: /*#__PURE__*/jsxRuntime.jsx(DonorBehavior$1, {})
685
+ children: /*#__PURE__*/jsxRuntime.jsx(DonorBehavior$1, {
686
+ apiData: apiData
687
+ })
661
688
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
662
689
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
663
690
  sx: {
@@ -666,7 +693,9 @@ var Dashboard = function Dashboard(_ref) {
666
693
  },
667
694
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
668
695
  }),
669
- children: /*#__PURE__*/jsxRuntime.jsx(UpdateEmails$1, {})
696
+ children: /*#__PURE__*/jsxRuntime.jsx(UpdateEmails$1, {
697
+ apiData: apiData
698
+ })
670
699
  })]
671
700
  });
672
701
  };
@@ -709,13 +738,15 @@ var DisplayCard = function DisplayCard(_ref) {
709
738
  fontSize: '22px',
710
739
  fontWeight: '500'
711
740
  },
712
- children: value
741
+ children: _typeof(value) === 'object' && value !== null ? value.value !== undefined ? value.value : JSON.stringify(value) : value
713
742
  })]
714
743
  })
715
744
  });
716
745
  };
717
746
 
718
- var OrganicSection = function OrganicSection() {
747
+ var OrganicSection = function OrganicSection(_ref) {
748
+ var _ref$apiData = _ref.apiData,
749
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
719
750
  var categories = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
720
751
  var dailyPerformance = {
721
752
  label: "Search Visibility",
@@ -747,37 +778,37 @@ var OrganicSection = function OrganicSection() {
747
778
  },
748
779
  children: [/*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
749
780
  title: "Organic Users",
750
- value: "$9,200",
781
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.organicUsers) || "$9,200",
751
782
  sx: {
752
783
  flex: 1
753
784
  }
754
785
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
755
786
  title: "Search Clicks",
756
- value: "$9,200",
787
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.searchClicks) || "$9,200",
757
788
  sx: {
758
789
  flex: 1
759
790
  }
760
791
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
761
792
  title: "Donations",
762
- value: "$9,200",
793
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.donations) || "$9,200",
763
794
  sx: {
764
795
  flex: 1
765
796
  }
766
797
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
767
798
  title: "Converstion Rate",
768
- value: "$9,200",
799
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.conversionRate) || "$9,200",
769
800
  sx: {
770
801
  flex: 1
771
802
  }
772
803
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
773
804
  title: "Revenue Raised",
774
- value: "3.0",
805
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.revenueRaised) || "3.0",
775
806
  sx: {
776
807
  flex: 1
777
808
  }
778
809
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
779
810
  title: "Avg Donation",
780
- value: "215",
811
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.avgDonation) || "215",
781
812
  sx: {
782
813
  flex: 1
783
814
  }
@@ -818,11 +849,13 @@ var OverallSection$2 = /*#__PURE__*/React.lazy(function () {
818
849
  var PaidSection$2 = /*#__PURE__*/React.lazy(function () {
819
850
  return Promise.resolve().then(function () { return PaidSection$1; });
820
851
  });
821
- var NewOverview = function NewOverview() {
852
+ var NewOverview = function NewOverview(_ref) {
853
+ var _ref$apiData = _ref.apiData,
854
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
822
855
  var initialMetric = "Revenue";
823
- var revenueData = [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000];
824
- var donationsData = [15, 22, 18, 30, 25, 35, 42, 45, 28];
825
- var categories = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"];
856
+ var revenueData = (apiData === null || apiData === void 0 ? void 0 : apiData.revenueData) || [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000];
857
+ var donationsData = (apiData === null || apiData === void 0 ? void 0 : apiData.donationsData) || [15, 22, 18, 30, 25, 35, 42, 45, 28];
858
+ var categories = (apiData === null || apiData === void 0 ? void 0 : apiData.categories) || ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"];
826
859
  var _useState = React.useState(initialMetric),
827
860
  _useState2 = _slicedToArray(_useState, 2),
828
861
  metric = _useState2[0];
@@ -832,10 +865,20 @@ var NewOverview = function NewOverview() {
832
865
  activeSection = _useState4[0],
833
866
  setActiveSection = _useState4[1];
834
867
  var currentData = metric === "Revenue" ? revenueData : donationsData;
868
+ var oneTimeData = (apiData === null || apiData === void 0 ? void 0 : apiData.oneTimeDonations) || [];
869
+ var oneTimeValues = oneTimeData.length > 0 ? oneTimeData.map(function (item) {
870
+ return item.value;
871
+ }) : currentData;
872
+ var oneTimeCategories = oneTimeData.length > 0 ? oneTimeData.map(function (item) {
873
+ return item.date;
874
+ }) : categories;
875
+ var oneTimeTotal = oneTimeData.length > 0 ? oneTimeValues.reduce(function (sum, val) {
876
+ return sum + val;
877
+ }, 0) : 7100;
835
878
  var primaryCharts = [{
836
879
  label: "Total Revenue",
837
- value: "$9,200.00",
838
- subValue: "Total Donations: 215",
880
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRevenue) || "$9,200.00",
881
+ subValue: "Total Donations: ".concat((apiData === null || apiData === void 0 ? void 0 : apiData.totalDonations) || 215),
839
882
  data: currentData,
840
883
  categories: categories,
841
884
  showSelector: true
@@ -846,9 +889,9 @@ var NewOverview = function NewOverview() {
846
889
  categories: categories.slice(-7)
847
890
  }, {
848
891
  label: "One-time donations",
849
- value: "$7,100.00",
850
- data: currentData,
851
- categories: categories
892
+ value: apiData !== null && apiData !== void 0 && apiData.oneTimeDonations ? "$".concat(oneTimeTotal.toLocaleString()) : "$7,100.00",
893
+ data: oneTimeValues,
894
+ categories: oneTimeCategories
852
895
  }];
853
896
  var secondaryCharts = [{
854
897
  label: "New vs Returning Donors",
@@ -997,15 +1040,20 @@ var NewOverview = function NewOverview() {
997
1040
  })
998
1041
  }),
999
1042
  children: [activeSection === "Overall" && /*#__PURE__*/jsxRuntime.jsx(OverallSection$2, {
1043
+ apiData: apiData,
1000
1044
  primaryCharts: primaryCharts,
1001
1045
  secondaryCharts: secondaryCharts,
1002
1046
  tertiaryCharts: tertiaryCharts,
1003
1047
  quaternaryCharts: quaternaryCharts
1004
- }), activeSection === "Paid" && /*#__PURE__*/jsxRuntime.jsx(PaidSection$2, {}), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1048
+ }), activeSection === "Paid" && /*#__PURE__*/jsxRuntime.jsx(PaidSection$2, {
1049
+ apiData: apiData
1050
+ }), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1005
1051
  sx: {
1006
1052
  p: 2
1007
1053
  },
1008
- children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection, {})
1054
+ children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection, {
1055
+ apiData: apiData
1056
+ })
1009
1057
  }), activeSection === "Email" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1010
1058
  sx: {
1011
1059
  p: 2
@@ -5147,7 +5195,9 @@ var index = /*#__PURE__*/Object.freeze({
5147
5195
  });
5148
5196
 
5149
5197
  var OverallSection = function OverallSection(_ref) {
5150
- var primaryCharts = _ref.primaryCharts,
5198
+ var _ref$apiData = _ref.apiData,
5199
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
5200
+ primaryCharts = _ref.primaryCharts,
5151
5201
  secondaryCharts = _ref.secondaryCharts,
5152
5202
  tertiaryCharts = _ref.tertiaryCharts,
5153
5203
  quaternaryCharts = _ref.quaternaryCharts;
@@ -5160,31 +5210,31 @@ var OverallSection = function OverallSection(_ref) {
5160
5210
  },
5161
5211
  children: [/*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
5162
5212
  title: "Total Raised",
5163
- value: "$9,200",
5213
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaised) || "$9,200",
5164
5214
  sx: {
5165
5215
  flex: 1
5166
5216
  }
5167
5217
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
5168
5218
  title: "Net Raised",
5169
- value: "$9,200",
5219
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.netRaised) || "$9,200",
5170
5220
  sx: {
5171
5221
  flex: 1
5172
5222
  }
5173
5223
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
5174
5224
  title: "Total Spent",
5175
- value: "$9,200",
5225
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalSpent) || "$9,200",
5176
5226
  sx: {
5177
5227
  flex: 1
5178
5228
  }
5179
5229
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
5180
5230
  title: "Total ROAS",
5181
- value: "3.0",
5231
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRoas) || "3.0",
5182
5232
  sx: {
5183
5233
  flex: 1
5184
5234
  }
5185
5235
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
5186
5236
  title: "Total Donors",
5187
- value: "215",
5237
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalDonors) || "215",
5188
5238
  sx: {
5189
5239
  flex: 1
5190
5240
  }
@@ -5199,7 +5249,7 @@ var OverallSection = function OverallSection(_ref) {
5199
5249
  return /*#__PURE__*/jsxRuntime.jsx(RenderChartCard, {
5200
5250
  item: item,
5201
5251
  index: index
5202
- });
5252
+ }, "primary-".concat(index));
5203
5253
  })
5204
5254
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
5205
5255
  container: true,
@@ -5211,7 +5261,7 @@ var OverallSection = function OverallSection(_ref) {
5211
5261
  return /*#__PURE__*/jsxRuntime.jsx(RenderChartCard, {
5212
5262
  item: item,
5213
5263
  index: index
5214
- });
5264
+ }, "secondary-".concat(index));
5215
5265
  })
5216
5266
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
5217
5267
  container: true,
@@ -5223,7 +5273,7 @@ var OverallSection = function OverallSection(_ref) {
5223
5273
  return /*#__PURE__*/jsxRuntime.jsx(RenderChartCard, {
5224
5274
  item: item,
5225
5275
  index: index
5226
- });
5276
+ }, "tertiary-".concat(index));
5227
5277
  })
5228
5278
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
5229
5279
  container: true,
@@ -5235,7 +5285,7 @@ var OverallSection = function OverallSection(_ref) {
5235
5285
  return /*#__PURE__*/jsxRuntime.jsx(RenderChartCard, {
5236
5286
  item: item,
5237
5287
  index: index
5238
- });
5288
+ }, "quaternary-".concat(index));
5239
5289
  })
5240
5290
  })]
5241
5291
  });