@ammarkhalidfarooq/dashboard-package 0.5.38 → 0.5.39

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
@@ -111,7 +111,10 @@ function _iterableToArrayLimit(r, l) {
111
111
  f = true,
112
112
  o = false;
113
113
  try {
114
- if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
114
+ if (i = (t = t.call(r)).next, 0 === l) {
115
+ if (Object(t) !== t) return;
116
+ f = !1;
117
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
115
118
  } catch (r) {
116
119
  o = true, n = r;
117
120
  } finally {
@@ -3268,8 +3271,9 @@ var GeographyCard = function GeographyCard(_ref4) {
3268
3271
  })
3269
3272
  });
3270
3273
  };
3271
- var TopCampaignsRaisedCard = function TopCampaignsRaisedCard() {
3272
- var data = [{
3274
+ var TopCampaignsRaisedCard = function TopCampaignsRaisedCard(_ref5) {
3275
+ var dataProp = _ref5.data;
3276
+ var data = dataProp !== null && dataProp !== void 0 ? dataProp : [{
3273
3277
  id: "RK",
3274
3278
  name: "Ramadan kickoff",
3275
3279
  value: "$14,200"
@@ -3315,7 +3319,15 @@ var TopCampaignsRaisedCard = function TopCampaignsRaisedCard() {
3315
3319
  },
3316
3320
  children: "Raised"
3317
3321
  })]
3318
- }), data.map(function (item, index) {
3322
+ }), data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3323
+ sx: {
3324
+ fontSize: "13px",
3325
+ color: "rgba(0, 0, 0, 0.45)",
3326
+ py: 2,
3327
+ textAlign: "left"
3328
+ },
3329
+ children: "No campaign data for this period."
3330
+ }) : data.map(function (item, index) {
3319
3331
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3320
3332
  sx: {
3321
3333
  display: "flex",
@@ -3365,8 +3377,9 @@ var TopCampaignsRaisedCard = function TopCampaignsRaisedCard() {
3365
3377
  })]
3366
3378
  });
3367
3379
  };
3368
- var TopCampaignsCTRCard = function TopCampaignsCTRCard() {
3369
- var data = [{
3380
+ var TopCampaignsCTRCard = function TopCampaignsCTRCard(_ref6) {
3381
+ var dataProp = _ref6.data;
3382
+ var data = dataProp !== null && dataProp !== void 0 ? dataProp : [{
3370
3383
  id: "RK",
3371
3384
  name: "Ramadan kickoff",
3372
3385
  value: "12.4%"
@@ -3412,7 +3425,15 @@ var TopCampaignsCTRCard = function TopCampaignsCTRCard() {
3412
3425
  },
3413
3426
  children: "CTR"
3414
3427
  })]
3415
- }), data.map(function (item, index) {
3428
+ }), data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3429
+ sx: {
3430
+ fontSize: "13px",
3431
+ color: "rgba(0, 0, 0, 0.45)",
3432
+ py: 2,
3433
+ textAlign: "left"
3434
+ },
3435
+ children: "No campaign data for this period."
3436
+ }) : data.map(function (item, index) {
3416
3437
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3417
3438
  sx: {
3418
3439
  display: "flex",
@@ -3462,8 +3483,9 @@ var TopCampaignsCTRCard = function TopCampaignsCTRCard() {
3462
3483
  })]
3463
3484
  });
3464
3485
  };
3465
- var TopCampaignsConvRateCard = function TopCampaignsConvRateCard() {
3466
- var data = [{
3486
+ var TopCampaignsConvRateCard = function TopCampaignsConvRateCard(_ref7) {
3487
+ var dataProp = _ref7.data;
3488
+ var data = dataProp !== null && dataProp !== void 0 ? dataProp : [{
3467
3489
  id: "YO",
3468
3490
  name: "Yemen orphans drive",
3469
3491
  value: "5.2%"
@@ -3509,7 +3531,15 @@ var TopCampaignsConvRateCard = function TopCampaignsConvRateCard() {
3509
3531
  },
3510
3532
  children: "Conv. rate"
3511
3533
  })]
3512
- }), data.map(function (item, index) {
3534
+ }), data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
3535
+ sx: {
3536
+ fontSize: "13px",
3537
+ color: "rgba(0, 0, 0, 0.45)",
3538
+ py: 2,
3539
+ textAlign: "left"
3540
+ },
3541
+ children: "No campaign data for this period."
3542
+ }) : data.map(function (item, index) {
3513
3543
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
3514
3544
  sx: {
3515
3545
  display: "flex",
@@ -3706,9 +3736,9 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
3706
3736
  })]
3707
3737
  });
3708
3738
  };
3709
- var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref5) {
3710
- var sx = _ref5.sx,
3711
- donorGeographyData = _ref5.donorGeographyData;
3739
+ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref8) {
3740
+ var sx = _ref8.sx,
3741
+ donorGeographyData = _ref8.donorGeographyData;
3712
3742
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || [];
3713
3743
  var data = rawCountries.map(function (item) {
3714
3744
  return {
@@ -4948,7 +4978,10 @@ var NewOverview = function NewOverview(_ref) {
4948
4978
  })
4949
4979
  }), activeSection === "Email" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4950
4980
  sx: {},
4951
- children: /*#__PURE__*/jsxRuntime.jsx(EmailSection$2, {})
4981
+ children: /*#__PURE__*/jsxRuntime.jsx(EmailSection$2, {
4982
+ apiData: apiData,
4983
+ dateName: dateName
4984
+ })
4952
4985
  })]
