@ammarkhalidfarooq/dashboard-package 0.5.20 → 0.5.21

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
@@ -2692,7 +2692,8 @@ var NewOverview = function NewOverview(_ref) {
2692
2692
  }), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
2693
2693
  sx: {},
2694
2694
  children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection$2, {
2695
- apiData: apiData
2695
+ apiData: apiData,
2696
+ dateName: dateName
2696
2697
  })
2697
2698
  }), activeSection === "Email" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
2698
2699
  sx: {},
@@ -5696,8 +5697,10 @@ var CardWrapper = function CardWrapper(_ref) {
5696
5697
  })
5697
5698
  });
5698
5699
  };
5699
- var LandingPagesCard = function LandingPagesCard() {
5700
- var data = [{
5700
+ var SOURCE_COLORS = ["#4285F4", "#10B981", "#6366F1", "#F59E0B", "#94A3B8", "#EC4899", "#4267B2", "#06510b"];
5701
+ var LandingPagesCard = function LandingPagesCard(_ref2) {
5702
+ var dataProp = _ref2.data;
5703
+ var data = dataProp !== null && dataProp !== void 0 ? dataProp : [{
5701
5704
  page: "/yemen-orphans-appeal",
5702
5705
  visitors: "1,840",
5703
5706
  donations: "32",
@@ -5787,7 +5790,15 @@ var LandingPagesCard = function LandingPagesCard() {
5787
5790
  },
5788
5791
  children: "Conv. rate"
5789
5792
  })]
5790
- }), data.map(function (item, index) {
5793
+ }), data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5794
+ sx: {
5795
+ fontSize: "13px",
5796
+ color: "rgba(0, 0, 0, 0.45)",
5797
+ py: 2,
5798
+ textAlign: "left"
5799
+ },
5800
+ children: "No landing page data for this period."
5801
+ }) : data.map(function (item, index) {
5791
5802
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5792
5803
  sx: {
5793
5804
  display: "grid",
@@ -5802,8 +5813,12 @@ var LandingPagesCard = function LandingPagesCard() {
5802
5813
  fontSize: "13px",
5803
5814
  fontWeight: 700,
5804
5815
  color: "#000",
5805
- textAlign: "left"
5816
+ textAlign: "left",
5817
+ overflow: "hidden",
5818
+ textOverflow: "ellipsis",
5819
+ whiteSpace: "nowrap"
5806
5820
  },
5821
+ title: item.page,
5807
5822
  children: item.page
5808
5823
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5809
5824
  sx: {
@@ -5842,8 +5857,11 @@ var LandingPagesCard = function LandingPagesCard() {
5842
5857
  })]
5843
5858
  });
5844
5859
  };
