@ammarkhalidfarooq/dashboard-package 0.1.2 → 0.1.4

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
@@ -556,7 +556,9 @@ var Dashboard = function Dashboard(_ref) {
556
556
  _ref$donationsData = _ref.donationsData,
557
557
  donationsData = _ref$donationsData === void 0 ? [15, 22, 18, 30, 25, 35, 42, 45, 28] : _ref$donationsData,
558
558
  _ref$categories = _ref.categories,
559
- categories = _ref$categories === void 0 ? ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"] : _ref$categories;
559
+ categories = _ref$categories === void 0 ? ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"] : _ref$categories,
560
+ _ref$apiData = _ref.apiData,
561
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
560
562
  var _React$useState = React.useState(initialMetric),
561
563
  _React$useState2 = _slicedToArray(_React$useState, 2),
562
564
  metric = _React$useState2[0];
@@ -621,7 +623,9 @@ var Dashboard = function Dashboard(_ref) {
621
623
  },
622
624
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
623
625
  }),
624
- children: /*#__PURE__*/jsxRuntime.jsx(NewOverview$1, {})
626
+ children: /*#__PURE__*/jsxRuntime.jsx(NewOverview$1, {
627
+ apiData: apiData
628
+ })
625
629
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
626
630
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
627
631
  sx: {
@@ -630,7 +634,9 @@ var Dashboard = function Dashboard(_ref) {
630
634
  },
631
635
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
632
636
  }),
633
- children: /*#__PURE__*/jsxRuntime.jsx(PerformanceSection$1, {})
637
+ children: /*#__PURE__*/jsxRuntime.jsx(PerformanceSection$1, {
638
+ apiData: apiData
639
+ })
634
640
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
635
641
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
636
642
  sx: {
@@ -639,7 +645,9 @@ var Dashboard = function Dashboard(_ref) {
639
645
  },
640
646
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
641
647
  }),
642
- children: /*#__PURE__*/jsxRuntime.jsx(RecurringPlans$1, {})
648
+ children: /*#__PURE__*/jsxRuntime.jsx(RecurringPlans$1, {
649
+ apiData: apiData
650
+ })
643
651
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
644
652
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
645
653
  sx: {
@@ -648,7 +656,9 @@ var Dashboard = function Dashboard(_ref) {
648
656
  },
649
657
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
650
658
  }),
651
- children: /*#__PURE__*/jsxRuntime.jsx(RecurringRevenueSection$1, {})
659
+ children: /*#__PURE__*/jsxRuntime.jsx(RecurringRevenueSection$1, {
660
+ apiData: apiData
661
+ })
652
662
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
653
663
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
654
664
  sx: {
@@ -657,7 +667,9 @@ var Dashboard = function Dashboard(_ref) {
657
667
  },
658
668
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
659
669
  }),
660
- children: /*#__PURE__*/jsxRuntime.jsx(DonorBehavior$1, {})
670
+ children: /*#__PURE__*/jsxRuntime.jsx(DonorBehavior$1, {
671
+ apiData: apiData
672
+ })
661
673
  }), /*#__PURE__*/jsxRuntime.jsx(React.Suspense, {
662
674
  fallback: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
663
675
  sx: {
@@ -666,7 +678,9 @@ var Dashboard = function Dashboard(_ref) {
666
678
  },
667
679
  children: /*#__PURE__*/jsxRuntime.jsx(material.CircularProgress, {})
668
680
  }),
669
- children: /*#__PURE__*/jsxRuntime.jsx(UpdateEmails$1, {})
681
+ children: /*#__PURE__*/jsxRuntime.jsx(UpdateEmails$1, {
682
+ apiData: apiData
683
+ })
670
684
  })]
671
685
  });
672
686
  };
@@ -715,7 +729,9 @@ var DisplayCard = function DisplayCard(_ref) {
715
729
  });
716
730
  };
717
731
 
