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