5845
- var KeywordsCard = function KeywordsCard() {
5846
- var data = [{
5860
+ var KeywordsCard = function KeywordsCard(_ref3) {
5861
+ var dataProp = _ref3.data,
5862
+ _ref3$available = _ref3.available,
5863
+ available = _ref3$available === void 0 ? true : _ref3$available;
5864
+ var data = dataProp !== null && dataProp !== void 0 ? dataProp : [{
5847
5865
  keyword: "zakat calculator",
5848
5866
  clicks: "1,240",
5849
5867
  rank: "#2.1",
@@ -5874,142 +5892,153 @@ var KeywordsCard = function KeywordsCard() {
5874
5892
  trend: "Improving",
5875
5893
  trendType: "up"
5876
5894
  }];
5877
- return /*#__PURE__*/jsxRuntime.jsxs(CardWrapper, {
5895
+ return /*#__PURE__*/jsxRuntime.jsx(CardWrapper, {
5878
5896
  title: "Top organic keywords",
5879
5897
  subtitle: "Search terms ranked by clicks \xB7 last 30 days",
5880
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5898
+ children: !available || data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5881
5899
  sx: {
5882
- display: "grid",
5883
- gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5884
- gap: 2,
5885
- pb: 1,
5886
- borderBottom: "1px solid #f0f0f0"
5900
+ fontSize: "13px",
5901
+ color: "rgba(0, 0, 0, 0.45)",
5902
+ py: 2,
5903
+ textAlign: "left"
5887
5904
  },
5888
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5889
- sx: {
5890
- fontSize: "12px",
5891
- color: "rgba(0, 0, 0, 0.4)",
5892
- fontWeight: 500,
5893
- textAlign: "left"
5894
- },
5895
- children: "Keyword"
5896
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5897
- sx: {
5898
- fontSize: "12px",
5899
- color: "rgba(0, 0, 0, 0.4)",
5900
- fontWeight: 500,
5901
- textAlign: "left"
5902
- },
5903
- children: "Clicks"
5904
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5905
- sx: {
5906
- fontSize: "12px",
5907
- color: "rgba(0, 0, 0, 0.4)",
5908
- fontWeight: 500,
5909
- textAlign: "left"
5910
- },
5911
- children: "Position"
5912
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5913
- sx: {
5914
- fontSize: "12px",
5915
- color: "rgba(0, 0, 0, 0.4)",
5916
- fontWeight: 500,
5917
- textAlign: "left"
5918
- },
5919
- children: "Trend"
5920
- })]
5921
- }), data.map(function (item, index) {
5922
- return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5905
+ children: "Keyword data is not available for this period."
5906
+ }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5907
+ children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5923
5908
  sx: {
5924
5909
  display: "grid",
5925
5910
  gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5926
5911
  gap: 2,
5927
- // py: 0.5,
5928
- alignItems: "center",
5929
- borderBottom: index === data.length - 1 ? "none" : "1px solid #f5f5f5"
5912
+ pb: 1,
5913
+ borderBottom: "1px solid #f0f0f0"
5930
5914
  },
5931
5915
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5932
5916
  sx: {
5933
- fontSize: "13px",
5934
- fontWeight: 700,
5935
- color: "#000",
5917
+ fontSize: "12px",
5918
+ color: "rgba(0, 0, 0, 0.4)",
5919
+ fontWeight: 500,
5936
5920
  textAlign: "left"
5937
5921
  },
5938
- children: item.keyword
5922
+ children: "Keyword"
5939
5923
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5940
5924
  sx: {
5941
- fontSize: "13px",
5942
- color: "rgba(0, 0, 0, 0.6)",
5925
+ fontSize: "12px",
5926
+ color: "rgba(0, 0, 0, 0.4)",
5943
5927
  fontWeight: 500,
5944
5928
  textAlign: "left"
5945
5929
  },
5946
- children: item.clicks
5947
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5930
+ children: "Clicks"
5931
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5932
+ sx: {
5933
+ fontSize: "12px",
5934
+ color: "rgba(0, 0, 0, 0.4)",
5935
+ fontWeight: 500,
5936
+ textAlign: "left"
5937
+ },
5938
+ children: "Position"
5939
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5948
5940
  sx: {
5941
+ fontSize: "12px",
5942
+ color: "rgba(0, 0, 0, 0.4)",
5943
+ fontWeight: 500,
5949
5944
  textAlign: "left"
5950
5945
  },
5951
- children: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5952
- sx: {
5953
- width: "40px",
5954
- bgcolor: "#ebf2ffb1",
5955
- color: "#3431e4",
5956
- // px: 0.5,
5957
- p: 0.5,
5958
- borderRadius: "100px",
5959
- fontSize: "11px",
5960
- fontWeight: 700,
5961
- textAlign: "center",
5962
- minWidth: "45px"
5963
- },
5964
- children: item.rank
5965
- })
5966
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5946
+ children: "Trend"
5947
+ })]
5948
+ }), data.map(function (item, index) {
5949
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5967
5950
  sx: {
5968
- display: "flex",
5951
+ display: "grid",
5952
+ gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5953
+ gap: 2,
5954
+ // py: 0.5,
5969
5955
  alignItems: "center",
5970
- justifyContent: "flex-start",
5971
- gap: 0.5
5956
+ borderBottom: index === data.length - 1 ? "none" : "1px solid #f5f5f5"
5972
5957
  },
5973
- children: item.trendType === "up" ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5974
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5975
- sx: {
5976
- fontSize: "14px",
5977
- color: "#22C55E"
5978
- },
5979
- children: "\u25B2"
5980
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5981
- sx: {
5982
- fontSize: "12px",
5983
- color: "#22C55E",
5984
- fontWeight: 700
5985
- },
5986
- children: "Improving"
5987
- })]
5988
- }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5989
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5990
- sx: {
5991
- fontSize: "14px",
5992
- color: "#EF4444"
5993
- },
5994
- children: "\u25BC"
5995
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5958
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5959
+ sx: {
5960
+ fontSize: "13px",
5961
+ fontWeight: 700,
5962
+ color: "#000",
5963
+ textAlign: "left"
5964
+ },
5965
+ children: item.keyword
5966
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5967
+ sx: {
5968
+ fontSize: "13px",
5969
+ color: "rgba(0, 0, 0, 0.6)",
5970
+ fontWeight: 500,
5971
+ textAlign: "left"
5972
+ },
5973
+ children: item.clicks
5974
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5975
+ sx: {
5976
+ textAlign: "left"
5977
+ },
5978
+ children: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5996
5979
  sx: {
5997
- fontSize: "12px",
5998
- color: "#EF4444",
5999
- fontWeight: 700
5980
+ width: "40px",
5981
+ bgcolor: "#ebf2ffb1",
5982
+ color: "#3431e4",
5983
+ // px: 0.5,
5984
+ p: 0.5,
5985
+ borderRadius: "100px",
5986
+ fontSize: "11px",
5987
+ fontWeight: 700,
5988
+ textAlign: "center",
5989
+ minWidth: "45px"
6000
5990
  },
