@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.cjs.js CHANGED
@@ -904,6 +904,17 @@ var W = 794;
904
904
  var H = 1123;
905
905
  var MX = 32; // horizontal margin
906
906
  var CW = W - MX * 2; // 730 px usable width
907
+ var THEME = {
908
+ pageBg: "#F8FAFC",
909
+ panelBg: "#FFFFFF",
910
+ panelBorder: "#DDE3EA",
911
+ kpiBg: "#F6F8FF",
912
+ kpiBorder: "#D9E0FF",
913
+ tableHeadBg: "#EEF2FF",
914
+ tableAltBg: "#F8FAFF",
915
+ muted: "#94A3B8",
916
+ text: "#111827"
917
+ };
907
918
 
908
919
  // ─── Number helpers ───────────────────────────────────────────────────────────
909
920
  var d$ = function d$(v) {
@@ -997,7 +1008,7 @@ var LineChart = function LineChart(_ref2) {
997
1008
  return /*#__PURE__*/jsxRuntime.jsx("div", {
998
1009
  style: {
999
1010
  height: height,
1000
- background: "#F9FAFB",
1011
+ background: THEME.tableAltBg,
1001
1012
  borderRadius: 6
1002
1013
  }
1003
1014
  });
@@ -1040,14 +1051,14 @@ var LineChart = function LineChart(_ref2) {
1040
1051
  y1: y,
1041
1052
  x2: width - PR,
1042
1053
  y2: y,
1043
- stroke: "#F3F4F6",
1054
+ stroke: "#E5EAF1",
1044
1055
  strokeWidth: 1
1045
1056
  }), /*#__PURE__*/jsxRuntime.jsx("text", {
1046
1057
  x: PL - 4,
1047
1058
  y: y + 3.5,
1048
1059
  textAnchor: "end",
1049
1060
  fontSize: 9,
1050
- fill: "#9CA3AF",
1061
+ fill: THEME.muted,
1051
1062
  children: label
1052
1063
  })]
1053
1064
  }, i);
@@ -1073,7 +1084,7 @@ var LineChart = function LineChart(_ref2) {
1073
1084
  y: height - 5,
1074
1085
  textAnchor: "middle",
1075
1086
  fontSize: 9,
1076
- fill: "#9CA3AF",
1087
+ fill: THEME.muted,
1077
1088
  children: label
1078
1089
  }, i);
1079
1090
  })]
@@ -1107,7 +1118,7 @@ var Donut = function Donut(_ref3) {
1107
1118
  cy: cy,
1108
1119
  r: r,
1109
1120
  fill: "none",
1110
- stroke: "#E5E7EB",
1121
+ stroke: "#E6EBF5",
1111
1122
  strokeWidth: 12
1112
1123
  }), segments.map(function (seg, i) {
1113
1124
  var dash = seg.value / total * circ;
@@ -1138,7 +1149,7 @@ var Donut = function Donut(_ref3) {
1138
1149
  y: cy + 13,
1139
1150
  textAnchor: "middle",
1140
1151
  fontSize: 9,
1141
- fill: "#6B7280",
1152
+ fill: THEME.muted,
1142
1153
  children: centerLabel
1143
1154
  })]
1144
1155
  });
