@ammarkhalidfarooq/dashboard-package 0.5.19 → 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';
@@ -902,6 +902,17 @@ var W = 794;
902
902
  var H = 1123;
903
903
  var MX = 32; // horizontal margin
904
904
  var CW = W - MX * 2; // 730 px usable width
905
+ var THEME = {
906
+ pageBg: "#F8FAFC",
907
+ panelBg: "#FFFFFF",
908
+ panelBorder: "#DDE3EA",
909
+ kpiBg: "#F6F8FF",
910
+ kpiBorder: "#D9E0FF",
911
+ tableHeadBg: "#EEF2FF",
912
+ tableAltBg: "#F8FAFF",
913
+ muted: "#94A3B8",
914
+ text: "#111827"
915
+ };
905
916
 
906
917
  // ─── Number helpers ───────────────────────────────────────────────────────────
907
918
  var d$ = function d$(v) {
@@ -995,7 +1006,7 @@ var LineChart = function LineChart(_ref2) {
995
1006
  return /*#__PURE__*/jsx("div", {
996
1007
  style: {
997
1008
  height: height,
998
- background: "#F9FAFB",
1009
+ background: THEME.tableAltBg,
999
1010
  borderRadius: 6
1000
1011
  }
1001
1012
  });
@@ -1038,14 +1049,14 @@ var LineChart = function LineChart(_ref2) {
1038
1049
  y1: y,
1039
1050
  x2: width - PR,
1040
1051
  y2: y,
1041
- stroke: "#F3F4F6",
1052
+ stroke: "#E5EAF1",
1042
1053
  strokeWidth: 1
1043
1054
  }), /*#__PURE__*/jsx("text", {
1044
1055
  x: PL - 4,
1045
1056
  y: y + 3.5,
1046
1057
  textAnchor: "end",
1047
1058
  fontSize: 9,
1048
- fill: "#9CA3AF",
1059
+ fill: THEME.muted,
1049
1060
  children: label
1050
1061
  })]
1051
1062
  }, i);
@@ -1071,7 +1082,7 @@ var LineChart = function LineChart(_ref2) {
1071
1082
  y: height - 5,
1072
1083
  textAnchor: "middle",
1073
1084
  fontSize: 9,
1074
- fill: "#9CA3AF",
1085
+ fill: THEME.muted,
1075
1086
  children: label
1076
1087
  }, i);
1077
1088
  })]
@@ -1105,7 +1116,7 @@ var Donut = function Donut(_ref3) {
1105
1116
  cy: cy,
1106
1117
  r: r,
1107
1118
  fill: "none",
1108
- stroke: "#E5E7EB",
1119
+ stroke: "#E6EBF5",
1109
1120
  strokeWidth: 12
1110
1121
  }), segments.map(function (seg, i) {
1111
1122
  var dash = seg.value / total * circ;
@@ -1136,7 +1147,7 @@ var Donut = function Donut(_ref3) {
1136
1147
  y: cy + 13,
1137
1148
  textAnchor: "middle",
1138
1149
  fontSize: 9,
1139
- fill: "#6B7280",
1150
+ fill: THEME.muted,
1140
1151
  children: centerLabel
1141
1152
  })]
1142
1153
  });