4953
4986
  }), showExportLayout && /*#__PURE__*/jsxRuntime.jsx("div", {
4954
4987
  "aria-hidden": "true",
@@ -15320,10 +15353,10 @@ var PaidSection$1 = /*#__PURE__*/Object.freeze({
15320
15353
  default: PaidSection
15321
15354
  });
15322
15355
 
15323
- var formatGrowth = function formatGrowth(value, dateName) {
15356
+ var formatGrowth$1 = function formatGrowth(value, dateName) {
15324
15357
  return "".concat(Number(value !== null && value !== void 0 ? value : 0).toFixed(2), "% vs ").concat(dateName || "previous period");
15325
15358
  };
15326
- var mapTimeSeries = function mapTimeSeries(series) {
15359
+ var mapTimeSeries$1 = function mapTimeSeries(series) {
15327
15360
  if (!Array.isArray(series) || series.length === 0) {
15328
15361
  return {
15329
15362
  categories: [],
@@ -15353,14 +15386,14 @@ var OrganicSection = function OrganicSection(_ref) {
15353
15386
  var overview = (apiData === null || apiData === void 0 ? void 0 : apiData.overview) || {};
15354
15387
  var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
15355
15388
  var hasOrganicOverview = Boolean(apiData === null || apiData === void 0 ? void 0 : apiData.overview);
15356
- var organicUsersSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.organicUsers);
15357
- var donationsSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.totalDonations);
15358
- var conversionSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.conversionRate);
15359
- var revenueSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.totalRevenue);
15360
- var avgDonationSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.avgDonations);
15389
+ var organicUsersSeries = mapTimeSeries$1(apiData === null || apiData === void 0 ? void 0 : apiData.organicUsers);
15390
+ var donationsSeries = mapTimeSeries$1(apiData === null || apiData === void 0 ? void 0 : apiData.totalDonations);
15391
+ var conversionSeries = mapTimeSeries$1(apiData === null || apiData === void 0 ? void 0 : apiData.conversionRate);
15392
+ var revenueSeries = mapTimeSeries$1(apiData === null || apiData === void 0 ? void 0 : apiData.totalRevenue);
15393
+ var avgDonationSeries = mapTimeSeries$1(apiData === null || apiData === void 0 ? void 0 : apiData.avgDonations);
15361
15394
  var fallbackCategories = organicUsersSeries.categories.length ? organicUsersSeries.categories : ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
15362
15395
  var growthCaption = function growthCaption(key) {
15363
- return formatGrowth(growth[key], dateName);
15396
+ return formatGrowth$1(growth[key], dateName);
15364
15397
  };
15365
15398
  var metricInfo = React.useMemo(function () {
15366
15399
  var _overview$totalRevenu2, _overview$overallAVGD2, _overview$organicUser, _apiData$topOrganicKe, _overview$totalDonati, _overview$conversionR, _overview$totalRevenu3, _overview$overallAVGD3;
@@ -15715,13 +15748,42 @@ var OrganicSection$1 = /*#__PURE__*/Object.freeze({
15715
15748
  default: OrganicSection
15716
15749
  });
15717
15750
 
15751
+ var formatCategoryLabel = function formatCategoryLabel(val) {
15752
+ if (!val || typeof val !== "string") return val;
15753
+ var ddMmYyyy = val.match(/^(\d{2})-(\d{2})-(\d{4})$/);
15754
+ if (ddMmYyyy) {
15755
+ var _ddMmYyyy = _slicedToArray(ddMmYyyy, 4),
15756
+ day = _ddMmYyyy[1],
15757
+ month = _ddMmYyyy[2],
15758
+ year = _ddMmYyyy[3];
15759
+ var _date = new Date(Number(year), Number(month) - 1, Number(day));
15760
+ if (!Number.isNaN(_date.getTime())) {
15761
+ return _date.toLocaleDateString("en-US", {
15762
+ month: "short",
15763
+ day: "numeric"
15764
+ });
15765
+ }
15766
+ }
15767
+ var date = new Date(val);
15768
+ if (!Number.isNaN(date.getTime())) {
15769
+ return date.toLocaleDateString("en-US", {
15770
+ month: "short",
15771
+ day: "numeric"
15772
+ });
15773
+ }
15774
+ return val;
15775
+ };
15718
15776
  var EmailTrendCard = function EmailTrendCard(_ref) {
15719
15777
  var title = _ref.title,
15720
15778
  subtitle = _ref.subtitle,
15721
15779
  value = _ref.value,
15722
15780
  trend = _ref.trend,
15723
- series = _ref.series,
15781
+ _ref$series = _ref.series,
15782
+ series = _ref$series === void 0 ? [] : _ref$series,
15783
+ trendData = _ref.trendData,
15784
+ trendSeries = _ref.trendSeries,
15724
15785
  colors = _ref.colors,
15786
+ categoriesProp = _ref.categories,
15725
15787
  _ref$yAxisMax = _ref.yAxisMax,
15726
15788
  yAxisMax = _ref$yAxisMax === void 0 ? 60 : _ref$yAxisMax,
15727
15789
  _ref$yAxisTickAmount = _ref.yAxisTickAmount,
@@ -15730,6 +15792,47 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15730
15792
  yAxisFormatter = _ref$yAxisFormatter === void 0 ? function (val) {
15731
15793
  return "".concat(val, "%");
15732
15794
  } : _ref$yAxisFormatter;
15795
+ var categories = React.useMemo(function () {
15796
+ var _trendSeries$;
15797
+ if (Array.isArray(trendSeries) && ((_trendSeries$ = trendSeries[0]) === null || _trendSeries$ === void 0 || (_trendSeries$ = _trendSeries$.data) === null || _trendSeries$ === void 0 ? void 0 : _trendSeries$.length) > 0) {
15798
+ return trendSeries[0].data.map(function (item) {
15799
+ return item.date;
15800
+ });
15801
+ }
15802
+ if (Array.isArray(trendData) && trendData.length > 0) {
15803
+ return trendData.map(function (item) {
15804
+ return item.date;
15805
+ });
15806
+ }
15807
+ return categoriesProp !== null && categoriesProp !== void 0 ? categoriesProp : [];
15808
+ }, [trendData, trendSeries, categoriesProp]);
15809
+ var chartSeries = React.useMemo(function () {
15810
+ if (Array.isArray(trendSeries) && trendSeries.length > 0) {
15811
+ return trendSeries.map(function (item) {
15812
+ var _item$data;
15813
+ return {
15814
+ name: item.name,
15815
+ data: ((_item$data = item.data) !== null && _item$data !== void 0 ? _item$data : []).map(function (point) {
15816
+ var _point$value;
15817
+ return (_point$value = point.value) !== null && _point$value !== void 0 ? _point$value : 0;
15818
+ }),
15819
+ dashed: item.dashed
15820
+ };
15821
+ });
15822
+ }
15823
+ if (Array.isArray(trendData) && trendData.length > 0) {
15824
+ var _series$0$name, _series$, _series$2;
15825
+ return [{
15826
+ name: (_series$0$name = (_series$ = series[0]) === null || _series$ === void 0 ? void 0 : _series$.name) !== null && _series$0$name !== void 0 ? _series$0$name : "Value",
15827
+ data: trendData.map(function (item) {
15828
+ var _item$value;
15829
+ return (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : 0;
15830
+ }),
15831
+ dashed: (_series$2 = series[0]) === null || _series$2 === void 0 ? void 0 : _series$2.dashed
15832
+ }];
15833
+ }
15834
+ return series;
15835
+ }, [trendData, trendSeries, series]);
15733
15836
  var chartOptions = {
15734
15837
  chart: {
15735
15838
  type: "area",
@@ -15744,7 +15847,7 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15744
15847
  stroke: {
15745
15848
  curve: "smooth",
15746
15849
  width: 2,
15747
- dashArray: series.map(function (s) {
15850
+ dashArray: chartSeries.map(function (s) {
15748
15851
  return s.dashed ? 5 : 0;
15749
15852
  })
15750
15853
  },
@@ -15759,14 +15862,18 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15759
15862
  },
15760
15863
  colors: colors,
15761
15864
  xaxis: {
15762
- categories: ["Apr 5", "Apr 12", "Apr 19", "Apr 26", "May 4"],
15865
+ categories: categories,
15866
+ tickAmount: 5,
15763
15867
  labels: {
15764
15868
  show: true,
15869
+ rotate: 0,
15870
+ hideOverlappingLabels: true,
15765
15871
  style: {
15766
- colors: 'rgba(0, 0, 0, 0.3)',
15767
- fontSize: '10px'
15872
+ colors: "rgba(0, 0, 0, 0.3)",
15873
+ fontSize: "10px"
15768
15874
  },
15769
- offsetY: -5
15875
+ offsetY: -5,
15876
+ formatter: formatCategoryLabel
15770
15877
  },
15771
15878
  axisBorder: {
15772
15879
  show: false
@@ -15774,7 +15881,7 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15774
15881
  axisTicks: {
15775
15882
  show: false
15776
15883
  },
15777
- position: 'bottom'
15884
+ position: "bottom"
15778
15885
  },
15779
15886
  yaxis: {
15780
15887
  max: yAxisMax,
@@ -15782,8 +15889,8 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15782
15889
  labels: {
15783
15890
  show: true,
15784
15891
  style: {
15785
- colors: 'rgba(0, 0, 0, 0.3)',
15786
- fontSize: '10px'
15892
+ colors: "rgba(0, 0, 0, 0.3)",
15893
+ fontSize: "10px"
15787
15894
  },
15788
15895
  formatter: yAxisFormatter
15789
15896
  }
@@ -15812,11 +15919,11 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15812
15919
  enabled: false
15813
15920
  },
15814
15921
  legend: {
15815
- show: series.length > 1,
15816
- position: 'bottom',
15817
- horizontalAlign: 'left',
15818
- fontSize: '11px',
15819
- fontFamily: 'Inter, sans-serif',
15922
+ show: chartSeries.length > 1,
15923
+ position: "bottom",
15924
+ horizontalAlign: "left",
15925
+ fontSize: "11px",
15926
+ fontFamily: "Inter, sans-serif",
15820
15927
  offsetY: -5,
15821
15928
  markers: {
15822
15929
  width: 8,
@@ -15829,7 +15936,13 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15829
15936
  }
15830
15937
  },
15831
15938
  tooltip: {
15832
- theme: 'light'
15939
+ theme: "light",
15940
+ x: {
15941
+ formatter: function formatter(_, _ref2) {
15942
+ var dataPointIndex = _ref2.dataPointIndex;
15943
+ return formatCategoryLabel(categories[dataPointIndex]);
15944
+ }
15945
+ }
15833
15946
  }
15834
15947
  };
15835
15948
  return /*#__PURE__*/jsxRuntime.jsxs(material.Card, {
@@ -15846,7 +15959,7 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15846
15959
  children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
15847
15960
  sx: {
15848
15961
  mb: 1,
15849
- textAlign: 'left'
15962
+ textAlign: "left"
15850
15963
  },
15851
15964
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
15852
15965
  sx: {
@@ -15892,7 +16005,7 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15892
16005
  },
15893
16006
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
15894
16007
  style: {
15895
- fontSize: '10px'
16008
+ fontSize: "10px"
15896
16009
  },
15897
16010
  children: "\u25B2"
15898
16011
  }), " ", trend]
@@ -15906,7 +16019,7 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15906
16019
  },
15907
16020
  children: /*#__PURE__*/jsxRuntime.jsx(ReactApexChart, {
15908
16021
  options: chartOptions,
15909
- series: series,
16022
+ series: chartSeries,
15910
16023
  type: "area",
15911
16024
  height: "100%"
15912
16025
  })
@@ -15914,109 +16027,282 @@ var EmailTrendCard = function EmailTrendCard(_ref) {
15914
16027
  });
15915
16028
  };
15916
16029
 
15917
- var EmailSection = function EmailSection() {
16030
+ var formatGrowth = function formatGrowth(value, dateName) {
16031
+ return "".concat(Number(value !== null && value !== void 0 ? value : 0).toFixed(2), "% vs ").concat(dateName || "previous period");
16032
+ };
16033
+ var mapTimeSeries = function mapTimeSeries(series) {
16034
+ if (!Array.isArray(series) || series.length === 0) {
16035
+ return {
16036
+ categories: [],
16037
+ data: []
16038
+ };
16039
+ }
16040
+ return {
16041
+ categories: series.map(function (item) {
16042
+ return item.date;
16043
+ }),
16044
+ data: series.map(function (item) {
16045
+ var _item$value;
16046
+ return (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : 0;
16047
+ })
16048
+ };
16049
+ };
16050
+ var getCampaignInitials = function getCampaignInitials() {
16051
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
16052
+ var words = name.trim().split(/\s+/).filter(Boolean);
16053
+ if (words.length >= 2) {
16054
+ return (words[0][0] + words[1][0]).toUpperCase();
16055
+ }
16056
+ return name.slice(0, 2).toUpperCase() || "—";
16057
+ };
16058
+ var computeYAxisMax = function computeYAxisMax(values) {
16059
+ var defaultMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
16060
+ var max = Math.max.apply(Math, _toConsumableArray(values.length ? values : [0]).concat([0]));
16061
+ return max === 0 ? defaultMax : Math.ceil(max * 1.2);
16062
+ };
16063
+ var formatTrendBadge = function formatTrendBadge(value) {
16064
+ var isPercentage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
16065
+ var num = Number(value !== null && value !== void 0 ? value : 0);
16066
+ if (isPercentage) {
16067
+ return "".concat(num >= 0 ? "+" : "").concat(num.toFixed(1), "pp");
16068
+ }
16069
+ return "".concat(num >= 0 ? "+" : "").concat(num.toFixed(1), "%");
16070
+ };
16071
+ var EmailSection = function EmailSection(_ref) {
16072
+ var _deliverability$openR2, _deliverability$total2, _deliverability$bounc2;
16073
+ var _ref$apiData = _ref.apiData,
16074
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
16075
+ _ref$dateName = _ref.dateName,
16076
+ dateName = _ref$dateName === void 0 ? "Last Period" : _ref$dateName;
15918
16077
  var _useState = React.useState("Total raised"),
15919
16078
  _useState2 = _slicedToArray(_useState, 2),
15920
16079
  activeMetric = _useState2[0],
15921
16080
  setActiveMetric = _useState2[1];
15922
- var metricInfo = {
15923
- "Total raised": {
15924
- value: "$".concat(formatNumber(48920)),
15925
- subValue: "12% vs last month",
15926
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
15927
- data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
15928
- money: true,
15929
- error: false,
15930
- warning: false
15931
- },
15932
- Donations: {
15933
- value: "62",
15934
- subValue: "12% vs last month",
15935
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
15936
- data: [4, 8, 5, 12, 10, 11, 12],
15937
- money: false,
15938
- error: false,
15939
- warning: false
15940
- },
15941
- "Conversion rate": {
15942
- value: "3.2%",
15943
- subValue: "12% vs last month",
15944
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
15945
- data: [2.8, 3.1, 2.9, 3.4, 3.2, 3.1, 3.2],
15946
- money: false,
15947
- error: false,
15948
- warning: false
15949
- },
15950
- CTR: {
15951
- value: "8.1%",
15952
- subValue: "12% vs last month",
15953
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NotInterested, {}),
15954
- data: [7.2, 8.4, 7.8, 8.9, 8.1, 8.0, 8.1],
15955
- money: false,
15956
- error: false,
15957
- warning: false
15958
- },
15959
- "Revenue per email": {
15960
- value: "$".concat(formatNumber(2.45)),
15961
- subValue: "12% vs last month",
15962
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.IndeterminateCheckBoxOutlined, {}),
15963
- data: [2.1, 2.5, 2.3, 2.8, 2.4, 2.4, 2.45],
15964
- money: true,
15965
- error: false,
15966
- warning: false
15967
- },
15968
- "Open rate": {
15969
- value: "42.3%",
15970
- subValue: "12% vs last month",
15971
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Email, {}),
15972
- data: [38, 44, 40, 46, 42, 41, 42.3],
15973
- money: false,
15974
- error: false,
15975
- warning: false
15976
- },
15977
- Clicks: {
15978
- value: "1,612",
15979
- subValue: "12% vs last month",
15980
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NearMe, {}),
15981
- data: [210, 240, 220, 280, 250, 245, 245],
15982
- money: false,
15983
- error: false,
15984
- warning: false
15985
- },
15986
- "Unique Clicks": {
15987
- value: "".concat(formatNumber(1148)),
15988
- subValue: "12% vs last month",
15989
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NearMe, {}),
15990
- data: [150, 180, 160, 210, 190, 185, 185],
15991
- money: false,
15992
- error: false,
15993
- warning: false
15994
- },
15995
- "Bounce rate": {
15996
- value: "1.8%",
15997
- subValue: "12% vs last month",
15998
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.HighlightOff, {}),
15999
- data: [2.1, 1.9, 1.8, 1.7, 1.8, 1.8, 1.8],
16000
- money: false,
16001
- error: false,
16002
- warning: false
16003
- },
16004
- "Revenue per Click": {
16005
- value: "$".concat(formatNumber(30.35)),
16006
- subValue: "12% vs last month",
16007
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.HighlightOff, {}),
16008
- data: [28, 32, 29, 34, 30, 30, 30.35],
16009
- money: true,
16010
- error: false,
16011
- warning: false
16012
- }
16081
+ var overview = (apiData === null || apiData === void 0 ? void 0 : apiData.overview) || {};
16082
+ var overviewGrowth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
16083
+ var deliverability = (apiData === null || apiData === void 0 ? void 0 : apiData.deliverability) || {};
16084
+ var deliverabilityGrowth = (deliverability === null || deliverability === void 0 ? void 0 : deliverability.growthPercentage) || {};
16085
+ var hasEmailOverview = Boolean(apiData === null || apiData === void 0 ? void 0 : apiData.overview);
16086
+ var openRateTrend = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.openRateTrend);
16087
+ var totalClicksTrend = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.totalClicksTrend);
16088
+ var uniqueClicksTrend = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.uniqueClicksTrend);
16089
+ var bounceRateTrend = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.bounceRateTrend);
16090
+ var growthCaption = function growthCaption(key) {
16091
+ var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : overviewGrowth;
16092
+ return formatGrowth(source[key], dateName);
16013
16093
  };