@@ -1152,7 +1163,7 @@ var Divider = function Divider(_ref4) {
1152
1163
  mb = _ref4$mb === void 0 ? 0 : _ref4$mb;
1153
1164
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1154
1165
  style: {
1155
- borderTop: "1px solid #E5E7EB",
1166
+ borderTop: "1px solid #E5EAF1",
1156
1167
  marginTop: mt,
1157
1168
  marginBottom: mb
1158
1169
  }
@@ -1167,13 +1178,14 @@ var Panel = function Panel(_ref5) {
1167
1178
  style = _ref5$style === void 0 ? {} : _ref5$style;
1168
1179
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1169
1180
  style: _objectSpread2({
1170
- border: "1px solid #E5E7EB",
1181
+ border: "1px solid ".concat(THEME.panelBorder),
1171
1182
  borderRadius: 8,
1172
- background: "#fff",
1183
+ background: THEME.panelBg,
1173
1184
  padding: 12,
1174
1185
  display: "flex",
1175
1186
  flexDirection: "column",
1176
- boxSizing: "border-box"
1187
+ boxSizing: "border-box",
1188
+ boxShadow: "0 1px 0 rgba(15,23,42,0.03)"
1177
1189
  }, style),
1178
1190
  children: [(title || subtitle || action) && /*#__PURE__*/jsxRuntime.jsxs("div", {
1179
1191
  style: {
@@ -1188,14 +1200,14 @@ var Panel = function Panel(_ref5) {
1188
1200
  style: {
1189
1201
  fontSize: 12,
1190
1202
  fontWeight: 700,
1191
- color: "#111827",
1203
+ color: THEME.text,
1192
1204
  lineHeight: 1.2
1193
1205
  },
1194
1206
  children: title
1195
1207
  }), subtitle && /*#__PURE__*/jsxRuntime.jsx("div", {
1196
1208
  style: {
1197
1209
  fontSize: 9.5,
1198
- color: "#9CA3AF",
1210
+ color: THEME.muted,
1199
1211
  marginTop: 2
1200
1212
  },
1201
1213
  children: subtitle
@@ -1222,12 +1234,13 @@ var MiniTable = function MiniTable(_ref6) {
1222
1234
  width: "100%",
1223
1235
  borderCollapse: "collapse",
1224
1236
  fontSize: 9.5,
1225
- tableLayout: "fixed"
1237
+ tableLayout: "fixed",
1238
+ background: "#fff"
1226
1239
  },
1227
1240
  children: [/*#__PURE__*/jsxRuntime.jsx("thead", {
1228
1241
  children: /*#__PURE__*/jsxRuntime.jsx("tr", {
1229
1242
  style: {
1230
- background: "#F9FAFB"
1243
+ background: THEME.tableHeadBg
1231
1244
  },
1232
1245
  children: head.map(function (h, i) {
1233
1246
  return /*#__PURE__*/jsxRuntime.jsx("th", {
@@ -1237,8 +1250,8 @@ var MiniTable = function MiniTable(_ref6) {
1237
1250
  fontWeight: 700,
1238
1251
  fontSize: 8.5,
1239
1252
  letterSpacing: "0.3px",
1240
- color: "#6B7280",
1241
- borderBottom: "1px solid #E5E7EB"
1253
+ color: "#64748B",
1254
+ borderBottom: "1px solid #DDE3EA"
1242
1255
  },
1243
1256
  children: h
1244
1257
  }, i);
@@ -1248,15 +1261,15 @@ var MiniTable = function MiniTable(_ref6) {
1248
1261
  children: rows.map(function (row, ri) {
1249
1262
  return /*#__PURE__*/jsxRuntime.jsx("tr", {
1250
1263
  style: {
1251
- background: ri % 2 === 1 ? "#F9FAFB" : "#fff"
1264
+ background: ri % 2 === 1 ? THEME.tableAltBg : "#fff"
1252
1265
  },
1253
1266
  children: row.map(function (cell, ci) {
1254
1267
  return /*#__PURE__*/jsxRuntime.jsx("td", {
1255
1268
  style: {
1256
1269
  padding: "4px 6px",
1257
1270
  textAlign: ci === 0 ? "left" : "right",
1258
- color: "#374151",
1259
- borderBottom: ri < rows.length - 1 ? "1px solid #F3F4F6" : "none"
1271
+ color: "#334155",
1272
+ borderBottom: ri < rows.length - 1 ? "1px solid #EEF2F7" : "none"
1260
1273
  },
1261
1274
  children: cell
1262
1275
  }, ci);
@@ -1274,10 +1287,10 @@ var KpiCard = function KpiCard(_ref7) {
1274
1287
  var neg = "".concat(trend).trim().startsWith("-");
1275
1288
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1276
1289
  style: {
1277
- border: "1px solid #E5E7EB",
1290
+ border: "1px solid ".concat(THEME.kpiBorder),
1278
1291
  borderRadius: 8,
1279
1292
  padding: "10px 12px 9px",
1280
- background: "#fff",
1293
+ background: THEME.kpiBg,
1281
1294
  width: "100%",
1282
1295
  minWidth: 0,
1283
1296
  boxSizing: "border-box",
@@ -1290,7 +1303,7 @@ var KpiCard = function KpiCard(_ref7) {
1290
1303
  fontSize: 8,
1291
1304
  fontWeight: 700,
1292
1305
  letterSpacing: "0.7px",
1293
- color: "#6B7280",
1306
+ color: "#64748B",
1294
1307
  textTransform: "uppercase"
1295
1308
  },
1296
1309
  children: title
@@ -1298,7 +1311,7 @@ var KpiCard = function KpiCard(_ref7) {
1298
1311
  style: {
1299
1312
  fontSize: 17,
1300
1313
  fontWeight: 800,
1301
- color: "#111827",
1314
+ color: THEME.text,
1302
1315
  lineHeight: 1.1,
1303
1316
  marginTop: 2
1304
1317
  },
@@ -1313,7 +1326,7 @@ var KpiCard = function KpiCard(_ref7) {
1313
1326
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
1314
1327
  style: {
1315
1328
  fontSize: 8.5,
1316
- color: "#9CA3AF",
1329
+ color: THEME.muted,
1317
1330
  lineHeight: 1.4
1318
1331
  },
1319
1332
  children: detail
@@ -1332,7 +1345,7 @@ var StatPair = function StatPair(_ref8) {
1332
1345
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1333
1346
  style: {
1334
1347
  fontSize: 8.5,
1335
- color: "#9CA3AF",
1348
+ color: THEME.muted,
1336
1349
  marginBottom: 1
1337
1350
  },
1338
1351
  children: label
@@ -1368,7 +1381,8 @@ var PageHeader = function PageHeader(_ref9) {
1368
1381
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1369
1382
  style: {
1370
1383
  padding: "22px ".concat(MX, "px 12px"),
1371
- borderBottom: "1px solid #E5E7EB",
1384
+ borderBottom: "1px solid #DEE5EF",
1385
+ background: "#FFFFFF",
1372
1386
  flexShrink: 0
1373
1387
  },
1374
1388
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -1387,7 +1401,7 @@ var PageHeader = function PageHeader(_ref9) {
1387
1401
  style: {
1388
1402
  fontSize: 20,
1389
1403
  fontWeight: 800,
1390
- color: "#111827",
1404
+ color: THEME.text,
1391
1405
  letterSpacing: "-0.5px"
1392
1406
  },
1393
1407
  children: "Madinah"
@@ -1396,7 +1410,7 @@ var PageHeader = function PageHeader(_ref9) {
1396
1410
  fontSize: 8.5,
1397
1411
  fontWeight: 700,
1398
1412
  letterSpacing: "1.5px",
1399
- color: "#9CA3AF",
1413
+ color: "#94A3B8",
1400
1414
  textTransform: "uppercase"
1401
1415
  },
1402
1416
  children: "PERFORMANCE REPORT"
@@ -1407,7 +1421,7 @@ var PageHeader = function PageHeader(_ref9) {
1407
1421
  marginTop: 8,
1408
1422
  fontSize: 13.5,
1409
1423
  fontWeight: 700,
1410
- color: "#111827"
1424
+ color: THEME.text
1411
1425
  },
1412
1426
  children: "Dashboard overview \u2014 Overall"
1413
1427
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -1420,13 +1434,13 @@ var PageHeader = function PageHeader(_ref9) {
1420
1434
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
1421
1435
  style: {
1422
1436
  fontSize: 10.5,
1423
- color: "#374151"
1437
+ color: "#334155"
1424
1438
  },
1425
1439
  children: dateLabel
1426
1440
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1427
1441
  style: {
1428
1442
  fontSize: 9.5,
1429
- color: "#9CA3AF",
1443
+ color: THEME.muted,
1430
1444
  marginTop: 1
1431
1445
  },
1432
1446
  children: ["30-day window \xB7 Generated ", generatedLabel]
@@ -1434,7 +1448,7 @@ var PageHeader = function PageHeader(_ref9) {
1434
1448
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1435
1449
  style: {
1436
1450
  fontSize: 9,
1437
- color: "#9CA3AF",
1451
+ color: THEME.muted,
1438
1452
  textAlign: "right",
1439
1453
  alignSelf: "flex-end"
1440
1454
  },
@@ -1445,8 +1459,8 @@ var PageHeader = function PageHeader(_ref9) {
1445
1459
  marginTop: 7,
1446
1460
  display: "inline-flex",
1447
1461
  gap: 5,
1448
- background: "#F9FAFB",
1449
- border: "1px solid #E5E7EB",
1462
+ background: "#EEF2FF",
1463
+ border: "1px solid #D7DEFF",
1450
1464
  borderRadius: 4,
1451
1465
  padding: "3px 9px",
1452
1466
  fontSize: 8.5
@@ -1473,14 +1487,15 @@ var PageFooter = function PageFooter(_ref0) {
1473
1487
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1474
1488
  style: {
1475
1489
  padding: "7px ".concat(MX, "px"),
1476
- borderTop: "1px solid #E5E7EB",
1490
+ borderTop: "1px solid #DEE5EF",
1491
+ background: "#FFFFFF",
1477
1492
  marginTop: "auto",
1478
1493
  flexShrink: 0
1479
1494
  },
1480
1495
  children: /*#__PURE__*/jsxRuntime.jsxs("span", {
1481
1496
  style: {
1482
1497
  fontSize: 8,
1483
- color: "#9CA3AF"
1498
+ color: THEME.muted
1484
1499
  },
1485
1500
  children: ["Confidential \xB7 Generated by Dashboard \xB7 ", generatedLabel, " \xA0\xA0 Page ", page, " of 2 \xB7 madinah.com"]
1486
1501
  })
@@ -1651,7 +1666,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1651
1666
  style: {
1652
1667
  width: W,
1653
1668
  height: H,
1654
- background: "#fff",
1669
+ background: THEME.pageBg,
1655
1670
  display: "flex",
1656
1671
  flexDirection: "column",
1657
1672
  fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
@@ -1818,7 +1833,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1818
1833
  style: {
1819
1834
  width: W,
1820
1835
  height: H,
1821
- background: "#fff",
1836
+ background: THEME.pageBg,
1822
1837
  display: "flex",
1823
1838
  flexDirection: "column",
1824
1839
  fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
@@ -2677,7 +2692,8 @@ var NewOverview = function NewOverview(_ref) {
2677
2692
  }), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
2678
2693
  sx: {},
2679
2694
  children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection$2, {
2680
- apiData: apiData
2695
+ apiData: apiData,
2696
+ dateName: dateName
2681
2697
  })
2682
2698
  }), activeSection === "Email" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
2683
2699
  sx: {},
@@ -5681,8 +5697,10 @@ var CardWrapper = function CardWrapper(_ref) {
5681
5697
  })
5682
5698
  });
5683
5699
  };
5684
- var LandingPagesCard = function LandingPagesCard() {
5685
- 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 : [{
5686
5704
  page: "/yemen-orphans-appeal",
5687
5705
  visitors: "1,840",
5688
5706
  donations: "32",
@@ -5772,7 +5790,15 @@ var LandingPagesCard = function LandingPagesCard() {
5772
5790
  },
5773
5791
  children: "Conv. rate"
5774
5792
  })]
5775
- }), 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) {
5776
5802
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5777
5803
  sx: {
5778
5804
  display: "grid",
@@ -5787,8 +5813,12 @@ var LandingPagesCard = function LandingPagesCard() {
5787
5813
  fontSize: "13px",
5788
5814
  fontWeight: 700,
5789
5815
  color: "#000",
5790
- textAlign: "left"
5816
+ textAlign: "left",
5817
+ overflow: "hidden",
5818
+ textOverflow: "ellipsis",
5819
+ whiteSpace: "nowrap"
5791
5820
  },
5821
+ title: item.page,
5792
5822
  children: item.page
5793
5823
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5794
5824
  sx: {
@@ -5827,8 +5857,11 @@ var LandingPagesCard = function LandingPagesCard() {
5827
5857
  })]
5828
5858
  });
5829
5859
  };
5830
- var KeywordsCard = function KeywordsCard() {
5831
- 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 : [{
5832
5865
  keyword: "zakat calculator",
5833
5866
  clicks: "1,240",
5834
5867
  rank: "#2.1",
@@ -5859,142 +5892,153 @@ var KeywordsCard = function KeywordsCard() {
5859
5892
  trend: "Improving",
5860
5893
  trendType: "up"
5861
5894
  }];
5862
- return /*#__PURE__*/jsxRuntime.jsxs(CardWrapper, {
5895
+ return /*#__PURE__*/jsxRuntime.jsx(CardWrapper, {
5863
5896
  title: "Top organic keywords",
5864
5897
  subtitle: "Search terms ranked by clicks \xB7 last 30 days",
5865
- children: [/*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5898
+ children: !available || data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5866
5899
  sx: {
5867
- display: "grid",
5868
- gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5869
- gap: 2,
5870
- pb: 1,
5871
- borderBottom: "1px solid #f0f0f0"
5900
+ fontSize: "13px",
5901
+ color: "rgba(0, 0, 0, 0.45)",
5902
+ py: 2,
5903
+ textAlign: "left"
5872
5904
  },
5873
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5874
- sx: {
5875
- fontSize: "12px",
5876
- color: "rgba(0, 0, 0, 0.4)",
5877
- fontWeight: 500,
5878
- textAlign: "left"
5879
- },
5880
- children: "Keyword"
5881
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5882
- sx: {
5883
- fontSize: "12px",
5884
- color: "rgba(0, 0, 0, 0.4)",
5885
- fontWeight: 500,
5886
- textAlign: "left"
5887
- },
5888
- children: "Clicks"
5889
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5890
- sx: {
5891
- fontSize: "12px",
5892
- color: "rgba(0, 0, 0, 0.4)",
5893
- fontWeight: 500,
5894
- textAlign: "left"
5895
- },
5896
- children: "Position"
5897
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5898
- sx: {
5899
- fontSize: "12px",
5900
- color: "rgba(0, 0, 0, 0.4)",
5901
- fontWeight: 500,
5902
- textAlign: "left"
5903
- },
5904
- children: "Trend"
5905
- })]
5906
- }), data.map(function (item, index) {
5907
- 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, {
5908
5908
  sx: {
5909
5909
  display: "grid",
5910
5910
  gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5911
5911
  gap: 2,
5912
- // py: 0.5,
5913
- alignItems: "center",
5914
- borderBottom: index === data.length - 1 ? "none" : "1px solid #f5f5f5"
5912
+ pb: 1,
5913
+ borderBottom: "1px solid #f0f0f0"
5915
5914
  },
5916
5915
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5917
5916
  sx: {
5918
- fontSize: "13px",
5919
- fontWeight: 700,
5920
- color: "#000",
5917
+ fontSize: "12px",
5918
+ color: "rgba(0, 0, 0, 0.4)",
5919
+ fontWeight: 500,
5921
5920
  textAlign: "left"
5922
5921
  },
5923
- children: item.keyword
5922
+ children: "Keyword"
5924
5923
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5925
5924
  sx: {
5926
- fontSize: "13px",
5927
- color: "rgba(0, 0, 0, 0.6)",
5925
+ fontSize: "12px",
5926
+ color: "rgba(0, 0, 0, 0.4)",
5928
5927
  fontWeight: 500,
5929
5928
  textAlign: "left"
5930
5929
  },
5931
- children: item.clicks
5932
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5930
+ children: "Clicks"
5931
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5933
5932
  sx: {
5933
+ fontSize: "12px",
5934
+ color: "rgba(0, 0, 0, 0.4)",
5935
+ fontWeight: 500,
5934
5936
  textAlign: "left"
5935
5937
  },
5936
- children: /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5937
- sx: {
5938
- width: "40px",
5939
- bgcolor: "#ebf2ffb1",
5940
- color: "#3431e4",
5941
- // px: 0.5,
5942
- p: 0.5,
5943
- borderRadius: "100px",
5944
- fontSize: "11px",
5945
- fontWeight: 700,
5946
- textAlign: "center",
5947
- minWidth: "45px"
5948
- },
5949
- children: item.rank
5950
- })
5951
- }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
5938
+ children: "Position"
5939
+ }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5952
5940
  sx: {
5953
- display: "flex",
5941
+ fontSize: "12px",
5942
+ color: "rgba(0, 0, 0, 0.4)",
5943
+ fontWeight: 500,
5944
+ textAlign: "left"
5945
+ },
5946
+ children: "Trend"
5947
+ })]
5948
+ }), data.map(function (item, index) {
5949
+ return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
5950
+ sx: {
5951
+ display: "grid",
5952
+ gridTemplateColumns: "2.5fr 1fr 1fr 1fr",
5953
+ gap: 2,
5954
+ // py: 0.5,
5954
5955
  alignItems: "center",
5955
- justifyContent: "flex-start",
5956
- gap: 0.5
5956
+ borderBottom: index === data.length - 1 ? "none" : "1px solid #f5f5f5"
5957
5957
  },
5958
- children: item.trendType === "up" ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5959
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5960
- sx: {
5961
- fontSize: "14px",
5962
- color: "#22C55E"
5963
- },
5964
- children: "\u25B2"
5965
- }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5966
- sx: {
5967
- fontSize: "12px",
5968
- color: "#22C55E",
5969
- fontWeight: 700
5970
- },
5971
- children: "Improving"
5972
- })]
5973
- }) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
5974
- children: [/*#__PURE__*/jsxRuntime.jsx(material.Typography, {
5975
- sx: {
5976
- fontSize: "14px",
5977
- color: "#EF4444"
5978
- },
5979
- children: "\u25BC"
5980
- }), /*#__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, {
5981
5979
  sx: {
5982
- fontSize: "12px",
5983
- color: "#EF4444",
5984
- 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"
5985
5990
  },
5986
- children: "Declining"
5987
- })]
5988
- })
5989
- })]
5990
- }, index);
5991
- })]
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
+ })
5992
6035
  });
5993
6036
  };
5994
- var GeographyCard = function GeographyCard(_ref2) {
5995
- var _ref2$subtitle = _ref2.subtitle,
5996
- subtitle = _ref2$subtitle === void 0 ? "Top countries by organic traffic" : _ref2$subtitle;
5997
- 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 : [{
5998
6042
  country: "United States",
5999
6043
  stats: "3,120 · 37%",
6000
6044
  percentage: 37
@@ -6022,7 +6066,15 @@ var GeographyCard = function GeographyCard(_ref2) {
6022
6066
  return /*#__PURE__*/jsxRuntime.jsx(CardWrapper, {
6023
6067
  title: "Geography insights",
6024
6068
  subtitle: subtitle,
6025
- 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) {
6026
6078
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
6027
6079
  sx: {
6028
6080
  display: "flex",
@@ -6508,9 +6560,9 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6508
6560
  })]
6509
6561
  });
6510
6562
  };
6511
- var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref3) {
6512
- var sx = _ref3.sx,
6513
- donorGeographyData = _ref3.donorGeographyData;
6563
+ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref5) {
6564
+ var sx = _ref5.sx,
6565
+ donorGeographyData = _ref5.donorGeographyData;
6514
6566
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || [];
6515
6567
  var data = rawCountries.map(function (item) {
6516
6568
  return {
@@ -7977,74 +8029,263 @@ var PaidSection$1 = /*#__PURE__*/Object.freeze({
7977
8029
  default: PaidSection
7978
8030
  });
7979
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
+ };
7980
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;
7981
8054
  var _ref$apiData = _ref.apiData,
7982
- 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;
7983
8058
  var _useState = React.useState("Organic Users"),
7984
8059
  _useState2 = _slicedToArray(_useState, 2),
7985
8060
  activeMetric = _useState2[0],
7986
8061
  setActiveMetric = _useState2[1];
7987
- var categories = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
7988
- var metricInfo = {
7989
- "Organic Users": {
7990
- value: "".concat(formatNumber(8420)),
7991
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
7992
- data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
7993
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
7994
- money: false,
7995
- warning: false,
7996
- error: false
7997
- },
7998
- "Search Clicks": {
7999
- value: "".concat(formatNumber(5842)),
8000
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.netRaisedSub) || "92.3% pass-through",
8001
- data: [1500, 1800, 1600, 2200, 2000, 2400, 2800],
8002
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8003
- money: false,
8004
- warning: false,
8005
- error: false
8006
- },
8007
- Donations: {
8008
- value: "".concat(formatNumber(420)),
8009
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8010
- data: [15, 22, 18, 30, 25, 35, 42],
8011
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8012
- money: false,
8013
- warning: false,
8014
- error: false
8015
- },
8016
- "Conversion Rate": {
8017
- value: "3.1%",
8018
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.avgDonationTrend) || "8.4% vs last month",
8019
- data: [2.5, 2.7, 2.6, 3.1, 3.0, 2.9, 3.1],
8020
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8021
- money: false,
8022
- warning: false,
8023
- error: false
8024
- },
8025
- "Revenue raised": {
8026
- value: "$".concat(formatNumber(240398)),
8027
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.roasTrend) || "0.4x vs last month",
8028
- data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
8029
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8030
- money: true,
8031
- warning: false,
8032
- error: false
8033
- },
8034
- "Avg donation": {
8035
- value: "$".concat(formatNumber(130.58)),
8036
- subValue: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaisedTrend) || "18% vs last month",
8037
- data: [110, 125, 120, 135, 130, 128, 130.58],
8038
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8039
- money: true,
8040
- warning: false,
8041
- error: false
8042
- }
8062
+ var overview = (apiData === null || apiData === void 0 ? void 0 : apiData.overview) || {};
8063
+ var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
8064
+ var hasOrganicOverview = Boolean(apiData === null || apiData === void 0 ? void 0 : apiData.overview);
8065
+ var organicUsersSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.organicUsers);
8066
+ var donationsSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.totalDonations);
8067
+ var conversionSeries = mapTimeSeries(apiData === null || apiData === void 0 ? void 0 : apiData.conversionRate);
8068
+ var fallbackCategories = organicUsersSeries.categories.length ? organicUsersSeries.categories : ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
8069
+ var growthCaption = function growthCaption(key) {
8070
+ return formatGrowth(growth[key], dateName);
8043
8071
  };
8072
+ var metricInfo = React.useMemo(function () {
8073
+ var _overview$totalRevenu2, _overview$overallAVGD2, _overview$organicUser, _apiData$topOrganicKe, _overview$totalDonati, _overview$conversionR, _overview$totalRevenu3, _overview$overallAVGD3;
8074
+ if (!hasOrganicOverview) {
8075
+ return {
8076
+ "Organic Users": {
8077
+ value: "".concat(formatNumber(8420)),
8078
+ subValue: "18% vs last month",
8079
+ data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
8080
+ categories: fallbackCategories,
8081
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8082
+ money: false,
8083
+ warning: false,
8084
+ error: false
8085
+ },
8086
+ "Search Clicks": {
8087
+ value: "".concat(formatNumber(5842)),
8088
+ subValue: "92.3% pass-through",
8089
+ data: [1500, 1800, 1600, 2200, 2000, 2400, 2800],
8090
+ categories: fallbackCategories,
8091
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8092
+ money: false,
8093
+ warning: false,
8094
+ error: false
8095
+ },
8096
+ Donations: {
8097
+ value: "".concat(formatNumber(420)),
8098
+ subValue: "18% vs last month",
8099
+ data: [15, 22, 18, 30, 25, 35, 42],
8100
+ categories: fallbackCategories,
8101
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8102
+ money: false,
8103
+ warning: false,
8104
+ error: false
8105
+ },
8106
+ "Conversion Rate": {
8107
+ value: "3.1%",
8108
+ subValue: "8.4% vs last month",
8109
+ data: [2.5, 2.7, 2.6, 3.1, 3.0, 2.9, 3.1],
8110
+ categories: fallbackCategories,
8111
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8112
+ money: false,
8113
+ warning: false,
8114
+ error: false
8115
+ },
8116
+ "Revenue raised": {
8117
+ value: "$".concat(formatNumber(240398)),
8118
+ subValue: "0.4x vs last month",
8119
+ data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
8120
+ categories: fallbackCategories,
8121
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8122
+ money: true,
8123
+ warning: false,
8124
+ error: false
8125
+ },
8126
+ "Avg donation": {
8127
+ value: "$".concat(formatNumber(130.58)),
8128
+ subValue: "18% vs last month",
8129
+ data: [110, 125, 120, 135, 130, 128, 130.58],
8130
+ categories: fallbackCategories,
8131
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8132
+ money: true,
8133
+ warning: false,
8134
+ error: false
8135
+ }
8136
+ };
8137
+ }
8138
+ var revenueChartData = organicUsersSeries.data.length > 0 ? organicUsersSeries.data.map(function () {
8139
+ var _overview$totalRevenu;
8140
+ return (_overview$totalRevenu = overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 0;
8141
+ }) : [(_overview$totalRevenu2 = overview.totalRevenue) !== null && _overview$totalRevenu2 !== void 0 ? _overview$totalRevenu2 : 0];
8142
+ var avgChartData = organicUsersSeries.data.length > 0 ? organicUsersSeries.data.map(function () {
8143
+ var _overview$overallAVGD;
8144
+ return (_overview$overallAVGD = overview.overallAVGDonations) !== null && _overview$overallAVGD !== void 0 ? _overview$overallAVGD : 0;
8145
+ }) : [(_overview$overallAVGD2 = overview.overallAVGDonations) !== null && _overview$overallAVGD2 !== void 0 ? _overview$overallAVGD2 : 0];
8146
+ return {
8147
+ "Organic Users": {
8148
+ value: formatNumber((_overview$organicUser = overview.organicUsers) !== null && _overview$organicUser !== void 0 ? _overview$organicUser : 0),
8149
+ subValue: growthCaption("organicUsers"),
8150
+ data: organicUsersSeries.data,
8151
+ categories: organicUsersSeries.categories,
8152
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PeopleAltOutlined, {}),
8153
+ money: false,
8154
+ warning: false,
8155
+ error: false
8156
+ },
8157
+ "Search Clicks": {
8158
+ value: "—",
8159
+ subValue: apiData !== null && apiData !== void 0 && (_apiData$topOrganicKe = apiData.topOrganicKeywords) !== null && _apiData$topOrganicKe !== void 0 && _apiData$topOrganicKe.available ? "From organic search" : "Keyword tracking unavailable",
8160
+ data: organicUsersSeries.data.map(function () {
8161
+ return 0;
8162
+ }),
8163
+ categories: organicUsersSeries.categories,
8164
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.SearchOutlined, {}),
8165
+ money: false,
8166
+ warning: false,
8167
+ error: false
8168
+ },
8169
+ Donations: {
8170
+ value: formatNumber((_overview$totalDonati = overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 0),
8171
+ subValue: growthCaption("totalDonations"),
8172
+ data: donationsSeries.data,
8173
+ categories: donationsSeries.categories,
8174
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.FavoriteOutlined, {}),
8175
+ money: false,
8176
+ warning: false,
8177
+ error: false
8178
+ },
8179
+ "Conversion Rate": {
8180
+ value: "".concat(Number((_overview$conversionR = overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 0).toFixed(2), "%"),
8181
+ subValue: growthCaption("conversionRate"),
8182
+ data: conversionSeries.data,
8183
+ categories: conversionSeries.categories,
8184
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.Adjust, {}),
8185
+ money: false,
8186
+ warning: false,
8187
+ error: false
8188
+ },
8189
+ "Revenue raised": {
8190
+ value: "$".concat(formatNumber((_overview$totalRevenu3 = overview.totalRevenue) !== null && _overview$totalRevenu3 !== void 0 ? _overview$totalRevenu3 : 0)),
8191
+ subValue: growthCaption("totalRevenue"),
8192
+ data: revenueChartData,
8193
+ categories: organicUsersSeries.categories,
8194
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8195
+ money: true,
8196
+ warning: false,
8197
+ error: false
8198
+ },
8199
+ "Avg donation": {
8200
+ value: "$".concat(formatNumber((_overview$overallAVGD3 = overview.overallAVGDonations) !== null && _overview$overallAVGD3 !== void 0 ? _overview$overallAVGD3 : 0)),
8201
+ subValue: growthCaption("overallAVGDonations"),
8202
+ data: avgChartData,
8203
+ categories: organicUsersSeries.categories,
8204
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
8205
+ money: true,
8206
+ warning: false,
8207
+ error: false
8208
+ }
8209
+ };
8210
+ }, [apiData === null || apiData === void 0 || (_apiData$topOrganicKe2 = apiData.topOrganicKeywords) === null || _apiData$topOrganicKe2 === void 0 ? void 0 : _apiData$topOrganicKe2.available, conversionSeries, donationsSeries, fallbackCategories, growth, hasOrganicOverview, organicUsersSeries, overview, dateName]);
8211
+ var landingPagesData = React.useMemo(function () {
8212
+ var pages = apiData === null || apiData === void 0 ? void 0 : apiData.topLandingPages;
8213
+ if (!hasOrganicOverview) return null;
8214
+ if (!Array.isArray(pages) || pages.length === 0) return [];
8215
+ return pages.map(function (item) {
8216
+ var _item$visitors, _item$donations, _item$revenue, _item$conversionRate;
8217
+ return {
8218
+ page: item.page,
8219
+ visitors: formatNumber((_item$visitors = item.visitors) !== null && _item$visitors !== void 0 ? _item$visitors : 0),
8220
+ donations: formatNumber((_item$donations = item.donations) !== null && _item$donations !== void 0 ? _item$donations : 0),
8221
+ revenue: "$".concat(formatNumber((_item$revenue = item.revenue) !== null && _item$revenue !== void 0 ? _item$revenue : 0)),
8222
+ cvr: "".concat(Number((_item$conversionRate = item.conversionRate) !== null && _item$conversionRate !== void 0 ? _item$conversionRate : 0).toFixed(2), "%")
8223
+ };
8224
+ });
8225
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topLandingPages, hasOrganicOverview]);
8226
+ var keywordsData = React.useMemo(function () {
8227
+ var keywords = apiData === null || apiData === void 0 ? void 0 : apiData.topOrganicKeywords;
8228
+ if (!hasOrganicOverview) return null;
8229
+ if (!(keywords !== null && keywords !== void 0 && keywords.available) || !Array.isArray(keywords.data) || keywords.data.length === 0) {
8230
+ return [];
8231
+ }
8232
+ return keywords.data.map(function (item) {
8233
+ var _item$clicks, _item$rank, _item$trend, _item$trendType;
8234
+ return {
8235
+ keyword: item.keyword,
8236
+ clicks: formatNumber((_item$clicks = item.clicks) !== null && _item$clicks !== void 0 ? _item$clicks : 0),
8237
+ rank: (_item$rank = item.rank) !== null && _item$rank !== void 0 ? _item$rank : "—",
8238
+ trend: (_item$trend = item.trend) !== null && _item$trend !== void 0 ? _item$trend : "—",
8239
+ trendType: (_item$trendType = item.trendType) !== null && _item$trendType !== void 0 ? _item$trendType : "up"
8240
+ };
8241
+ });
8242
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topOrganicKeywords, hasOrganicOverview]);
8243
+ var geographyData = React.useMemo(function () {
8244
+ var _apiData$geographyIns;
8245
+ var countries = apiData === null || apiData === void 0 || (_apiData$geographyIns = apiData.geographyInsights) === null || _apiData$geographyIns === void 0 ? void 0 : _apiData$geographyIns.countries;
8246
+ if (!hasOrganicOverview) return null;
8247
+ if (!Array.isArray(countries) || countries.length === 0) return [];
8248
+ return countries.map(function (item) {
8249
+ var _item$visitors2, _item$percentage, _item$percentage2;
8250
+ return {
8251
+ country: item.country || "Unknown",
8252
+ stats: "".concat(formatNumber((_item$visitors2 = item.visitors) !== null && _item$visitors2 !== void 0 ? _item$visitors2 : 0), " \xB7 ").concat(Number((_item$percentage = item.percentage) !== null && _item$percentage !== void 0 ? _item$percentage : 0).toFixed(0), "%"),
8253
+ percentage: Number((_item$percentage2 = item.percentage) !== null && _item$percentage2 !== void 0 ? _item$percentage2 : 0)
8254
+ };
8255
+ });
8256
+ }, [apiData === null || apiData === void 0 || (_apiData$geographyIns2 = apiData.geographyInsights) === null || _apiData$geographyIns2 === void 0 ? void 0 : _apiData$geographyIns2.countries, hasOrganicOverview]);
8257
+ var sourceBreakdown = React.useMemo(function () {
8258
+ var _breakdown$totalVisit;
8259
+ var breakdown = apiData === null || apiData === void 0 ? void 0 : apiData.sourceBreakdown;
8260
+ var sources = breakdown === null || breakdown === void 0 ? void 0 : breakdown.data;
8261
+ if (!hasOrganicOverview) return null;
8262
+ if (!Array.isArray(sources) || sources.length === 0) return null;
8263
+ var colors = sources.map(function (_, index) {
8264
+ return SOURCE_COLORS[index % SOURCE_COLORS.length];
8265
+ });
8266
+ return {
8267
+ series: sources.map(function (item) {
8268
+ var _item$percentage3;
8269
+ return Number((_item$percentage3 = item.percentage) !== null && _item$percentage3 !== void 0 ? _item$percentage3 : 0);
8270
+ }),
8271
+ labels: sources.map(function (item) {
8272
+ return item.source;
8273
+ }),
8274
+ colors: colors,
8275
+ centerLabel: "visitors",
8276
+ centerValue: formatNumber((_breakdown$totalVisit = breakdown.totalVisitors) !== null && _breakdown$totalVisit !== void 0 ? _breakdown$totalVisit : 0),
8277
+ items: sources.map(function (item, index) {
8278
+ var _item$percentage4;
8279
+ return {
8280
+ label: item.source,
8281
+ val: "".concat(Number((_item$percentage4 = item.percentage) !== null && _item$percentage4 !== void 0 ? _item$percentage4 : 0).toFixed(1), "%"),
8282
+ color: colors[index]
8283
+ };
8284
+ })
8285
+ };
8286
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.sourceBreakdown, hasOrganicOverview]);
8044
8287
  var renderCard = function renderCard(title) {
8045
- return /*#__PURE__*/jsxRuntime.jsx(MetricCard
8046
- // key={title}
8047
- , {
8288
+ return /*#__PURE__*/jsxRuntime.jsx(MetricCard, {
8048
8289
  title: title,
8049
8290
  value: metricInfo[title].money ? metricInfo[title].value : metricInfo[title].value,
8050
8291
  caption: metricInfo[title].subValue,
@@ -8058,31 +8299,16 @@ var OrganicSection = function OrganicSection(_ref) {
8058
8299
  border: "2px solid #ef4444",
8059
8300
  bgcolor: "#fffafa"
8060
8301
  } : {}
8061
- })
8062
- // <DisplayCard
8063
- // key={title}
8064
- // title={title}
8065
- // value={metricInfo[title].value}
8066
- // subValue={metricInfo[title].subValue}
8067
- // icon={metricInfo[title].icon}
8068
- // onClick={() => setActiveMetric(title)}
8069
- // isActive={activeMetric === title}
8070
- // sx={{
8071
- // // border:
8072
- // // activeMetric === title
8073
- // // ? "2px solid rgb(99, 99, 230)"
8074
- // // : "2px solid #f0f0f0",
8075
- // }}
8076
- // />
8077
- ;
8302
+ });
8078
8303
  };
8079
- var selectedInfo = metricInfo[activeMetric];
8304
+ var selectedInfo = metricInfo[activeMetric] || metricInfo["Organic Users"];
8305
+ var chartCategories = ((_selectedInfo$categor = selectedInfo.categories) === null || _selectedInfo$categor === void 0 ? void 0 : _selectedInfo$categor.length) > 0 ? selectedInfo.categories : fallbackCategories;
8080
8306
  var mainChart = {
8081
8307
  label: activeMetric,
8082
8308
  value: selectedInfo.value,
8083
8309
  trend: selectedInfo.subValue,
8084
8310
  data: selectedInfo.data,
8085
- categories: categories
8311
+ categories: chartCategories
8086
8312
  };
8087
8313
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
8088
8314
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
@@ -8115,7 +8341,9 @@ var OrganicSection = function OrganicSection(_ref) {
8115
8341
  item: true,
8116
8342
  xs: 12,
8117
8343
  md: 6,
8118
- children: /*#__PURE__*/jsxRuntime.jsx(LandingPagesCard, {})
8344
+ children: /*#__PURE__*/jsxRuntime.jsx(LandingPagesCard, {
8345
+ data: landingPagesData
8346
+ })
8119
8347
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
8120
8348
  item: true,
8121
8349
  xs: 12,
@@ -8123,12 +8351,12 @@ var OrganicSection = function OrganicSection(_ref) {
8123
8351
  children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
8124
8352
  title: "Source breakdown",
8125
8353
  subtitle: "Where organic visitors come from",
8126
- series: [40.8, 35.1, 14.2, 3.3],
8127
- labels: ["Meta Ads", "Google Ads", "TikTok", "Snapchat"],
8128
- colors: ["#4267B2", "#4285F4", "#06510bff", "#f2b61dff"],
8129
- centerLabel: "total spend",
8130
- centerValue: "$8.3K",
8131
- items: [{
8354
+ series: (_sourceBreakdown$seri = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.series) !== null && _sourceBreakdown$seri !== void 0 ? _sourceBreakdown$seri : [40.8, 35.1, 14.2, 3.3],
8355
+ labels: (_sourceBreakdown$labe = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.labels) !== null && _sourceBreakdown$labe !== void 0 ? _sourceBreakdown$labe : ["Meta Ads", "Google Ads", "TikTok", "Snapchat"],
8356
+ colors: (_sourceBreakdown$colo = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.colors) !== null && _sourceBreakdown$colo !== void 0 ? _sourceBreakdown$colo : ["#4267B2", "#4285F4", "#06510bff", "#f2b61dff"],
8357
+ centerLabel: (_sourceBreakdown$cent = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.centerLabel) !== null && _sourceBreakdown$cent !== void 0 ? _sourceBreakdown$cent : "total spend",
8358
+ centerValue: (_sourceBreakdown$cent2 = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.centerValue) !== null && _sourceBreakdown$cent2 !== void 0 ? _sourceBreakdown$cent2 : "$8.3K",
8359
+ items: (_sourceBreakdown$item = sourceBreakdown === null || sourceBreakdown === void 0 ? void 0 : sourceBreakdown.items) !== null && _sourceBreakdown$item !== void 0 ? _sourceBreakdown$item : [{
8132
8360
  label: "Google Search",
8133
8361
  val: "40.8%",
8134
8362
  color: "#4267B2"
@@ -8154,13 +8382,17 @@ var OrganicSection = function OrganicSection(_ref) {
8154
8382
  item: true,
8155
8383
  xs: 12,
8156
8384
  md: 6,
8157
- children: /*#__PURE__*/jsxRuntime.jsx(KeywordsCard, {})
8385
+ children: /*#__PURE__*/jsxRuntime.jsx(KeywordsCard, {
8386
+ data: keywordsData,
8387
+ available: hasOrganicOverview ? (apiData === null || apiData === void 0 || (_apiData$topOrganicKe3 = apiData.topOrganicKeywords) === null || _apiData$topOrganicKe3 === void 0 ? void 0 : _apiData$topOrganicKe3.available) !== false : true
8388
+ })
8158
8389
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
8159
8390
  item: true,
8160
8391
  xs: 12,
8161
8392
  md: 6,
8162
8393
  children: /*#__PURE__*/jsxRuntime.jsx(GeographyCard, {
8163
- subtitle: "Top countries by organic traffic"
8394
+ subtitle: "Top countries by organic traffic",
8395
+ data: geographyData
8164
8396
  })
8165
8397
  })]
8166
8398
  })]