6001
- children: "Declining"
6002
- })]
6003
- })
6004
- })]
6005
- }, index);
6006
- })]
5991
+ children: item.rank
5992
+ })
5993
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5994
+ sx: {
5995
+ display: "flex",
5996
+ alignItems: "center",
5997
+ justifyContent: "flex-start",
5998
+ gap: 0.5
5999
+ },
6000
+ children: item.trendType === "up" ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6001
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6002
+ sx: {
6003
+ fontSize: "14px",
6004
+ color: "#22C55E"
6005
+ },
6006
+ children: "\u25B2"
6007
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6008
+ sx: {
6009
+ fontSize: "12px",
6010
+ color: "#22C55E",
6011
+ fontWeight: 700
6012
+ },
6013
+ children: "Improving"
6014
+ })]
6015
+ }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
6016
+ children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6017
+ sx: {
6018
+ fontSize: "14px",
6019
+ color: "#EF4444"
6020
+ },
6021
+ children: "\u25BC"
6022
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6023
+ sx: {
6024
+ fontSize: "12px",
6025
+ color: "#EF4444",
6026
+ fontWeight: 700
6027
+ },
6028
+ children: "Declining"
6029
+ })]
6030
+ })
6031
+ })]
6032
+ }, index);
6033
+ })]
6034
+ })
6007
6035
  });
6008
6036
  };