718
- var OrganicSection = function OrganicSection() {
732
+ var OrganicSection = function OrganicSection(_ref) {
733
+ var _ref$apiData = _ref.apiData,
734
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
719
735
  var categories = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
720
736
  var dailyPerformance = {
721
737
  label: "Search Visibility",
@@ -747,37 +763,37 @@ var OrganicSection = function OrganicSection() {
747
763
  },
748
764
  children: [/*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
749
765
  title: "Organic Users",
750
- value: "$9,200",
766
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.organicUsers) || "$9,200",
751
767
  sx: {
752
768
  flex: 1
753
769
  }
754
770
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
755
771
  title: "Search Clicks",
756
- value: "$9,200",
772
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.searchClicks) || "$9,200",
757
773
  sx: {
758
774
  flex: 1
759
775
  }
760
776
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
761
777
  title: "Donations",
762
- value: "$9,200",
778
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.donations) || "$9,200",
763
779
  sx: {
764
780
  flex: 1
765
781
  }
766
782
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
767
783
  title: "Converstion Rate",
768
- value: "$9,200",
784
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.conversionRate) || "$9,200",
769
785
  sx: {
770
786
  flex: 1
771
787
  }
772
788
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
773
789
  title: "Revenue Raised",
774
- value: "3.0",
790
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.revenueRaised) || "3.0",
775
791
  sx: {
776
792
  flex: 1
777
793
  }
778
794
  }), /*#__PURE__*/jsxRuntime.jsx(DisplayCard, {
779
795
  title: "Avg Donation",
780
- value: "215",
796
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.avgDonation) || "215",
781
797
  sx: {
782
798
  flex: 1
783
799
  }
@@ -818,11 +834,13 @@ var OverallSection$2 = /*#__PURE__*/React.lazy(function () {
818
834
  var PaidSection$2 = /*#__PURE__*/React.lazy(function () {
819
835
  return Promise.resolve().then(function () { return PaidSection$1; });
820
836
  });
821
- var NewOverview = function NewOverview() {
837
+ var NewOverview = function NewOverview(_ref) {
838
+ var _ref$apiData = _ref.apiData,
839
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
822
840
  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"];
841
+ var revenueData = (apiData === null || apiData === void 0 ? void 0 : apiData.revenueData) || [3000, 4500, 4200, 5800, 5200, 7100, 8500, 9200, 5000];
842
+ var donationsData = (apiData === null || apiData === void 0 ? void 0 : apiData.donationsData) || [15, 22, 18, 30, 25, 35, 42, 45, 28];
843
+ var categories = (apiData === null || apiData === void 0 ? void 0 : apiData.categories) || ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"];
826
844
  var _useState = React.useState(initialMetric),
827
845
  _useState2 = _slicedToArray(_useState, 2),
828
846
  metric = _useState2[0];
@@ -832,10 +850,20 @@ var NewOverview = function NewOverview() {
832
850
  activeSection = _useState4[0],
833
851
  setActiveSection = _useState4[1];
834
852
  var currentData = metric === "Revenue" ? revenueData : donationsData;
853
+ var oneTimeData = (apiData === null || apiData === void 0 ? void 0 : apiData.oneTimeDonations) || [];
854
+ var oneTimeValues = oneTimeData.length > 0 ? oneTimeData.map(function (item) {
855
+ return item.value;
856
+ }) : currentData;
857
+ var oneTimeCategories = oneTimeData.length > 0 ? oneTimeData.map(function (item) {
858
+ return item.date;
859
+ }) : categories;
860
+ var oneTimeTotal = oneTimeData.length > 0 ? oneTimeValues.reduce(function (sum, val) {
861
+ return sum + val;
862
+ }, 0) : 7100;
835
863
  var primaryCharts = [{
836
864
  label: "Total Revenue",
837
- value: "$9,200.00",
838
- subValue: "Total Donations: 215",
865
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRevenue) || "$9,200.00",
866
+ subValue: "Total Donations: ".concat((apiData === null || apiData === void 0 ? void 0 : apiData.totalDonations) || 215),
839
867
  data: currentData,
840
868
  categories: categories,
841
869
  showSelector: true
@@ -846,9 +874,9 @@ var NewOverview = function NewOverview() {
846
874
  categories: categories.slice(-7)
847
875
  }, {
848
876
  label: "One-time donations",
849
- value: "$7,100.00",
850
- data: currentData,
851
- categories: categories
877
+ value: apiData !== null && apiData !== void 0 && apiData.oneTimeDonations ? "$".concat(oneTimeTotal.toLocaleString()) : "$7,100.00",
878
+ data: oneTimeValues,
879
+ categories: oneTimeCategories
852
880
  }];
853
881
  var secondaryCharts = [{
854
882
  label: "New vs Returning Donors",
@@ -997,15 +1025,20 @@ var NewOverview = function NewOverview() {
997
1025
  })
998
1026
  }),
999
1027
  children: [activeSection === "Overall" && /*#__PURE__*/jsxRuntime.jsx(OverallSection$2, {
1028
+ apiData: apiData,
1000
1029
  primaryCharts: primaryCharts,
1001
1030
  secondaryCharts: secondaryCharts,
1002
1031
  tertiaryCharts: tertiaryCharts,
1003
1032
  quaternaryCharts: quaternaryCharts
1004
- }), activeSection === "Paid" && /*#__PURE__*/jsxRuntime.jsx(PaidSection$2, {}), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1033
+ }), activeSection === "Paid" && /*#__PURE__*/jsxRuntime.jsx(PaidSection$2, {
1034
+ apiData: apiData
1035
+ }), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1005
1036
  sx: {
1006
1037
  p: 2
1007
1038
  },
1008
- children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection, {})
1039
+ children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection, {
1040
+ apiData: apiData
1041
+ })
1009
1042
  }), activeSection === "Email" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1010
1043
  sx: {
1011
1044
  p: 2