@ammarkhalidfarooq/dashboard-package 0.5.20 → 0.5.22

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,265 @@ 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 revenueSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.totalRevenue);
8069
+ var avgDonationSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.avdDonations);
8070
+ var fallbackCategories = organicUsersSeries.categories.length ? organicUsersSeries.categories : ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
8071
+ var growthCaption = function growthCaption(key) {
8072
+ return formatGrowth(growth[key], dateName);
8058
8073
  };
8074
+ var metricInfo = React.useMemo(function () {
8075
+ var _overview$totalRevenu2, _overview$overallAVGD2, _overview$organicUser, _apiData$topOrganicKe, _overview$totalDonati, _overview$conversionR, _overview$totalRevenu3, _overview$overallAVGD3;
8076
+ if (!hasOrganicOverview) {
8077
+ return {
8078
+ "Organic Users": {
8079
+ value: "".concat(formatNumber(8420)),
8080
+ subValue: "18% vs last month",
8081
+ data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
8082
+ categories: fallbackCategories,
8083
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8084
+ money: false,
8085
+ warning: false,
8086
+ error: false
8087
+ },
8088
+ "Search Clicks": {
8089
+ value: "".concat(formatNumber(5842)),
8090
+ subValue: "92.3% pass-through",
8091
+ data: [1500, 1800, 1600, 2200, 2000, 2400, 2800],
8092
+ categories: fallbackCategories,
8093
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8094
+ money: false,
8095
+ warning: false,
8096
+ error: false
8097
+ },
8098
+ Donations: {
8099
+ value: "".concat(formatNumber(420)),
8100
+ subValue: "18% vs last month",
8101
+ data: [15, 22, 18, 30, 25, 35, 42],
8102
+ categories: fallbackCategories,
8103
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8104
+ money: false,
8105
+ warning: false,
8106
+ error: false
8107
+ },
8108
+ "Conversion Rate": {
8109
+ value: "3.1%",
8110
+ subValue: "8.4% vs last month",
8111
+ data: [2.5, 2.7, 2.6, 3.1, 3.0, 2.9, 3.1],
8112
+ categories: fallbackCategories,
8113
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8114
+ money: false,
8115
+ warning: false,
8116
+ error: false
8117
+ },
8118
+ "Revenue raised": {
8119
+ value: "$".concat(formatNumber(240398)),
8120
+ subValue: "0.4x vs last month",
8121
+ data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
8122
+ categories: fallbackCategories,
8123
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8124
+ money: true,
8125
+ warning: false,
8126
+ error: false
8127
+ },
8128
+ "Avg donation": {
8129
+ value: "$".concat(formatNumber(130.58)),
8130
+ subValue: "18% vs last month",
8131
+ data: [110, 125, 120, 135, 130, 128, 130.58],
8132
+ categories: fallbackCategories,
8133
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8134
+ money: true,
8135
+ warning: false,
8136
+ error: false
8137
+ }
8138
+ };
8139
+ }
8140
+ organicUsersSeries.data.length > 0 ? organicUsersSeries.data.map(function () {
8141
+ var _overview$totalRevenu;
8142
+ return (_overview$totalRevenu = overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 0;
8143
+ }) : [(_overview$totalRevenu2 = overview.totalRevenue) !== null && _overview$totalRevenu2 !== void 0 ? _overview$totalRevenu2 : 0];
8144
+ organicUsersSeries.data.length > 0 ? organicUsersSeries.data.map(function () {
8145
+ var _overview$overallAVGD;
8146
+ return (_overview$overallAVGD = overview.overallAVGDonations) !== null && _overview$overallAVGD !== void 0 ? _overview$overallAVGD : 0;
8147
+ }) : [(_overview$overallAVGD2 = overview.overallAVGDonations) !== null && _overview$overallAVGD2 !== void 0 ? _overview$overallAVGD2 : 0];
8148
+ return {
8149
+ "Organic Users": {
8150
+ value: formatNumber((_overview$organicUser = overview.organicUsers) !== null && _overview$organicUser !== void 0 ? _overview$organicUser : 0),
8151
+ subValue: growthCaption("organicUsers"),
8152
+ data: organicUsersSeries.data,
8153
+ categories: organicUsersSeries.categories,
8154
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8155
+ money: false,
8156
+ warning: false,
8157
+ error: false
8158
+ },
8159
+ "Search Clicks": {
8160
+ value: "—",
8161
+ subValue: apiData !== null && apiData !== void 0 && (_apiData$topOrganicKe = apiData.topOrganicKeywords) !== null && _apiData$topOrganicKe !== void 0 && _apiData$topOrganicKe.available ? "From organic search" : "Keyword tracking unavailable",
8162
+ data: organicUsersSeries.data.map(function () {
8163
+ return 0;
8164
+ }),
8165
+ categories: organicUsersSeries.categories,
8166
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8167
+ money: false,
8168
+ warning: false,
8169
+ error: false
8170
+ },
8171
+ Donations: {
8172
+ value: formatNumber((_overview$totalDonati = overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 0),
8173
+ subValue: growthCaption("totalDonations"),
8174
+ data: donationsSeries.data,
8175
+ categories: donationsSeries.categories,
8176
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8177
+ money: false,
8178
+ warning: false,
8179
+ error: false
8180
+ },
8181
+ "Conversion Rate": {
8182
+ value: "".concat(Number((_overview$conversionR = overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 0).toFixed(2), "%"),
8183
+ subValue: growthCaption("conversionRate"),
8184
+ data: conversionSeries.data,
8185
+ categories: conversionSeries.categories,
8186
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8187
+ money: false,
8188
+ warning: false,
8189
+ error: false
8190
+ },
8191
+ "Revenue raised": {
8192
+ value: "$".concat(formatNumber((_overview$totalRevenu3 = overview.totalRevenue) !== null && _overview$totalRevenu3 !== void 0 ? _overview$totalRevenu3 : 0)),
8193
+ subValue: growthCaption("totalRevenue"),
8194
+ data: revenueSeries.data,
8195
+ categories: revenueSeries.categories,
8196
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8197
+ money: true,
8198
+ warning: false,
8199
+ error: false
8200
+ },
8201
+ "Avg donation": {
8202
+ value: "$".concat(formatNumber((_overview$overallAVGD3 = overview.overallAVGDonations) !== null && _overview$overallAVGD3 !== void 0 ? _overview$overallAVGD3 : 0)),
8203
+ subValue: growthCaption("overallAVGDonations"),
8204
+ data: avgDonationSeries.data,
8205
+ categories: avgDonationSeries.categories,
8206
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8207
+ money: true,
8208
+ warning: false,
8209
+ error: false
8210
+ }
8211
+ };
8212
+ }, [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]);
8213
+ var landingPagesData = React.useMemo(function () {
8214
+ var pages = apiData === null || apiData === void 0 ? void 0 : apiData.topLandingPages;
8215
+ if (!hasOrganicOverview) return null;
8216
+ if (!Array.isArray(pages) || pages.length === 0) return [];
8217
+ return pages.map(function (item) {
8218
+ var _item$visitors, _item$donations, _item$revenue, _item$conversionRate;
8219
+ return {
8220
+ page: item.page,
8221
+ visitors: formatNumber((_item$visitors = item.visitors) !== null && _item$visitors !== void 0 ? _item$visitors : 0),
8222
+ donations: formatNumber((_item$donations = item.donations) !== null && _item$donations !== void 0 ? _item$donations : 0),
8223
+ revenue: "$".concat(formatNumber((_item$revenue = item.revenue) !== null && _item$revenue !== void 0 ? _item$revenue : 0)),
8224
+ cvr: "".concat(Number((_item$conversionRate = item.conversionRate) !== null && _item$conversionRate !== void 0 ? _item$conversionRate : 0).toFixed(2), "%")
8225
+ };
8226
+ });
8227
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topLandingPages, hasOrganicOverview]);
8228
+ var keywordsData = React.useMemo(function () {
8229
+ var keywords = apiData === null || apiData === void 0 ? void 0 : apiData.topOrganicKeywords;
8230
+ if (!hasOrganicOverview) return null;
8231
+ if (!(keywords !== null && keywords !== void 0 && keywords.available) || !Array.isArray(keywords.data) || keywords.data.length === 0) {
8232
+ return [];
8233
+ }
8234
+ return keywords.data.map(function (item) {
8235
+ var _item$clicks, _item$rank, _item$trend, _item$trendType;
8236
+ return {
8237
+ keyword: item.keyword,
8238
+ clicks: formatNumber((_item$clicks = item.clicks) !== null && _item$clicks !== void 0 ? _item$clicks : 0),
8239
+ rank: (_item$rank = item.rank) !== null && _item$rank !== void 0 ? _item$rank : "—",
8240
+ trend: (_item$trend = item.trend) !== null && _item$trend !== void 0 ? _item$trend : "—",
8241
+ trendType: (_item$trendType = item.trendType) !== null && _item$trendType !== void 0 ? _item$trendType : "up"
8242
+ };
8243
+ });
8244
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topOrganicKeywords, hasOrganicOverview]);
8245
+ var geographyData = React.useMemo(function () {
8246
+ var _apiData$geographyIns;
8247
+ var countries = apiData === null || apiData === void 0 || (_apiData$geographyIns = apiData.geographyInsights) === null || _apiData$geographyIns === void 0 ? void 0 : _apiData$geographyIns.countries;
8248
+ if (!hasOrganicOverview) return null;
8249
+ if (!Array.isArray(countries) || countries.length === 0) return [];
8250
+ return countries.map(function (item) {
8251
+ var _item$visitors2, _item$percentage, _item$percentage2;
8252
+ return {
8253
+ country: item.country || "Unknown",
8254
+ 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), "%"),
8255
+ percentage: Number((_item$percentage2 = item.percentage) !== null && _item$percentage2 !== void 0 ? _item$percentage2 : 0)
8256
+ };
8257
+ });
8258
+ }, [apiData === null || apiData === void 0 || (_apiData$geographyIns2 = apiData.geographyInsights) === null || _apiData$geographyIns2 === void 0 ? void 0 : _apiData$geographyIns2.countries, hasOrganicOverview]);
8259
+ var sourceBreakdown = React.useMemo(function () {
8260
+ var _breakdown$totalVisit;
8261
+ var breakdown = apiData === null || apiData === void 0 ? void 0 : apiData.sourceBreakdown;
8262
+ var sources = breakdown === null || breakdown === void 0 ? void 0 : breakdown.data;
8263
+ if (!hasOrganicOverview) return null;
8264
+ if (!Array.isArray(sources) || sources.length === 0) return null;
8265
+ var colors = sources.map(function (_, index) {
8266
+ return SOURCE_COLORS[index % SOURCE_COLORS.length];
8267
+ });
8268
+ return {
8269
+ series: sources.map(function (item) {
8270
+ var _item$percentage3;
8271
+ return Number((_item$percentage3 = item.percentage) !== null && _item$percentage3 !== void 0 ? _item$percentage3 : 0);
8272
+ }),
8273
+ labels: sources.map(function (item) {
8274
+ return item.source;
8275
+ }),
8276
+ colors: colors,
8277
+ centerLabel: "visitors",
8278
+ centerValue: formatNumber((_breakdown$totalVisit = breakdown.totalVisitors) !== null && _breakdown$totalVisit !== void 0 ? _breakdown$totalVisit : 0),
8279
+ items: sources.map(function (item, index) {
8280
+ var _item$percentage4;
8281
+ return {
8282
+ label: item.source,
8283
+ val: "".concat(Number((_item$percentage4 = item.percentage) !== null && _item$percentage4 !== void 0 ? _item$percentage4 : 0).toFixed(1), "%"),
8284
+ color: colors[index]
8285
+ };
8286
+ })
8287
+ };
8288
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.sourceBreakdown, hasOrganicOverview]);
8059
8289
  var renderCard = function renderCard(title) {
8060
- return /*#__PURE__*/jsxRuntime.jsx(MetricCard
8061
- // key={title}
8062
- , {
8290
+ return /*#__PURE__*/jsxRuntime.jsx(MetricCard, {
8063
8291
  title: title,
8064
8292
  value: metricInfo[title].money ? metricInfo[title].value : metricInfo[title].value,
8065
8293
  caption: metricInfo[title].subValue,
@@ -8073,31 +8301,16 @@ var OrganicSection = function OrganicSection(_ref) {
8073
8301
  border: "2px solid #ef4444",
8074
8302
  bgcolor: "#fffafa"
8075
8303
  } : {}
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
- ;
8304
+ });
8093
8305
  };
8094
- var selectedInfo = metricInfo[activeMetric];
8306
+ var selectedInfo = metricInfo[activeMetric] || metricInfo["Organic Users"];
8307
+ var chartCategories = ((_selectedInfo$categor = selectedInfo.categories) === null || _selectedInfo$categor === void 0 ? void 0 : _selectedInfo$categor.length) > 0 ? selectedInfo.categories : fallbackCategories;
8095
8308
  var mainChart = {
8096
8309
  label: activeMetric,
8097
8310
  value: selectedInfo.value,
8098
8311
  trend: selectedInfo.subValue,
8099
8312
  data: selectedInfo.data,
8100
- categories: categories
8313
+ categories: chartCategories
8101
8314
  };
8102
8315
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
8103
8316
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
@@ -8130,7 +8343,9 @@ var OrganicSection = function OrganicSection(_ref) {
8130
8343
  item: true,
8131
8344
  xs: 12,
8132
8345
  md: 6,
8133
- children: /*#__PURE__*/jsxRuntime.jsx(LandingPagesCard, {})
8346
+ children: /*#__PURE__*/jsxRuntime.jsx(LandingPagesCard, {
8347
+ data: landingPagesData
8348
+ })
8134
8349
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
8135
8350
  item: true,
8136
8351
  xs: 12,
@@ -8138,12 +8353,12 @@ var OrganicSection = function OrganicSection(_ref) {
8138
8353
  children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
8139
8354
  title: "Source breakdown",
8140
8355
  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: [{
8356
+ 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],
8357
+ 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"],
8358
+ colors: (_sourceBreakdown$colo = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.colors) !== null && _sourceBreakdown$colo !== void 0 ? _sourceBreakdown$colo : ["#4267B2", "#4285F4", "#06510bff", "#f2b61dff"],
8359
+ centerLabel: (_sourceBreakdown$cent = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.centerLabel) !== null && _sourceBreakdown$cent !== void 0 ? _sourceBreakdown$cent : "total spend",
8360
+ centerValue: (_sourceBreakdown$cent2 = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.centerValue) !== null && _sourceBreakdown$cent2 !== void 0 ? _sourceBreakdown$cent2 : "$8.3K",
8361
+ items: (_sourceBreakdown$item = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.items) !== null && _sourceBreakdown$item !== void 0 ? _sourceBreakdown$item : [{
8147
8362
  label: "Google Search",
8148
8363
  val: "40.8%",
8149
8364
  color: "#4267B2"
@@ -8169,13 +8384,17 @@ var OrganicSection = function OrganicSection(_ref) {
8169
8384
  item: true,
8170
8385
  xs: 12,
8171
8386
  md: 6,
8172
- children: /*#__PURE__*/jsxRuntime.jsx(KeywordsCard, {})
8387
+ children: /*#__PURE__*/jsxRuntime.jsx(KeywordsCard, {
8388
+ data: keywordsData,
8389
+ available: hasOrganicOverview ? (apiData === null || apiData === void 0 || (_apiData$topOrganicKe3 = apiData.topOrganicKeywords) === null || _apiData$topOrganicKe3 === void 0 ? void 0 : _apiData$topOrganicKe3.available) !== false : true
8390
+ })
8173
8391
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
8174
8392
  item: true,
8175
8393
  xs: 12,
8176
8394
  md: 6,
8177
8395
  children: /*#__PURE__*/jsxRuntime.jsx(GeographyCard, {
8178
- subtitle: "Top countries by organic traffic"
8396
+ subtitle: "Top countries by organic traffic",
8397
+ data: geographyData
8179
8398
  })
8180
8399
  })]
8181
8400
  })]