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