16094
+ var metricInfo = React.useMemo(function () {
16095
+ var _overview$totalRevenu, _overview$totalDonati, _overview$conversionR, _overview$ctr, _overview$revenuePerE, _deliverability$openR, _deliverability$total, _deliverability$uniqu, _deliverability$bounc, _deliverability$reven;
16096
+ if (!hasEmailOverview) {
16097
+ return {
16098
+ "Total raised": {
16099
+ value: "$".concat(formatNumber(48920)),
16100
+ subValue: "12% vs last month",
16101
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
16102
+ money: true,
16103
+ error: false,
16104
+ warning: false
16105
+ },
16106
+ Donations: {
16107
+ value: "62",
16108
+ subValue: "12% vs last month",
16109
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
16110
+ money: false,
16111
+ error: false,
16112
+ warning: false
16113
+ },
16114
+ "Conversion rate": {
16115
+ value: "3.2%",
16116
+ subValue: "12% vs last month",
16117
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
16118
+ money: false,
16119
+ error: false,
16120
+ warning: false
16121
+ },
16122
+ CTR: {
16123
+ value: "8.1%",
16124
+ subValue: "12% vs last month",
16125
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NotInterested, {}),
16126
+ money: false,
16127
+ error: false,
16128
+ warning: false
16129
+ },
16130
+ "Revenue per email": {
16131
+ value: "$".concat(formatNumber(2.45)),
16132
+ subValue: "12% vs last month",
16133
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.IndeterminateCheckBoxOutlined, {}),
16134
+ money: true,
16135
+ error: false,
16136
+ warning: false
16137
+ },
16138
+ "Open rate": {
16139
+ value: "42.3%",
16140
+ subValue: "12% vs last month",
16141
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Email, {}),
16142
+ money: false,
16143
+ error: false,
16144
+ warning: false
16145
+ },
16146
+ Clicks: {
16147
+ value: "1,612",
16148
+ subValue: "12% vs last month",
16149
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NearMe, {}),
16150
+ money: false,
16151
+ error: false,
16152
+ warning: false
16153
+ },
16154
+ "Unique Clicks": {
16155
+ value: formatNumber(1148),
16156
+ subValue: "12% vs last month",
16157
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NearMe, {}),
16158
+ money: false,
16159
+ error: false,
16160
+ warning: false
16161
+ },
16162
+ "Bounce rate": {
16163
+ value: "1.8%",
16164
+ subValue: "12% vs last month",
16165
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.HighlightOff, {}),
16166
+ money: false,
16167
+ error: false,
16168
+ warning: false
16169
+ },
16170
+ "Revenue per Click": {
16171
+ value: "$".concat(formatNumber(30.35)),
16172
+ subValue: "12% vs last month",
16173
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.HighlightOff, {}),
16174
+ money: true,
16175
+ error: false,
16176
+ warning: false
16177
+ }
16178
+ };
16179
+ }
16180
+ return {
16181
+ "Total raised": {
16182
+ value: "$".concat(formatNumber((_overview$totalRevenu = overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 0)),
16183
+ subValue: growthCaption("totalRevenue"),
16184
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
16185
+ money: true,
16186
+ error: false,
16187
+ warning: false
16188
+ },
16189
+ Donations: {
16190
+ value: formatNumber((_overview$totalDonati = overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 0),
16191
+ subValue: growthCaption("totalDonations"),
16192
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
16193
+ money: false,
16194
+ error: false,
16195
+ warning: false
16196
+ },
16197
+ "Conversion rate": {
16198
+ value: "".concat(Number((_overview$conversionR = overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 0).toFixed(2), "%"),
16199
+ subValue: growthCaption("conversionRate"),
16200
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
16201
+ money: false,
16202
+ error: false,
16203
+ warning: false
16204
+ },
16205
+ CTR: {
16206
+ value: "".concat(Number((_overview$ctr = overview.ctr) !== null && _overview$ctr !== void 0 ? _overview$ctr : 0).toFixed(2), "%"),
16207
+ subValue: growthCaption("ctr"),
16208
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NotInterested, {}),
16209
+ money: false,
16210
+ error: false,
16211
+ warning: false
16212
+ },
16213
+ "Revenue per email": {
16214
+ value: "$".concat(formatNumber((_overview$revenuePerE = overview.revenuePerEmail) !== null && _overview$revenuePerE !== void 0 ? _overview$revenuePerE : 0)),
16215
+ subValue: growthCaption("revenuePerEmail"),
16216
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.IndeterminateCheckBoxOutlined, {}),
16217
+ money: true,
16218
+ error: false,
16219
+ warning: false
16220
+ },
16221
+ "Open rate": {
16222
+ value: "".concat(Number((_deliverability$openR = deliverability.openRate) !== null && _deliverability$openR !== void 0 ? _deliverability$openR : 0).toFixed(2), "%"),
16223
+ subValue: growthCaption("openRate", deliverabilityGrowth),
16224
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Email, {}),
16225
+ money: false,
16226
+ error: false,
16227
+ warning: false
16228
+ },
16229
+ Clicks: {
16230
+ value: formatNumber((_deliverability$total = deliverability.totalClicks) !== null && _deliverability$total !== void 0 ? _deliverability$total : 0),
16231
+ subValue: growthCaption("totalClicks", deliverabilityGrowth),
16232
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NearMe, {}),
16233
+ money: false,
16234
+ error: false,
16235
+ warning: false
16236
+ },
16237
+ "Unique Clicks": {
16238
+ value: formatNumber((_deliverability$uniqu = deliverability.uniqueClicks) !== null && _deliverability$uniqu !== void 0 ? _deliverability$uniqu : 0),
16239
+ subValue: growthCaption("uniqueClicks", deliverabilityGrowth),
16240
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.NearMe, {}),
16241
+ money: false,
16242
+ error: false,
16243
+ warning: false
16244
+ },
16245
+ "Bounce rate": {
16246
+ value: "".concat(Number((_deliverability$bounc = deliverability.bounceRate) !== null && _deliverability$bounc !== void 0 ? _deliverability$bounc : 0).toFixed(2), "%"),
16247
+ subValue: growthCaption("bounceRate", deliverabilityGrowth),
16248
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.HighlightOff, {}),
16249
+ money: false,
16250
+ error: false,
16251
+ warning: false
16252
+ },
16253
+ "Revenue per Click": {
16254
+ value: "$".concat(formatNumber((_deliverability$reven = deliverability.revenuePerClick) !== null && _deliverability$reven !== void 0 ? _deliverability$reven : 0)),
16255
+ subValue: growthCaption("revenuePerClick", deliverabilityGrowth),
16256
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.HighlightOff, {}),
16257
+ money: true,
16258
+ error: false,
16259
+ warning: false
16260
+ }
16261
+ };
16262
+ }, [deliverability, deliverabilityGrowth, hasEmailOverview, overview, overviewGrowth, dateName]);
16263
+ var campaignsRaisedData = React.useMemo(function () {
16264
+ var campaigns = apiData === null || apiData === void 0 ? void 0 : apiData.topCampaignsByRaised;
16265
+ if (!hasEmailOverview) return null;
16266
+ if (!Array.isArray(campaigns) || campaigns.length === 0) return [];
16267
+ return campaigns.map(function (item) {
16268
+ var _item$value2;
16269
+ return {
16270
+ id: getCampaignInitials(item.campaignName),
16271
+ name: item.campaignName || "Unknown",
16272
+ value: "$".concat(formatNumber((_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : 0))
16273
+ };
16274
+ });
16275
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topCampaignsByRaised, hasEmailOverview]);
16276
+ var campaignsCtrData = React.useMemo(function () {
16277
+ var campaigns = apiData === null || apiData === void 0 ? void 0 : apiData.topCampaignsByCtr;
16278
+ if (!hasEmailOverview) return null;
16279
+ if (!Array.isArray(campaigns) || campaigns.length === 0) return [];
16280
+ return campaigns.map(function (item) {
16281
+ var _item$value3;
16282
+ return {
16283
+ id: getCampaignInitials(item.campaignName),
16284
+ name: item.campaignName || "Unknown",
16285
+ value: "".concat(Number((_item$value3 = item.value) !== null && _item$value3 !== void 0 ? _item$value3 : 0).toFixed(2), "%")
16286
+ };
16287
+ });
16288
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topCampaignsByCtr, hasEmailOverview]);
16289
+ var campaignsConversionData = React.useMemo(function () {
16290
+ var campaigns = apiData === null || apiData === void 0 ? void 0 : apiData.topCampaignsByConversion;
16291
+ if (!hasEmailOverview) return null;
16292
+ if (!Array.isArray(campaigns) || campaigns.length === 0) return [];
16293
+ return campaigns.map(function (item) {
16294
+ var _item$value4;
16295
+ return {
16296
+ id: getCampaignInitials(item.campaignName),
16297
+ name: item.campaignName || "Unknown",
16298
+ value: "".concat(Number((_item$value4 = item.value) !== null && _item$value4 !== void 0 ? _item$value4 : 0).toFixed(2), "%")
16299
+ };
16300
+ });
16301
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topCampaignsByConversion, hasEmailOverview]);
16014
16302
  var renderCard = function renderCard(title) {
16015
- return /*#__PURE__*/jsxRuntime.jsx(MetricCard
16016
- // key={title}
16017
- , {
16303
+ return /*#__PURE__*/jsxRuntime.jsx(MetricCard, {
16018
16304
  title: title,
16019
- value: metricInfo[title].money ? metricInfo[title].value : metricInfo[title].value,
16305
+ value: metricInfo[title].value,
16020
16306
  caption: metricInfo[title].subValue,
16021
16307
  icon: metricInfo[title].icon,
16022
16308
  error: metricInfo[title].error,
@@ -16028,19 +16314,7 @@ var EmailSection = function EmailSection() {
16028
16314
  border: "2px solid #ef4444",
16029
16315
  bgcolor: "#fffafa"
16030
16316
  } : {}
16031
- })
16032
- // <DisplayCard
16033
- // key={title}
16034
- // title={title}
16035
- // value={metricInfo[title].value}
16036
- // subValue={metricInfo[title].subValue}
16037
- // icon={metricInfo[title].icon}
16038
- // // onClick={() => setActiveMetric(title)}
16039
- // // isActive={activeMetric === title}
16040
- // sx={{
16041
- // }}
16042
- // />
16043
- ;
16317
+ });
16044
16318
  };
16045
16319
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
16046
16320
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
@@ -16072,14 +16346,16 @@ var EmailSection = function EmailSection() {
16072
16346
  children: /*#__PURE__*/jsxRuntime.jsx(EmailTrendCard, {
16073
16347
  title: "Open rate trend",
16074
16348
  subtitle: "Daily \xB7 30 days",
16075
- value: "42.3%",
16076
- trend: "2.1pp",
16349
+ value: hasEmailOverview ? "".concat(Number((_deliverability$openR2 = deliverability.openRate) !== null && _deliverability$openR2 !== void 0 ? _deliverability$openR2 : 0).toFixed(2), "%") : "42.3%",
16350
+ trend: hasEmailOverview ? formatTrendBadge(deliverabilityGrowth.openRate, true) : "2.1pp",
16351
+ trendData: hasEmailOverview ? apiData === null || apiData === void 0 ? void 0 : apiData.openRateTrend : undefined,
16077
16352
  series: [{
16078
- name: 'Open Rate',
16353
+ name: "Open Rate",
16079
16354
  data: [38, 42, 41, 43, 42.3]
16080
16355
  }],
16081
- colors: ['rgb(99, 99, 230)'],
16082
- yAxisMax: 53,
16356
+ categories: ["Apr 5", "Apr 12", "Apr 19", "Apr 26", "May 4"],
16357
+ colors: ["rgb(99, 99, 230)"],
16358
+ yAxisMax: computeYAxisMax(openRateTrend.data, 5),
16083
16359
  yAxisTickAmount: 3
16084
16360
  })
16085
16361
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
@@ -16097,18 +16373,27 @@ var EmailSection = function EmailSection() {
16097
16373
  children: /*#__PURE__*/jsxRuntime.jsx(EmailTrendCard, {
16098
16374
  title: "Clicks trend",
16099
16375
  subtitle: "Total + unique \xB7 30 days",
16100
- value: "1,612",
16101
- trend: "14%",
16376
+ value: hasEmailOverview ? formatNumber((_deliverability$total2 = deliverability.totalClicks) !== null && _deliverability$total2 !== void 0 ? _deliverability$total2 : 0) : "1,612",
16377
+ trend: hasEmailOverview ? formatTrendBadge(deliverabilityGrowth.totalClicks) : "14%",
16378
+ trendSeries: hasEmailOverview ? [{
16379
+ name: "Total clicks",
16380
+ data: apiData === null || apiData === void 0 ? void 0 : apiData.totalClicksTrend
16381
+ }, {
16382
+ name: "Unique clicks",
16383
+ data: apiData === null || apiData === void 0 ? void 0 : apiData.uniqueClicksTrend,
16384
+ dashed: true
16385
+ }] : undefined,
16102
16386
  series: [{
16103
- name: 'Total clicks',
16387
+ name: "Total clicks",
16104
16388
  data: [56, 112, 80, 150, 112]
16105
16389
  }, {
16106
- name: 'Unique clicks',
16390
+ name: "Unique clicks",
16107
16391
  data: [30, 70, 45, 100, 75],
16108
16392
  dashed: true
16109
16393
  }],
16110
- colors: ['#10B981', '#10B981'],
16111
- yAxisMax: 168,
16394
+ categories: ["Apr 5", "Apr 12", "Apr 19", "Apr 26", "May 4"],
16395
+ colors: ["#10B981", "#10B981"],
16396
+ yAxisMax: computeYAxisMax([].concat(_toConsumableArray(totalClicksTrend.data), _toConsumableArray(uniqueClicksTrend.data)), 10),
16112
16397
  yAxisTickAmount: 3,
16113
16398
  yAxisFormatter: function yAxisFormatter(val) {
16114
16399
  return val;
@@ -16129,14 +16414,16 @@ var EmailSection = function EmailSection() {
16129
16414
  children: /*#__PURE__*/jsxRuntime.jsx(EmailTrendCard, {
16130
16415
  title: "Bounce rate trend",
16131
16416
  subtitle: "Daily \xB7 lower is better",
16132
- value: "1.8%",
16133
- trend: "0.3pp",
16417
+ value: hasEmailOverview ? "".concat(Number((_deliverability$bounc2 = deliverability.bounceRate) !== null && _deliverability$bounc2 !== void 0 ? _deliverability$bounc2 : 0).toFixed(2), "%") : "1.8%",
16418
+ trend: hasEmailOverview ? formatTrendBadge(deliverabilityGrowth.bounceRate, true) : "0.3pp",
16419
+ trendData: hasEmailOverview ? apiData === null || apiData === void 0 ? void 0 : apiData.bounceRateTrend : undefined,
16134
16420
  series: [{
16135
- name: 'Bounce Rate',
16421
+ name: "Bounce Rate",
16136
16422
  data: [2.2, 1.9, 2.0, 1.7, 1.8]
16137
16423
  }],
16138
- colors: ['#f2994a'],
16139
- yAxisMax: 2.5,
16424
+ categories: ["Apr 5", "Apr 12", "Apr 19", "Apr 26", "May 4"],
16425
+ colors: ["#f2994a"],
16426
+ yAxisMax: computeYAxisMax(bounceRateTrend.data, 2.5),
16140
16427
  yAxisTickAmount: 3
16141
16428
  })
16142
16429
  })]
@@ -16153,7 +16440,9 @@ var EmailSection = function EmailSection() {
16153
16440
  sx: {
16154
16441
  paddingTop: "0px !important"
16155
16442
  },
16156
- children: /*#__PURE__*/jsxRuntime.jsx(TopCampaignsRaisedCard, {})
16443
+ children: /*#__PURE__*/jsxRuntime.jsx(TopCampaignsRaisedCard, {
16444
+ data: campaignsRaisedData
16445
+ })
16157
16446
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
16158
16447
  item: true,
16159
16448
  xs: 12,
@@ -16166,7 +16455,9 @@ var EmailSection = function EmailSection() {
16166
16455
  md: "0px"
16167
16456
  }
16168
16457
  },
16169
- children: /*#__PURE__*/jsxRuntime.jsx(TopCampaignsCTRCard, {})
16458
+ children: /*#__PURE__*/jsxRuntime.jsx(TopCampaignsCTRCard, {
16459
+ data: campaignsCtrData
16460
+ })
16170
16461
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
16171
16462
  item: true,
16172
16463
  xs: 12,
@@ -16179,7 +16470,9 @@ var EmailSection = function EmailSection() {
16179
16470
  md: "0px"
16180
16471
  }
16181
16472
  },
16182
- children: /*#__PURE__*/jsxRuntime.jsx(TopCampaignsConvRateCard, {})
16473
+ children: /*#__PURE__*/jsxRuntime.jsx(TopCampaignsConvRateCard, {
16474
+ data: campaignsConversionData
16475
+ })
16183
16476
  })]
16184
16477
  })]
16185
16478
  });