@@ -1150,7 +1161,7 @@ var Divider = function Divider(_ref4) {
1150
1161
  mb = _ref4$mb === void 0 ? 0 : _ref4$mb;
1151
1162
  return /*#__PURE__*/jsx("div", {
1152
1163
  style: {
1153
- borderTop: "1px solid #E5E7EB",
1164
+ borderTop: "1px solid #E5EAF1",
1154
1165
  marginTop: mt,
1155
1166
  marginBottom: mb
1156
1167
  }
@@ -1165,13 +1176,14 @@ var Panel = function Panel(_ref5) {
1165
1176
  style = _ref5$style === void 0 ? {} : _ref5$style;
1166
1177
  return /*#__PURE__*/jsxs("div", {
1167
1178
  style: _objectSpread2({
1168
- border: "1px solid #E5E7EB",
1179
+ border: "1px solid ".concat(THEME.panelBorder),
1169
1180
  borderRadius: 8,
1170
- background: "#fff",
1181
+ background: THEME.panelBg,
1171
1182
  padding: 12,
1172
1183
  display: "flex",
1173
1184
  flexDirection: "column",
1174
- boxSizing: "border-box"
1185
+ boxSizing: "border-box",
1186
+ boxShadow: "0 1px 0 rgba(15,23,42,0.03)"
1175
1187
  }, style),
1176
1188
  children: [(title || subtitle || action) && /*#__PURE__*/jsxs("div", {
1177
1189
  style: {
@@ -1186,14 +1198,14 @@ var Panel = function Panel(_ref5) {
1186
1198
  style: {
1187
1199
  fontSize: 12,
1188
1200
  fontWeight: 700,
1189
- color: "#111827",
1201
+ color: THEME.text,
1190
1202
  lineHeight: 1.2
1191
1203
  },
1192
1204
  children: title
1193
1205
  }), subtitle && /*#__PURE__*/jsx("div", {
1194
1206
  style: {
1195
1207
  fontSize: 9.5,
1196
- color: "#9CA3AF",
1208
+ color: THEME.muted,
1197
1209
  marginTop: 2
1198
1210
  },
1199
1211
  children: subtitle
@@ -1220,12 +1232,13 @@ var MiniTable = function MiniTable(_ref6) {
1220
1232
  width: "100%",
1221
1233
  borderCollapse: "collapse",
1222
1234
  fontSize: 9.5,
1223
- tableLayout: "fixed"
1235
+ tableLayout: "fixed",
1236
+ background: "#fff"
1224
1237
  },
1225
1238
  children: [/*#__PURE__*/jsx("thead", {
1226
1239
  children: /*#__PURE__*/jsx("tr", {
1227
1240
  style: {
1228
- background: "#F9FAFB"
1241
+ background: THEME.tableHeadBg
1229
1242
  },
1230
1243
  children: head.map(function (h, i) {
1231
1244
  return /*#__PURE__*/jsx("th", {
@@ -1235,8 +1248,8 @@ var MiniTable = function MiniTable(_ref6) {
1235
1248
  fontWeight: 700,
1236
1249
  fontSize: 8.5,
1237
1250
  letterSpacing: "0.3px",
1238
- color: "#6B7280",
1239
- borderBottom: "1px solid #E5E7EB"
1251
+ color: "#64748B",
1252
+ borderBottom: "1px solid #DDE3EA"
1240
1253
  },
1241
1254
  children: h
1242
1255
  }, i);
@@ -1246,15 +1259,15 @@ var MiniTable = function MiniTable(_ref6) {
1246
1259
  children: rows.map(function (row, ri) {
1247
1260
  return /*#__PURE__*/jsx("tr", {
1248
1261
  style: {
1249
- background: ri % 2 === 1 ? "#F9FAFB" : "#fff"
1262
+ background: ri % 2 === 1 ? THEME.tableAltBg : "#fff"
1250
1263
  },
1251
1264
  children: row.map(function (cell, ci) {
1252
1265
  return /*#__PURE__*/jsx("td", {
1253
1266
  style: {
1254
1267
  padding: "4px 6px",
1255
1268
  textAlign: ci === 0 ? "left" : "right",
1256
- color: "#374151",
1257
- borderBottom: ri < rows.length - 1 ? "1px solid #F3F4F6" : "none"
1269
+ color: "#334155",
1270
+ borderBottom: ri < rows.length - 1 ? "1px solid #EEF2F7" : "none"
1258
1271
  },
1259
1272
  children: cell
1260
1273
  }, ci);
@@ -1272,10 +1285,10 @@ var KpiCard = function KpiCard(_ref7) {
1272
1285
  var neg = "".concat(trend).trim().startsWith("-");
1273
1286
  return /*#__PURE__*/jsxs("div", {
1274
1287
  style: {
1275
- border: "1px solid #E5E7EB",
1288
+ border: "1px solid ".concat(THEME.kpiBorder),
1276
1289
  borderRadius: 8,
1277
1290
  padding: "10px 12px 9px",
1278
- background: "#fff",
1291
+ background: THEME.kpiBg,
1279
1292
  width: "100%",
1280
1293
  minWidth: 0,
1281
1294
  boxSizing: "border-box",
@@ -1288,7 +1301,7 @@ var KpiCard = function KpiCard(_ref7) {
1288
1301
  fontSize: 8,
1289
1302
  fontWeight: 700,
1290
1303
  letterSpacing: "0.7px",
1291
- color: "#6B7280",
1304
+ color: "#64748B",
1292
1305
  textTransform: "uppercase"
1293
1306
  },
1294
1307
  children: title
@@ -1296,7 +1309,7 @@ var KpiCard = function KpiCard(_ref7) {
1296
1309
  style: {
1297
1310
  fontSize: 17,
1298
1311
  fontWeight: 800,
1299
- color: "#111827",
1312
+ color: THEME.text,
1300
1313
  lineHeight: 1.1,
1301
1314
  marginTop: 2
1302
1315
  },
@@ -1311,7 +1324,7 @@ var KpiCard = function KpiCard(_ref7) {
1311
1324
  }), /*#__PURE__*/jsx("div", {
1312
1325
  style: {
1313
1326
  fontSize: 8.5,
1314
- color: "#9CA3AF",
1327
+ color: THEME.muted,
1315
1328
  lineHeight: 1.4
1316
1329
  },
1317
1330
  children: detail
@@ -1330,7 +1343,7 @@ var StatPair = function StatPair(_ref8) {
1330
1343
  children: [/*#__PURE__*/jsx("div", {
1331
1344
  style: {
1332
1345
  fontSize: 8.5,
1333
- color: "#9CA3AF",
1346
+ color: THEME.muted,
1334
1347
  marginBottom: 1
1335
1348
  },
1336
1349
  children: label
@@ -1366,7 +1379,8 @@ var PageHeader = function PageHeader(_ref9) {
1366
1379
  return /*#__PURE__*/jsxs("div", {
1367
1380
  style: {
1368
1381
  padding: "22px ".concat(MX, "px 12px"),
1369
- borderBottom: "1px solid #E5E7EB",
1382
+ borderBottom: "1px solid #DEE5EF",
1383
+ background: "#FFFFFF",
1370
1384
  flexShrink: 0
1371
1385
  },
1372
1386
  children: [/*#__PURE__*/jsx("div", {
@@ -1385,7 +1399,7 @@ var PageHeader = function PageHeader(_ref9) {
1385
1399
  style: {
1386
1400
  fontSize: 20,
1387
1401
  fontWeight: 800,
1388
- color: "#111827",
1402
+ color: THEME.text,
1389
1403
  letterSpacing: "-0.5px"
1390
1404
  },
1391
1405
  children: "Madinah"
@@ -1394,7 +1408,7 @@ var PageHeader = function PageHeader(_ref9) {
1394
1408
  fontSize: 8.5,
1395
1409
  fontWeight: 700,
1396
1410
  letterSpacing: "1.5px",
1397
- color: "#9CA3AF",
1411
+ color: "#94A3B8",
1398
1412
  textTransform: "uppercase"
1399
1413
  },
1400
1414
  children: "PERFORMANCE REPORT"
@@ -1405,7 +1419,7 @@ var PageHeader = function PageHeader(_ref9) {
1405
1419
  marginTop: 8,
1406
1420
  fontSize: 13.5,
1407
1421
  fontWeight: 700,
1408
- color: "#111827"
1422
+ color: THEME.text
1409
1423
  },
1410
1424
  children: "Dashboard overview \u2014 Overall"
1411
1425
  }), /*#__PURE__*/jsxs("div", {
@@ -1418,13 +1432,13 @@ var PageHeader = function PageHeader(_ref9) {
1418
1432
  children: [/*#__PURE__*/jsx("div", {
1419
1433
  style: {
1420
1434
  fontSize: 10.5,
1421
- color: "#374151"
1435
+ color: "#334155"
1422
1436
  },
1423
1437
  children: dateLabel
1424
1438
  }), /*#__PURE__*/jsxs("div", {
1425
1439
  style: {
1426
1440
  fontSize: 9.5,
1427
- color: "#9CA3AF",
1441
+ color: THEME.muted,
1428
1442
  marginTop: 1
1429
1443
  },
1430
1444
  children: ["30-day window \xB7 Generated ", generatedLabel]
@@ -1432,7 +1446,7 @@ var PageHeader = function PageHeader(_ref9) {
1432
1446
  }), /*#__PURE__*/jsxs("div", {
1433
1447
  style: {
1434
1448
  fontSize: 9,
1435
- color: "#9CA3AF",
1449
+ color: THEME.muted,
1436
1450
  textAlign: "right",
1437
1451
  alignSelf: "flex-end"
1438
1452
  },
@@ -1443,8 +1457,8 @@ var PageHeader = function PageHeader(_ref9) {
1443
1457
  marginTop: 7,
1444
1458
  display: "inline-flex",
1445
1459
  gap: 5,
1446
- background: "#F9FAFB",
1447
- border: "1px solid #E5E7EB",
1460
+ background: "#EEF2FF",
1461
+ border: "1px solid #D7DEFF",
1448
1462
  borderRadius: 4,
1449
1463
  padding: "3px 9px",
1450
1464
  fontSize: 8.5
@@ -1471,14 +1485,15 @@ var PageFooter = function PageFooter(_ref0) {
1471
1485
  return /*#__PURE__*/jsx("div", {
1472
1486
  style: {
1473
1487
  padding: "7px ".concat(MX, "px"),
1474
- borderTop: "1px solid #E5E7EB",
1488
+ borderTop: "1px solid #DEE5EF",
1489
+ background: "#FFFFFF",
1475
1490
  marginTop: "auto",
1476
1491
  flexShrink: 0
1477
1492
  },
1478
1493
  children: /*#__PURE__*/jsxs("span", {
1479
1494
  style: {
1480
1495
  fontSize: 8,
1481
- color: "#9CA3AF"
1496
+ color: THEME.muted
1482
1497
  },
1483
1498
  children: ["Confidential \xB7 Generated by Dashboard \xB7 ", generatedLabel, " \xA0\xA0 Page ", page, " of 2 \xB7 madinah.com"]
1484
1499
  })
@@ -1649,7 +1664,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1649
1664
  style: {
1650
1665
  width: W,
1651
1666
  height: H,
1652
- background: "#fff",
1667
+ background: THEME.pageBg,
1653
1668
  display: "flex",
1654
1669
  flexDirection: "column",
1655
1670
  fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
@@ -1816,7 +1831,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1816
1831
  style: {
1817
1832
  width: W,
1818
1833
  height: H,
1819
- background: "#fff",
1834
+ background: THEME.pageBg,
1820
1835
  display: "flex",
1821
1836
  flexDirection: "column",
1822
1837
  fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
@@ -2675,7 +2690,8 @@ var NewOverview = function NewOverview(_ref) {
2675
2690
  }), activeSection === "Organic" && /*#__PURE__*/jsx(Box, {
2676
2691
  sx: {},
2677
2692
  children: /*#__PURE__*/jsx(OrganicSection$2, {
2678
- apiData: apiData
2693
+ apiData: apiData,
2694
+ dateName: dateName
2679
2695
  })
2680
2696
  }), activeSection === "Email" && /*#__PURE__*/jsx(Box, {
2681
2697
  sx: {},
@@ -5679,8 +5695,10 @@ var CardWrapper = function CardWrapper(_ref) {
5679
5695
  })
5680
5696
  });
5681
5697
  };
5682
- var LandingPagesCard = function LandingPagesCard() {
5683
- 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 : [{
5684
5702
  page: "/yemen-orphans-appeal",
5685
5703
  visitors: "1,840",
5686
5704
  donations: "32",
@@ -5770,7 +5788,15 @@ var LandingPagesCard = function LandingPagesCard() {
5770
5788
  },
5771
5789
  children: "Conv. rate"
5772
5790
  })]
5773
- }), 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) {
5774
5800
  return /*#__PURE__*/jsxs(Box, {
5775
5801
  sx: {
5776
5802
  display: "grid",
@@ -5785,8 +5811,12 @@ var LandingPagesCard = function LandingPagesCard() {
5785
5811
  fontSize: "13px",
5786
5812
  fontWeight: 700,
5787
5813
  color: "#000",
5788
- textAlign: "left"
5814
+ textAlign: "left",
5815
+ overflow: "hidden",
5816
+ textOverflow: "ellipsis",
5817
+ whiteSpace: "nowrap"
5789
5818
  },
5819
+ title: item.page,
5790
5820
  children: item.page
5791
5821
  }), /*#__PURE__*/jsx(Typography, {
5792
5822
  sx: {
@@ -5825,8 +5855,11 @@ var LandingPagesCard = function LandingPagesCard() {
5825
5855
  })]
5826
5856
  });
5827
5857
  };
5828
- var KeywordsCard = function KeywordsCard() {
5829
- 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 : [{
5830
5863
  keyword: "zakat calculator",
5831
5864
  clicks: "1,240",
5832
5865
  rank: "#2.1",
@@ -5857,142 +5890,153 @@ var KeywordsCard = function KeywordsCard() {
5857
5890
  trend: "Improving",
5858
5891
  trendType: "up"
5859
5892
  }];
5860
- return /*#__PURE__*/jsxs(CardWrapper, {
5893
+ return /*#__PURE__*/jsx(CardWrapper, {
5861
5894
  title: "Top organic keywords",
5862
5895
  subtitle: "Search terms ranked by clicks \xB7 last 30 days",
5863
- children: [/*#__PURE__*/jsxs(Box, {
5896
+ children: !available || data.length === 0 ? /*#__PURE__*/jsx(Typography, {
5864
5897
  sx: {
5865
- display: "grid",
5866
- gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5867
- gap: 2,
5868
- pb: 1,
5869
- borderBottom: "1px solid #f0f0f0"
5898
+ fontSize: "13px",
5899
+ color: "rgba(0, 0, 0, 0.45)",
5900
+ py: 2,
5901
+ textAlign: "left"
5870
5902
  },
5871
- children: [/*#__PURE__*/jsx(Typography, {
5872
- sx: {
5873
- fontSize: "12px",
5874
- color: "rgba(0, 0, 0, 0.4)",
5875
- fontWeight: 500,
5876
- textAlign: "left"
5877
- },
5878
- children: "Keyword"
5879
- }), /*#__PURE__*/jsx(Typography, {
5880
- sx: {
5881
- fontSize: "12px",
5882
- color: "rgba(0, 0, 0, 0.4)",
5883
- fontWeight: 500,
5884
- textAlign: "left"
5885
- },
5886
- children: "Clicks"
5887
- }), /*#__PURE__*/jsx(Typography, {
5888
- sx: {
5889
- fontSize: "12px",
5890
- color: "rgba(0, 0, 0, 0.4)",
5891
- fontWeight: 500,
5892
- textAlign: "left"
5893
- },
5894
- children: "Position"
5895
- }), /*#__PURE__*/jsx(Typography, {
5896
- sx: {
5897
- fontSize: "12px",
5898
- color: "rgba(0, 0, 0, 0.4)",
5899
- fontWeight: 500,
5900
- textAlign: "left"
5901
- },
5902
- children: "Trend"
5903
- })]
5904
- }), data.map(function (item, index) {
5905
- return /*#__PURE__*/jsxs(Box, {
5903
+ children: "Keyword data is not available for this period."
5904
+ }) : /*#__PURE__*/jsxs(Fragment, {
5905
+ children: [/*#__PURE__*/jsxs(Box, {
5906
5906
  sx: {
5907
5907
  display: "grid",
5908
5908
  gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5909
5909
  gap: 2,
5910
- // py: 0.5,
5911
- alignItems: "center",
5912
- borderBottom: index === data.length - 1 ? "none" : "1px solid #f5f5f5"
5910
+ pb: 1,
5911
+ borderBottom: "1px solid #f0f0f0"
5913
5912
  },
5914
5913
  children: [/*#__PURE__*/jsx(Typography, {
5915
5914
  sx: {
5916
- fontSize: "13px",
5917
- fontWeight: 700,
5918
- color: "#000",
5915
+ fontSize: "12px",
5916
+ color: "rgba(0, 0, 0, 0.4)",
5917
+ fontWeight: 500,
5919
5918
  textAlign: "left"
5920
5919
  },
5921
- children: item.keyword
5920
+ children: "Keyword"
5922
5921
  }), /*#__PURE__*/jsx(Typography, {
5923
5922
  sx: {
5924
- fontSize: "13px",
5925
- color: "rgba(0, 0, 0, 0.6)",
5923
+ fontSize: "12px",
5924
+ color: "rgba(0, 0, 0, 0.4)",
5926
5925
  fontWeight: 500,
5927
5926
  textAlign: "left"
5928
5927
  },
5929
- children: item.clicks
5930
- }), /*#__PURE__*/jsx(Box, {
5928
+ children: "Clicks"
5929
+ }), /*#__PURE__*/jsx(Typography, {
5931
5930
  sx: {
5931
+ fontSize: "12px",
5932
+ color: "rgba(0, 0, 0, 0.4)",
5933
+ fontWeight: 500,
5932
5934
  textAlign: "left"
5933
5935
  },
5934
- children: /*#__PURE__*/jsx(Box, {
5935
- sx: {
5936
- width: "40px",
5937
- bgcolor: "#ebf2ffb1",
5938
- color: "#3431e4",
5939
- // px: 0.5,
5940
- p: 0.5,
5941
- borderRadius: "100px",
5942
- fontSize: "11px",
5943
- fontWeight: 700,
5944
- textAlign: "center",
5945
- minWidth: "45px"
5946
- },
5947
- children: item.rank
5948
- })
5949
- }), /*#__PURE__*/jsx(Box, {
5936
+ children: "Position"
5937
+ }), /*#__PURE__*/jsx(Typography, {
5950
5938
  sx: {
5951
- display: "flex",
5939
+ fontSize: "12px",
5940
+ color: "rgba(0, 0, 0, 0.4)",
5941
+ fontWeight: 500,
5942
+ textAlign: "left"
5943
+ },
5944
+ children: "Trend"
5945
+ })]
5946
+ }), data.map(function (item, index) {
5947
+ return /*#__PURE__*/jsxs(Box, {
5948
+ sx: {
5949
+ display: "grid",
5950
+ gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5951
+ gap: 2,
5952
+ // py: 0.5,
5952
5953
  alignItems: "center",
5953
- justifyContent: "flex-start",
5954
- gap: 0.5
5954
+ borderBottom: index === data.length - 1 ? "none" : "1px solid #f5f5f5"
5955
5955
  },
5956
- children: item.trendType === "up" ? /*#__PURE__*/jsxs(Fragment, {
5957
- children: [/*#__PURE__*/jsx(Typography, {
5958
- sx: {
5959
- fontSize: "14px",
5960
- color: "#22C55E"
5961
- },
5962
- children: "\u25B2"
5963
- }), /*#__PURE__*/jsx(Typography, {
5964
- sx: {
5965
- fontSize: "12px",
5966
- color: "#22C55E",
5967
- fontWeight: 700
5968
- },
5969
- children: "Improving"
5970
- })]
5971
- }) : /*#__PURE__*/jsxs(Fragment, {
5972
- children: [/*#__PURE__*/jsx(Typography, {
5973
- sx: {
5974
- fontSize: "14px",
5975
- color: "#EF4444"
5976
- },
5977
- children: "\u25BC"
5978
- }), /*#__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, {
5979
5977
  sx: {
5980
- fontSize: "12px",
5981
- color: "#EF4444",
5982
- 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"
5983
5988
  },
5984
- children: "Declining"
5985
- })]
5986
- })
5987
- })]
5988
- }, index);
5989
- })]
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
+ })
5990
6033
  });
5991
6034
  };
5992
- var GeographyCard = function GeographyCard(_ref2) {
5993
- var _ref2$subtitle = _ref2.subtitle,
5994
- subtitle = _ref2$subtitle === void 0 ? "Top countries by organic traffic" : _ref2$subtitle;
5995
- 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 : [{
5996
6040
  country: "United States",
5997
6041
  stats: "3,120 · 37%",
5998
6042
  percentage: 37
@@ -6020,7 +6064,15 @@ var GeographyCard = function GeographyCard(_ref2) {
6020
6064
  return /*#__PURE__*/jsx(CardWrapper, {
6021
6065
  title: "Geography insights",
6022
6066
  subtitle: subtitle,
6023
- 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) {
6024
6076
  return /*#__PURE__*/jsxs(Box, {
6025
6077
  sx: {
6026
6078
  display: "flex",
@@ -6506,9 +6558,9 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6506
6558
  })]
6507
6559
  });
6508
6560
  };
6509
- var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref3) {
6510
- var sx = _ref3.sx,
6511
- donorGeographyData = _ref3.donorGeographyData;
6561
+ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref5) {
6562
+ var sx = _ref5.sx,
6563
+ donorGeographyData = _ref5.donorGeographyData;
6512
6564
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || [];
6513
6565
  var data = rawCountries.map(function (item) {
6514
6566
  return {
@@ -7975,74 +8027,263 @@ var PaidSection$1 = /*#__PURE__*/Object.freeze({
7975
8027
  default: PaidSection
7976
8028
  });
7977
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
+ };
7978
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;
7979
8052
  var _ref$apiData = _ref.apiData,
7980
- 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;
7981
8056
  var _useState = useState("Organic Users"),
7982
8057
  _useState2 = _slicedToArray(_useState, 2),
7983
8058
  activeMetric = _useState2[0],
7984
8059
  setActiveMetric = _useState2[1];
7985
- var categories = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
7986
- var metricInfo = {
7987
- "Organic Users": {
7988
- value: "".concat(formatNumber(8420)),
7989
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
7990
- data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
7991
- icon: /*#__PURE__*/jsx(PeopleAltOutlined, {}),
7992
- money: false,
7993
- warning: false,
7994
- error: false
7995
- },
7996
- "Search Clicks": {
7997
- value: "".concat(formatNumber(5842)),
7998
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.netRaisedSub) || "92.3% pass-through",
7999
- data: [1500, 1800, 1600, 2200, 2000, 2400, 2800],
8000
- icon: /*#__PURE__*/jsx(SearchOutlined, {}),
8001
- money: false,
8002
- warning: false,
8003
- error: false
8004
- },
8005
- Donations: {
8006
- value: "".concat(formatNumber(420)),
8007
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8008
- data: [15, 22, 18, 30, 25, 35, 42],
8009
- icon: /*#__PURE__*/jsx(FavoriteOutlined, {}),
8010
- money: false,
8011
- warning: false,
8012
- error: false
8013
- },
8014
- "Conversion Rate": {
8015
- value: "3.1%",
8016
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.avgDonationTrend) || "8.4% vs last month",
8017
- data: [2.5, 2.7, 2.6, 3.1, 3.0, 2.9, 3.1],
8018
- icon: /*#__PURE__*/jsx(Adjust, {}),
8019
- money: false,
8020
- warning: false,
8021
- error: false
8022
- },
8023
- "Revenue raised": {
8024
- value: "$".concat(formatNumber(240398)),
8025
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.roasTrend) || "0.4x vs last month",
8026
- data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
8027
- icon: /*#__PURE__*/jsx(PaidOutlined, {}),
8028
- money: true,
8029
- warning: false,
8030
- error: false
8031
- },
8032
- "Avg donation": {
8033
- value: "$".concat(formatNumber(130.58)),
8034
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8035
- data: [110, 125, 120, 135, 130, 128, 130.58],
8036
- icon: /*#__PURE__*/jsx(PaidOutlined, {}),
8037
- money: true,
8038
- warning: false,
8039
- error: false
8040
- }
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);
8041
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]);
8042
8285
  var renderCard = function renderCard(title) {
8043
- return /*#__PURE__*/jsx(MetricCard
8044
- // key={title}
8045
- , {
8286
+ return /*#__PURE__*/jsx(MetricCard, {
8046
8287
  title: title,
8047
8288
  value: metricInfo[title].money ? metricInfo[title].value : metricInfo[title].value,
8048
8289
  caption: metricInfo[title].subValue,
@@ -8056,31 +8297,16 @@ var OrganicSection = function OrganicSection(_ref) {
8056
8297
  border: "2px solid #ef4444",
8057
8298
  bgcolor: "#fffafa"
8058
8299
  } : {}
8059
- })
8060
- // <DisplayCard
8061
- // key={title}
8062
- // title={title}
8063
- // value={metricInfo[title].value}
8064
- // subValue={metricInfo[title].subValue}
8065
- // icon={metricInfo[title].icon}
8066
- // onClick={() => setActiveMetric(title)}
8067
- // isActive={activeMetric === title}
8068
- // sx={{
8069
- // // border:
8070
- // // activeMetric === title
8071
- // // ? "2px solid rgb(99, 99, 230)"
8072
- // // : "2px solid #f0f0f0",
8073
- // }}
8074
- // />
8075
- ;
8300
+ });
8076
8301
  };
8077
- 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;
8078
8304
  var mainChart = {
8079
8305
  label: activeMetric,
8080
8306
  value: selectedInfo.value,
8081
8307
  trend: selectedInfo.subValue,
8082
8308
  data: selectedInfo.data,
8083
- categories: categories
8309
+ categories: chartCategories
8084
8310
  };
8085
8311
  return /*#__PURE__*/jsxs(Fragment, {
8086
8312
  children: [/*#__PURE__*/jsx(Box, {
@@ -8113,7 +8339,9 @@ var OrganicSection = function OrganicSection(_ref) {
8113
8339
  item: true,
8114
8340
  xs: 12,
8115
8341
  md: 6,
8116
- children: /*#__PURE__*/jsx(LandingPagesCard, {})
8342
+ children: /*#__PURE__*/jsx(LandingPagesCard, {
8343
+ data: landingPagesData
8344
+ })
8117
8345
  }), /*#__PURE__*/jsx(Grid, {
8118
8346
  item: true,
8119
8347
  xs: 12,
@@ -8121,12 +8349,12 @@ var OrganicSection = function OrganicSection(_ref) {
8121
8349
  children: /*#__PURE__*/jsx(DonorMixCard, {
8122
8350
  title: "Source breakdown",
8123
8351
  subtitle: "Where organic visitors come from",
8124
- series: [40.8, 35.1, 14.2, 3.3],
8125
- labels: ["Meta Ads", "Google Ads", "TikTok", "Snapchat"],
8126
- colors: ["#4267B2", "#4285F4", "#06510bff", "#f2b61dff"],
8127
- centerLabel: "total spend",
8128
- centerValue: "$8.3K",
8129
- 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 : [{
8130
8358
  label: "Google Search",
8131
8359
  val: "40.8%",
8132
8360
  color: "#4267B2"
@@ -8152,13 +8380,17 @@ var OrganicSection = function OrganicSection(_ref) {
8152
8380
  item: true,
8153
8381
  xs: 12,
8154
8382
  md: 6,
8155
- 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
+ })
8156
8387
  }), /*#__PURE__*/jsx(Grid, {
8157
8388
  item: true,
8158
8389
  xs: 12,
8159
8390
  md: 6,
8160
8391
  children: /*#__PURE__*/jsx(GeographyCard, {
8161
- subtitle: "Top countries by organic traffic"
8392
+ subtitle: "Top countries by organic traffic",
8393
+ data: geographyData
8162
8394
  })
8163
8395
  })]
8164
8396
  })]