6009
- var GeographyCard = function GeographyCard(_ref2) {
6010
- var _ref2$subtitle = _ref2.subtitle,
6011
- subtitle = _ref2$subtitle === void 0 ? "Top countries by organic traffic" : _ref2$subtitle;
6012
- var data = [{
6037
+ var GeographyCard = function GeographyCard(_ref4) {
6038
+ var _ref4$subtitle = _ref4.subtitle,
6039
+ subtitle = _ref4$subtitle === void 0 ? "Top countries by organic traffic" : _ref4$subtitle,
6040
+ dataProp = _ref4.data;
6041
+ var data = dataProp !== null && dataProp !== void 0 ? dataProp : [{
6013
6042
  country: "United States",
6014
6043
  stats: "3,120 · 37%",
6015
6044
  percentage: 37
@@ -6037,7 +6066,15 @@ var GeographyCard = function GeographyCard(_ref2) {
6037
6066
  return /*#__PURE__*/jsxRuntime.jsx(CardWrapper, {
6038
6067
  title: "Geography insights",
6039
6068
  subtitle: subtitle,
6040
- children: data.map(function (item, index) {
6069
+ children: data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6070
+ sx: {
6071
+ fontSize: "13px",
6072
+ color: "rgba(0, 0, 0, 0.45)",
6073
+ py: 2,
6074
+ textAlign: "left"
6075
+ },
6076
+ children: "No geography data for this period."
6077
+ }) : data.map(function (item, index) {
6041
6078
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
6042
6079
  sx: {
6043
6080
  display: "flex",
@@ -6523,9 +6560,9 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6523
6560
  })]
6524
6561
  });
6525
6562
  };
6526
- var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref3) {
6527
- var sx = _ref3.sx,
6528
- donorGeographyData = _ref3.donorGeographyData;
6563
+ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref5) {
6564
+ var sx = _ref5.sx,
6565
+ donorGeographyData = _ref5.donorGeographyData;
6529
6566
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || [];
6530
6567
  var data = rawCountries.map(function (item) {
6531
6568
  return {
@@ -7992,74 +8029,263 @@ var PaidSection$1 = /*#__PURE__*/Object.freeze({
7992
8029
  default: PaidSection
7993
8030
  });
7994
8031
 
8032
+ var formatGrowth = function formatGrowth(value, dateName) {
8033
+ return "".concat(Number(value !== null && value !== void 0 ? value : 0).toFixed(2), "% vs ").concat(dateName || "previous period");
8034
+ };
8035
+ var mapTimeSeries = function mapTimeSeries(series) {
8036
+ if (!Array.isArray(series) || series.length === 0) {
8037
+ return {
8038
+ categories: [],
8039
+ data: []
8040
+ };
8041
+ }
8042
+ return {
8043
+ categories: series.map(function (item) {
8044
+ return item.date;
8045
+ }),
8046
+ data: series.map(function (item) {
8047
+ var _item$value;
8048
+ return (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : 0;
8049
+ })
8050
+ };
8051
+ };
7995
8052
  var OrganicSection = function OrganicSection(_ref) {
8053
+ var _apiData$topOrganicKe2, _apiData$geographyIns2, _selectedInfo$categor, _sourceBreakdown$seri, _sourceBreakdown$labe, _sourceBreakdown$colo, _sourceBreakdown$cent, _sourceBreakdown$cent2, _sourceBreakdown$item, _apiData$topOrganicKe3;
7996
8054
  var _ref$apiData = _ref.apiData,
7997
- apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
8055
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
8056
+ _ref$dateName = _ref.dateName,
8057
+ dateName = _ref$dateName === void 0 ? "Last Period" : _ref$dateName;
7998
8058
  var _useState = React.useState("Organic Users"),
7999
8059
  _useState2 = _slicedToArray(_useState, 2),
8000
8060
  activeMetric = _useState2[0],
8001
8061
  setActiveMetric = _useState2[1];
8002
- var categories = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
8003
- var metricInfo = {
8004
- "Organic Users": {
8005
- value: "".concat(formatNumber(8420)),
8006
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8007
- data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
8008
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8009
- money: false,
8010
- warning: false,
8011
- error: false
8012
- },
8013
- "Search Clicks": {
8014
- value: "".concat(formatNumber(5842)),
8015
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.netRaisedSub) || "92.3% pass-through",
8016
- data: [1500, 1800, 1600, 2200, 2000, 2400, 2800],
8017
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8018
- money: false,
8019
- warning: false,
8020
- error: false
8021
- },
8022
- Donations: {
8023
- value: "".concat(formatNumber(420)),
8024
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8025
- data: [15, 22, 18, 30, 25, 35, 42],
8026
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8027
- money: false,
8028
- warning: false,
8029
- error: false
8030
- },
8031
- "Conversion Rate": {
8032
- value: "3.1%",
8033
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.avgDonationTrend) || "8.4% vs last month",
8034
- data: [2.5, 2.7, 2.6, 3.1, 3.0, 2.9, 3.1],
8035
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8036
- money: false,
8037
- warning: false,
8038
- error: false
8039
- },
8040
- "Revenue raised": {
8041
- value: "$".concat(formatNumber(240398)),
8042
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.roasTrend) || "0.4x vs last month",
8043
- data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
8044
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8045
- money: true,
8046
- warning: false,
8047
- error: false
8048
- },
8049
- "Avg donation": {
8050
- value: "$".concat(formatNumber(130.58)),
8051
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8052
- data: [110, 125, 120, 135, 130, 128, 130.58],
8053
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8054
- money: true,
8055
- warning: false,
8056
- error: false
8057
- }
8062
+ var overview = (apiData === null || apiData === void 0 ? void 0 : apiData.overview) || {};
8063
+ var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
8064
+ var hasOrganicOverview = Boolean(apiData === null || apiData === void 0 ? void 0 : apiData.overview);
8065
+ var organicUsersSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.organicUsers);
8066
+ var donationsSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.totalDonations);
8067
+ var conversionSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.conversionRate);
8068
+ var fallbackCategories = organicUsersSeries.categories.length ? organicUsersSeries.categories : ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
8069
+ var growthCaption = function growthCaption(key) {
8070
+ return formatGrowth(growth[key], dateName);
8058
8071
  };
8072
+ var metricInfo = React.useMemo(function () {
8073
+ var _overview$totalRevenu2, _overview$overallAVGD2, _overview$organicUser, _apiData$topOrganicKe, _overview$totalDonati, _overview$conversionR, _overview$totalRevenu3, _overview$overallAVGD3;
8074
+ if (!hasOrganicOverview) {
8075
+ return {
8076
+ "Organic Users": {
8077
+ value: "".concat(formatNumber(8420)),
8078
+ subValue: "18% vs last month",
8079
+ data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
8080
+ categories: fallbackCategories,
8081
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8082
+ money: false,
8083
+ warning: false,
8084
+ error: false
8085
+ },
8086
+ "Search Clicks": {
8087
+ value: "".concat(formatNumber(5842)),
8088
+ subValue: "92.3% pass-through",
8089
+ data: [1500, 1800, 1600, 2200, 2000, 2400, 2800],
8090
+ categories: fallbackCategories,
8091
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8092
+ money: false,
8093
+ warning: false,
8094
+ error: false
8095
+ },
8096
+ Donations: {
8097
+ value: "".concat(formatNumber(420)),
8098
+ subValue: "18% vs last month",
8099
+ data: [15, 22, 18, 30, 25, 35, 42],
8100
+ categories: fallbackCategories,
8101
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8102
+ money: false,
8103
+ warning: false,
8104
+ error: false
8105
+ },
8106
+ "Conversion Rate": {
8107
+ value: "3.1%",
8108
+ subValue: "8.4% vs last month",
8109
+ data: [2.5, 2.7, 2.6, 3.1, 3.0, 2.9, 3.1],
8110
+ categories: fallbackCategories,
8111
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8112
+ money: false,
8113
+ warning: false,
8114
+ error: false
8115
+ },
8116
+ "Revenue raised": {
8117
+ value: "$".concat(formatNumber(240398)),
8118
+ subValue: "0.4x vs last month",
8119
+ data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
8120
+ categories: fallbackCategories,
8121
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8122
+ money: true,
8123
+ warning: false,
8124
+ error: false
8125
+ },
8126
+ "Avg donation": {
8127
+ value: "$".concat(formatNumber(130.58)),
8128
+ subValue: "18% vs last month",
8129
+ data: [110, 125, 120, 135, 130, 128, 130.58],
8130
+ categories: fallbackCategories,
8131
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8132
+ money: true,
8133
+ warning: false,
8134
+ error: false
8135
+ }
8136
+ };
8137
+ }
8138
+ var revenueChartData = organicUsersSeries.data.length > 0 ? organicUsersSeries.data.map(function () {
8139
+ var _overview$totalRevenu;
8140
+ return (_overview$totalRevenu = overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 0;
8141
+ }) : [(_overview$totalRevenu2 = overview.totalRevenue) !== null && _overview$totalRevenu2 !== void 0 ? _overview$totalRevenu2 : 0];
8142
+ var avgChartData = organicUsersSeries.data.length > 0 ? organicUsersSeries.data.map(function () {
8143
+ var _overview$overallAVGD;
8144
+ return (_overview$overallAVGD = overview.overallAVGDonations) !== null && _overview$overallAVGD !== void 0 ? _overview$overallAVGD : 0;
8145
+ }) : [(_overview$overallAVGD2 = overview.overallAVGDonations) !== null && _overview$overallAVGD2 !== void 0 ? _overview$overallAVGD2 : 0];
8146
+ return {
8147
+ "Organic Users": {
8148
+ value: formatNumber((_overview$organicUser = overview.organicUsers) !== null && _overview$organicUser !== void 0 ? _overview$organicUser : 0),
8149
+ subValue: growthCaption("organicUsers"),
8150
+ data: organicUsersSeries.data,
8151
+ categories: organicUsersSeries.categories,
8152
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8153
+ money: false,
8154
+ warning: false,
8155
+ error: false
8156
+ },
8157
+ "Search Clicks": {
8158
+ value: "—",
8159
+ subValue: apiData !== null && apiData !== void 0 && (_apiData$topOrganicKe = apiData.topOrganicKeywords) !== null && _apiData$topOrganicKe !== void 0 && _apiData$topOrganicKe.available ? "From organic search" : "Keyword tracking unavailable",
8160
+ data: organicUsersSeries.data.map(function () {
8161
+ return 0;
8162
+ }),
8163
+ categories: organicUsersSeries.categories,
8164
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8165
+ money: false,
8166
+ warning: false,
8167
+ error: false
8168
+ },
8169
+ Donations: {
8170
+ value: formatNumber((_overview$totalDonati = overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 0),
8171
+ subValue: growthCaption("totalDonations"),
8172
+ data: donationsSeries.data,
8173
+ categories: donationsSeries.categories,
8174
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8175
+ money: false,
8176
+ warning: false,
8177
+ error: false
8178
+ },
8179
+ "Conversion Rate": {
8180
+ value: "".concat(Number((_overview$conversionR = overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 0).toFixed(2), "%"),
8181
+ subValue: growthCaption("conversionRate"),
8182
+ data: conversionSeries.data,
8183
+ categories: conversionSeries.categories,
8184
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8185
+ money: false,
8186
+ warning: false,
8187
+ error: false
8188
+ },
8189
+ "Revenue raised": {
8190
+ value: "$".concat(formatNumber((_overview$totalRevenu3 = overview.totalRevenue) !== null && _overview$totalRevenu3 !== void 0 ? _overview$totalRevenu3 : 0)),
8191
+ subValue: growthCaption("totalRevenue"),
8192
+ data: revenueChartData,
8193
+ categories: organicUsersSeries.categories,
8194
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8195
+ money: true,
8196
+ warning: false,
8197
+ error: false
8198
+ },
8199
+ "Avg donation": {
8200
+ value: "$".concat(formatNumber((_overview$overallAVGD3 = overview.overallAVGDonations) !== null && _overview$overallAVGD3 !== void 0 ? _overview$overallAVGD3 : 0)),
8201
+ subValue: growthCaption("overallAVGDonations"),
8202
+ data: avgChartData,
8203
+ categories: organicUsersSeries.categories,
8204
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8205
+ money: true,
8206
+ warning: false,
8207
+ error: false
8208
+ }
8209
+ };
8210
+ }, [apiData === null || apiData === void 0 || (_apiData$topOrganicKe2 = apiData.topOrganicKeywords) === null || _apiData$topOrganicKe2 === void 0 ? void 0 : _apiData$topOrganicKe2.available, conversionSeries, donationsSeries, fallbackCategories, growth, hasOrganicOverview, organicUsersSeries, overview, dateName]);
8211
+ var landingPagesData = React.useMemo(function () {
8212
+ var pages = apiData === null || apiData === void 0 ? void 0 : apiData.topLandingPages;
8213
+ if (!hasOrganicOverview) return null;
8214
+ if (!Array.isArray(pages) || pages.length === 0) return [];
8215
+ return pages.map(function (item) {
8216
+ var _item$visitors, _item$donations, _item$revenue, _item$conversionRate;
8217
+ return {
8218
+ page: item.page,
8219
+ visitors: formatNumber((_item$visitors = item.visitors) !== null && _item$visitors !== void 0 ? _item$visitors : 0),
8220
+ donations: formatNumber((_item$donations = item.donations) !== null && _item$donations !== void 0 ? _item$donations : 0),
8221
+ revenue: "$".concat(formatNumber((_item$revenue = item.revenue) !== null && _item$revenue !== void 0 ? _item$revenue : 0)),
8222
+ cvr: "".concat(Number((_item$conversionRate = item.conversionRate) !== null && _item$conversionRate !== void 0 ? _item$conversionRate : 0).toFixed(2), "%")
8223
+ };
8224
+ });
8225
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topLandingPages, hasOrganicOverview]);
8226
+ var keywordsData = React.useMemo(function () {
8227
+ var keywords = apiData === null || apiData === void 0 ? void 0 : apiData.topOrganicKeywords;
8228
+ if (!hasOrganicOverview) return null;
8229
+ if (!(keywords !== null && keywords !== void 0 && keywords.available) || !Array.isArray(keywords.data) || keywords.data.length === 0) {
8230
+ return [];
8231
+ }
8232
+ return keywords.data.map(function (item) {
8233
+ var _item$clicks, _item$rank, _item$trend, _item$trendType;
8234
+ return {
8235
+ keyword: item.keyword,
8236
+ clicks: formatNumber((_item$clicks = item.clicks) !== null && _item$clicks !== void 0 ? _item$clicks : 0),
8237
+ rank: (_item$rank = item.rank) !== null && _item$rank !== void 0 ? _item$rank : "—",
8238
+ trend: (_item$trend = item.trend) !== null && _item$trend !== void 0 ? _item$trend : "—",
8239
+ trendType: (_item$trendType = item.trendType) !== null && _item$trendType !== void 0 ? _item$trendType : "up"
8240
+ };
8241
+ });
8242
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topOrganicKeywords, hasOrganicOverview]);
8243
+ var geographyData = React.useMemo(function () {
8244
+ var _apiData$geographyIns;
8245
+ var countries = apiData === null || apiData === void 0 || (_apiData$geographyIns = apiData.geographyInsights) === null || _apiData$geographyIns === void 0 ? void 0 : _apiData$geographyIns.countries;
8246
+ if (!hasOrganicOverview) return null;
8247
+ if (!Array.isArray(countries) || countries.length === 0) return [];
8248
+ return countries.map(function (item) {
8249
+ var _item$visitors2, _item$percentage, _item$percentage2;
8250
+ return {
8251
+ country: item.country || "Unknown",
8252
+ stats: "".concat(formatNumber((_item$visitors2 = item.visitors) !== null && _item$visitors2 !== void 0 ? _item$visitors2 : 0), " \xB7 ").concat(Number((_item$percentage = item.percentage) !== null && _item$percentage !== void 0 ? _item$percentage : 0).toFixed(0), "%"),
8253
+ percentage: Number((_item$percentage2 = item.percentage) !== null && _item$percentage2 !== void 0 ? _item$percentage2 : 0)
8254
+ };
8255
+ });
8256
+ }, [apiData === null || apiData === void 0 || (_apiData$geographyIns2 = apiData.geographyInsights) === null || _apiData$geographyIns2 === void 0 ? void 0 : _apiData$geographyIns2.countries, hasOrganicOverview]);
8257
+ var sourceBreakdown = React.useMemo(function () {
8258
+ var _breakdown$totalVisit;
8259
+ var breakdown = apiData === null || apiData === void 0 ? void 0 : apiData.sourceBreakdown;
8260
+ var sources = breakdown === null || breakdown === void 0 ? void 0 : breakdown.data;
8261
+ if (!hasOrganicOverview) return null;
8262
+ if (!Array.isArray(sources) || sources.length === 0) return null;
8263
+ var colors = sources.map(function (_, index) {
8264
+ return SOURCE_COLORS[index % SOURCE_COLORS.length];
8265
+ });
8266
+ return {
8267
+ series: sources.map(function (item) {
8268
+ var _item$percentage3;
8269
+ return Number((_item$percentage3 = item.percentage) !== null && _item$percentage3 !== void 0 ? _item$percentage3 : 0);
8270
+ }),
8271
+ labels: sources.map(function (item) {
8272
+ return item.source;
8273
+ }),
8274
+ colors: colors,
8275
+ centerLabel: "visitors",
8276
+ centerValue: formatNumber((_breakdown$totalVisit = breakdown.totalVisitors) !== null && _breakdown$totalVisit !== void 0 ? _breakdown$totalVisit : 0),
8277
+ items: sources.map(function (item, index) {
8278
+ var _item$percentage4;
8279
+ return {
8280
+ label: item.source,
8281
+ val: "".concat(Number((_item$percentage4 = item.percentage) !== null && _item$percentage4 !== void 0 ? _item$percentage4 : 0).toFixed(1), "%"),
8282
+ color: colors[index]
8283
+ };
8284
+ })
8285
+ };
8286
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.sourceBreakdown, hasOrganicOverview]);
8059
8287
  var renderCard = function renderCard(title) {
8060
- return /*#__PURE__*/jsxRuntime.jsx(MetricCard
8061
- // key={title}
8062
- , {
8288
+ return /*#__PURE__*/jsxRuntime.jsx(MetricCard, {
8063
8289
  title: title,
8064
8290
  value: metricInfo[title].money ? metricInfo[title].value : metricInfo[title].value,
8065
8291
  caption: metricInfo[title].subValue,
@@ -8073,31 +8299,16 @@ var OrganicSection = function OrganicSection(_ref) {
8073
8299
  border: "2px solid #ef4444",
8074
8300
  bgcolor: "#fffafa"
8075
8301
  } : {}
8076
- })
8077
- // <DisplayCard
8078
- // key={title}
8079
- // title={title}
8080
- // value={metricInfo[title].value}
8081
- // subValue={metricInfo[title].subValue}
8082
- // icon={metricInfo[title].icon}
8083
- // onClick={() => setActiveMetric(title)}
8084
- // isActive={activeMetric === title}
8085
- // sx={{
8086
- // // border:
8087
- // // activeMetric === title
8088
- // // ? "2px solid rgb(99, 99, 230)"
8089
- // // : "2px solid #f0f0f0",
8090
- // }}
8091
- // />
8092
- ;
8302
+ });
8093
8303
  };
8094
- var selectedInfo = metricInfo[activeMetric];
8304
+ var selectedInfo = metricInfo[activeMetric] || metricInfo["Organic Users"];
8305
+ var chartCategories = ((_selectedInfo$categor = selectedInfo.categories) === null || _selectedInfo$categor === void 0 ? void 0 : _selectedInfo$categor.length) > 0 ? selectedInfo.categories : fallbackCategories;
8095
8306
  var mainChart = {
8096
8307
  label: activeMetric,
8097
8308
  value: selectedInfo.value,
8098
8309
  trend: selectedInfo.subValue,
8099
8310
  data: selectedInfo.data,
8100
- categories: categories
8311
+ categories: chartCategories
8101
8312
  };
8102
8313
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
8103
8314
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
@@ -8130,7 +8341,9 @@ var OrganicSection = function OrganicSection(_ref) {
8130
8341
  item: true,
8131
8342
  xs: 12,
8132
8343
  md: 6,
8133
- children: /*#__PURE__*/jsxRuntime.jsx(LandingPagesCard, {})
8344
+ children: /*#__PURE__*/jsxRuntime.jsx(LandingPagesCard, {
8345
+ data: landingPagesData
8346
+ })
8134
8347
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
8135
8348
  item: true,
8136
8349
  xs: 12,
@@ -8138,12 +8351,12 @@ var OrganicSection = function OrganicSection(_ref) {
8138
8351
  children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
8139
8352
  title: "Source breakdown",
8140
8353
  subtitle: "Where organic visitors come from",
8141
- series: [40.8, 35.1, 14.2, 3.3],
8142
- labels: ["Meta Ads", "Google Ads", "TikTok", "Snapchat"],
8143
- colors: ["#4267B2", "#4285F4", "#06510bff", "#f2b61dff"],
8144
- centerLabel: "total spend",
8145
- centerValue: "$8.3K",
8146
- items: [{
8354
+ series: (_sourceBreakdown$seri = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.series) !== null && _sourceBreakdown$seri !== void 0 ? _sourceBreakdown$seri : [40.8, 35.1, 14.2, 3.3],
8355
+ labels: (_sourceBreakdown$labe = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.labels) !== null && _sourceBreakdown$labe !== void 0 ? _sourceBreakdown$labe : ["Meta Ads", "Google Ads", "TikTok", "Snapchat"],
8356
+ colors: (_sourceBreakdown$colo = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.colors) !== null && _sourceBreakdown$colo !== void 0 ? _sourceBreakdown$colo : ["#4267B2", "#4285F4", "#06510bff", "#f2b61dff"],
8357
+ centerLabel: (_sourceBreakdown$cent = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.centerLabel) !== null && _sourceBreakdown$cent !== void 0 ? _sourceBreakdown$cent : "total spend",
8358
+ centerValue: (_sourceBreakdown$cent2 = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.centerValue) !== null && _sourceBreakdown$cent2 !== void 0 ? _sourceBreakdown$cent2 : "$8.3K",
8359
+ items: (_sourceBreakdown$item = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.items) !== null && _sourceBreakdown$item !== void 0 ? _sourceBreakdown$item : [{
8147
8360
  label: "Google Search",
8148
8361
  val: "40.8%",
8149
8362
  color: "#4267B2"
@@ -8169,13 +8382,17 @@ var OrganicSection = function OrganicSection(_ref) {
8169
8382
  item: true,
8170
8383
  xs: 12,
8171
8384
  md: 6,
8172
- children: /*#__PURE__*/jsxRuntime.jsx(KeywordsCard, {})
8385
+ children: /*#__PURE__*/jsxRuntime.jsx(KeywordsCard, {
8386
+ data: keywordsData,
8387
+ available: hasOrganicOverview ? (apiData === null || apiData === void 0 || (_apiData$topOrganicKe3 = apiData.topOrganicKeywords) === null || _apiData$topOrganicKe3 === void 0 ? void 0 : _apiData$topOrganicKe3.available) !== false : true
8388
+ })
8173
8389
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
8174
8390
  item: true,
8175
8391
  xs: 12,
8176
8392
  md: 6,
8177
8393
  children: /*#__PURE__*/jsxRuntime.jsx(GeographyCard, {
8178
- subtitle: "Top countries by organic traffic"
8394
+ subtitle: "Top countries by organic traffic",
8395
+ data: geographyData
8179
8396
  })
8180
8397
  })]
8181
8398
  })]