@ammarkhalidfarooq/dashboard-package 0.6.81 → 0.6.83

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
@@ -2752,7 +2752,7 @@ var PageHeader = function PageHeader(_ref12) {
2752
2752
  fontWeight: 700,
2753
2753
  letterSpacing: "0.3px"
2754
2754
  },
2755
- children: "ACTIVE FILTERS:"
2755
+ children: "Active Filters:"
2756
2756
  }), " ", /*#__PURE__*/jsxRuntime.jsx("span", {
2757
2757
  style: {
2758
2758
  fontWeight: 500,
@@ -4005,7 +4005,9 @@ var NewOverview = function NewOverview(_ref) {
4005
4005
  apiLoading: apiLoading
4006
4006
  }), activeSection === "Paid" && /*#__PURE__*/jsxRuntime.jsx(PaidSection$2, {
4007
4007
  apiData: apiData,
4008
- apiLoading: apiLoading
4008
+ dateName: dateName,
4009
+ apiLoading: apiLoading,
4010
+ numberOfDays: numberOfDays
4009
4011
  }), activeSection === "Organic" && /*#__PURE__*/jsxRuntime.jsx(material.Box, {
4010
4012
  sx: {},
4011
4013
  children: /*#__PURE__*/jsxRuntime.jsx(OrganicSection$2, {
@@ -6253,36 +6255,39 @@ var TopCampaignsConvRateCard = function TopCampaignsConvRateCard(_ref7) {
6253
6255
  })]
6254
6256
  });
6255
6257
  };
6256
- var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6257
- var data = [{
6258
- id: "YO",
6259
- // avatarBg: "#c1cfde70",
6258
+ var getCampaignInitials$1 = function getCampaignInitials() {
6259
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
6260
+ var words = name.trim().split(/\s+/).filter(Boolean);
6261
+ if (words.length >= 2) {
6262
+ return (words[0][0] + words[1][0]).toUpperCase();
6263
+ }
6264
+ return name.slice(0, 2).toUpperCase() || "—";
6265
+ };
6266
+ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard(_ref8) {
6267
+ var _ref8$data = _ref8.data,
6268
+ dataProp = _ref8$data === void 0 ? null : _ref8$data;
6269
+ var fallbackData = [{
6260
6270
  name: "Yemen Orphans - Meta",
6261
6271
  spend: "$8,200",
6262
6272
  revenue: "$31,400",
6263
6273
  roas: "3.8x"
6264
6274
  }, {
6265
- id: "GF",
6266
- // avatarBg: "#c1cfdedb",
6267
6275
  name: "Gaza Food - Google",
6268
6276
  spend: "$7,400",
6269
6277
  revenue: "$25,200",
6270
6278
  roas: "3.4x"
6271
6279
  }, {
6272
- id: "PW",
6273
- // avatarBg: "#c1cfdedb",
6274
6280
  name: "Pakistan Wells - Meta",
6275
6281
  spend: "$5,800",
6276
6282
  revenue: "$18,600",
6277
6283
  roas: "3.2x"
6278
6284
  }, {
6279
- id: "R",
6280
- // avatarBg: "#c1cfdedb",
6281
6285
  name: "Ramadan - TikTok",
6282
6286
  spend: "$3,200",
6283
6287
  revenue: "$8,900",
6284
6288
  roas: "2.8x"
6285
6289
  }];
6290
+ var data = dataProp === null ? fallbackData : dataProp;
6286
6291
  return /*#__PURE__*/jsxRuntime.jsxs(CardWrapper, {
6287
6292
  title: "Top performing campaigns",
6288
6293
  subtitle: "Paid campaigns ranked by ROAS",
@@ -6327,7 +6332,14 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6327
6332
  },
6328
6333
  children: "ROAS"
6329
6334
  })]
6330
- }), data.map(function (item, index) {
6335
+ }), data.length === 0 ? /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6336
+ sx: {
6337
+ fontSize: "13px",
6338
+ color: "rgba(0, 0, 0, 0.4)",
6339
+ py: 2
6340
+ },
6341
+ children: "No campaign data for this period"
6342
+ }) : data.map(function (item, index) {
6331
6343
  return /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
6332
6344
  sx: {
6333
6345
  display: "grid",
@@ -6356,7 +6368,7 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6356
6368
  fontSize: "10px",
6357
6369
  fontWeight: 700
6358
6370
  },
6359
- children: item.id
6371
+ children: item.id || getCampaignInitials$1(item.name)
6360
6372
  }), /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
6361
6373
  sx: {
6362
6374
  fontSize: "13px",
@@ -6400,9 +6412,9 @@ var TopPerformingCampaignsCard = function TopPerformingCampaignsCard() {
6400
6412
  })]
6401
6413
  });
6402
6414
  };
6403
- var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref8) {
6404
- var sx = _ref8.sx,
6405
- donorGeographyData = _ref8.donorGeographyData;
6415
+ var PaidDonorGeographyCard = function PaidDonorGeographyCard(_ref9) {
6416
+ var sx = _ref9.sx,
6417
+ donorGeographyData = _ref9.donorGeographyData;
6406
6418
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || [];
6407
6419
  var data = rawCountries.map(function (item) {
6408
6420
  return {
@@ -17978,87 +17990,341 @@ var OverallSection$1 = /*#__PURE__*/Object.freeze({
17978
17990
  default: OverallSection
17979
17991
  });
17980
17992
 
17993
+ var CHANNEL_STYLES = {
17994
+ "Meta Ads": {
17995
+ id: "M",
17996
+ avatarBg: "#4267B2",
17997
+ color: "#4267B2"
17998
+ },
17999
+ "Google Ads": {
18000
+ id: "G",
18001
+ avatarBg: "#4285F4",
18002
+ color: "#4285F4"
18003
+ },
18004
+ "TikTok Ads": {
18005
+ id: "T",
18006
+ avatarBg: "#000000",
18007
+ color: "#cd249dff"
18008
+ },
18009
+ YouTube: {
18010
+ id: "Y",
18011
+ avatarBg: "#FF0000",
18012
+ color: "#FF0000"
18013
+ },
18014
+ Snapchat: {
18015
+ id: "S",
18016
+ avatarBg: "#FFFC00",
18017
+ color: "#FFFC00"
18018
+ }
18019
+ };
18020
+ var formatGrowth$2 = function formatGrowth(value) {
18021
+ return "".concat(Number(value !== null && value !== void 0 ? value : 0).toFixed(2), "% vs pp");
18022
+ };
18023
+ var mapTimeSeries$2 = function mapTimeSeries(series) {
18024
+ if (!Array.isArray(series) || series.length === 0) {
18025
+ return {
18026
+ categories: [],
18027
+ data: []
18028
+ };
18029
+ }
18030
+ return {
18031
+ categories: series.map(function (item) {
18032
+ return item.date;
18033
+ }),
18034
+ data: series.map(function (item) {
18035
+ var _item$value;
18036
+ return (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : 0;
18037
+ })
18038
+ };
18039
+ };
18040
+ var getChannelStyle = function getChannelStyle() {
18041
+ var channel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
18042
+ return CHANNEL_STYLES[channel] || {
18043
+ id: channel.slice(0, 1).toUpperCase() || "?",
18044
+ avatarBg: "#F3F4F6",
18045
+ color: "#6366F1"
18046
+ };
18047
+ };
18048
+ var mapChannelTrend = function mapChannelTrend(trend) {
18049
+ var normalized = (trend || "stable").toLowerCase();
18050
+ if (normalized === "down" || normalized === "declining") {
18051
+ return {
18052
+ type: "trend",
18053
+ trendType: "down",
18054
+ trendLabel: "Declining"
18055
+ };
18056
+ }
18057
+ if (normalized === "up" || normalized === "improving") {
18058
+ return {
18059
+ type: "trend",
18060
+ trendType: "up",
18061
+ trendLabel: "Improving"
18062
+ };
18063
+ }
18064
+ return {
18065
+ type: "status",
18066
+ status: "Stable",
18067
+ statusBg: "#F3F4F6",
18068
+ statusColor: "#6B7280"
18069
+ };
18070
+ };
18071
+ var getRoasColor = function getRoasColor(roas) {
18072
+ return Number(roas !== null && roas !== void 0 ? roas : 0) >= 2.5 ? "#22C55E" : "#EF4444";
18073
+ };
17981
18074
  var PaidSection = function PaidSection(_ref) {
17982
- var _ref$apiLoading = _ref.apiLoading,
17983
- apiLoading = _ref$apiLoading === void 0 ? false : _ref$apiLoading;
18075
+ var _apiData$spendVsReven, _apiData$spendVsReven2, _selectedInfo$categor, _spendAllocation$subt, _spendAllocation$seri, _spendAllocation$labe, _spendAllocation$colo, _spendAllocation$cent, _spendAllocation$cent2, _spendAllocation$item;
18076
+ var _ref$apiData = _ref.apiData,
18077
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData;
18078
+ _ref.dateName;
18079
+ var _ref$apiLoading = _ref.apiLoading,
18080
+ apiLoading = _ref$apiLoading === void 0 ? false : _ref$apiLoading,
18081
+ _ref$numberOfDays = _ref.numberOfDays,
18082
+ numberOfDays = _ref$numberOfDays === void 0 ? 30 : _ref$numberOfDays;
17984
18083
  var _useState = React.useState("Total Spent"),
17985
18084
  _useState2 = _slicedToArray(_useState, 2),
17986
18085
  activeMetric = _useState2[0],
17987
18086
  setActiveMetric = _useState2[1];
17988
- if (apiLoading) {
17989
- return /*#__PURE__*/jsxRuntime.jsx(PaidSectionSkeleton, {});
17990
- }
17991
- var categories = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
17992
- var metricInfo = {
17993
- "Total Spent": {
17994
- value: "$".concat(formatNumber(80313)),
17995
- subValue: "12% vs last month",
17996
- chartLabel: "Daily Spend",
17997
- data: [800, 950, 700, 1100, 900, 1200, 1300],
17998
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.IndeterminateCheckBoxOutlined, {}),
17999
- money: true,
18000
- error: false,
18001
- warning: false
18002
- },
18003
- "Revinue Raised": {
18004
- value: "$".concat(formatNumber(240398)),
18005
- subValue: "12% vs last month",
18006
- chartLabel: "Daily Revenue",
18007
- data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
18008
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
18009
- money: true,
18010
- error: false,
18011
- warning: false
18012
- },
18013
- ROAS: {
18014
- value: "3.0",
18015
- subValue: "12% vs last month",
18016
- chartLabel: "ROAS Trend",
18017
- data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
18018
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.TrendingUp, {}),
18019
- money: false,
18020
- error: false,
18021
- warning: false
18022
- },
18023
- "Cost per donor": {
18024
- value: "$".concat(formatNumber(373)),
18025
- subValue: "12% vs last month",
18026
- chartLabel: "CPA Trend",
18027
- data: [350, 380, 360, 410, 390, 370, 373],
18028
- icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PersonOutlined, {}),
18029
- money: true,
18030
- error: false,
18031
- warning: false
18032
- },
18033
- "Conversion rate": {
18034
- value: "3.1%",
18035
- subValue: "12% vs last month",
18036
- chartLabel: "Conversion Rate",
18037
- data: [2.8, 3.0, 2.9, 3.4, 3.2, 3.1, 3.1],
18038
- icon: /*#__PURE__*/jsxRuntime.jsx(ConversionRateIcon, {}),
18039
- avatarSx: conversionRateAvatarSx,
18040
- money: false,
18041
- error: false,
18042
- warning: false
18043
- },
18044
- "Avg donation": {
18045
- value: "$".concat(formatNumber(130.58)),
18046
- subValue: "12% vs last month",
18047
- chartLabel: "Average Donation",
18048
- data: [120, 135, 125, 140, 130, 128, 130.58],
18049
- icon: /*#__PURE__*/jsxRuntime.jsx(AverageDonationIcon, {}),
18050
- avatarSx: avgDonationAvatarSx,
18051
- money: true,
18052
- error: false,
18053
- warning: false
18087
+ var overview = (apiData === null || apiData === void 0 ? void 0 : apiData.overview) || {};
18088
+ var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
18089
+ var hasPaidOverview = Boolean(apiData === null || apiData === void 0 ? void 0 : apiData.overview);
18090
+ var spendSeries = mapTimeSeries$2(apiData === null || apiData === void 0 || (_apiData$spendVsReven = apiData.spendVsRevenue) === null || _apiData$spendVsReven === void 0 ? void 0 : _apiData$spendVsReven.spend);
18091
+ var revenueSeries = mapTimeSeries$2(apiData === null || apiData === void 0 || (_apiData$spendVsReven2 = apiData.spendVsRevenue) === null || _apiData$spendVsReven2 === void 0 ? void 0 : _apiData$spendVsReven2.revenue);
18092
+ var roasChartData = React.useMemo(function () {
18093
+ if (spendSeries.data.length === 0 || revenueSeries.data.length === 0) {
18094
+ return [];
18054
18095
  }
18096
+ var length = Math.min(spendSeries.data.length, revenueSeries.data.length);
18097
+ return Array.from({
18098
+ length: length
18099
+ }, function (_, index) {
18100
+ var _spendSeries$data$ind, _revenueSeries$data$i;
18101
+ var spend = (_spendSeries$data$ind = spendSeries.data[index]) !== null && _spendSeries$data$ind !== void 0 ? _spendSeries$data$ind : 0;
18102
+ var revenue = (_revenueSeries$data$i = revenueSeries.data[index]) !== null && _revenueSeries$data$i !== void 0 ? _revenueSeries$data$i : 0;
18103
+ return spend > 0 ? revenue / spend : 0;
18104
+ });
18105
+ }, [spendSeries.data, revenueSeries.data]);
18106
+ var fallbackCategories = spendSeries.categories.length ? spendSeries.categories : revenueSeries.categories.length ? revenueSeries.categories : ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
18107
+ var flatSeries = function flatSeries(value) {
18108
+ return fallbackCategories.length > 0 ? fallbackCategories.map(function () {
18109
+ return Number(value !== null && value !== void 0 ? value : 0);
18110
+ }) : [Number(value !== null && value !== void 0 ? value : 0)];
18055
18111
  };
18112
+ var metricInfo = React.useMemo(function () {
18113
+ var _overview$totalSpent, _overview$totalRevenu, _overview$roas, _overview$roas2, _overview$costPerDono, _overview$costPerDono2, _overview$conversionR, _overview$conversionR2, _overview$averageDona, _overview$averageDona2;
18114
+ if (!hasPaidOverview) {
18115
+ return {
18116
+ "Total Spent": {
18117
+ value: "$".concat(formatNumber(80313)),
18118
+ subValue: "12% vs pp",
18119
+ data: [800, 950, 700, 1100, 900, 1200, 1300],
18120
+ categories: fallbackCategories,
18121
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.IndeterminateCheckBoxOutlined, {}),
18122
+ money: true,
18123
+ error: false,
18124
+ warning: false
18125
+ },
18126
+ "Revinue Raised": {
18127
+ value: "$".concat(formatNumber(240398)),
18128
+ subValue: "12% vs pp",
18129
+ data: [3200, 4100, 2800, 5600, 4200, 6100, 7500],
18130
+ categories: fallbackCategories,
18131
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
18132
+ money: true,
18133
+ error: false,
18134
+ warning: false
18135
+ },
18136
+ ROAS: {
18137
+ value: "3.0x",
18138
+ subValue: "12% vs pp",
18139
+ data: [2.5, 3.1, 2.8, 4.2, 3.8, 4.5, 5.2],
18140
+ categories: fallbackCategories,
18141
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.TrendingUp, {}),
18142
+ money: false,
18143
+ error: false,
18144
+ warning: false
18145
+ },
18146
+ "Cost per donor": {
18147
+ value: "$".concat(formatNumber(373)),
18148
+ subValue: "12% vs pp",
18149
+ data: [350, 380, 360, 410, 390, 370, 373],
18150
+ categories: fallbackCategories,
18151
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PersonOutlined, {}),
18152
+ money: true,
18153
+ error: false,
18154
+ warning: false
18155
+ },
18156
+ "Conversion rate": {
18157
+ value: "3.1%",
18158
+ subValue: "12% vs pp",
18159
+ data: [2.8, 3.0, 2.9, 3.4, 3.2, 3.1, 3.1],
18160
+ categories: fallbackCategories,
18161
+ icon: /*#__PURE__*/jsxRuntime.jsx(ConversionRateIcon, {}),
18162
+ avatarSx: conversionRateAvatarSx,
18163
+ money: false,
18164
+ error: false,
18165
+ warning: false
18166
+ },
18167
+ "Avg donation": {
18168
+ value: "$".concat(formatNumber(130.58)),
18169
+ subValue: "12% vs pp",
18170
+ data: [120, 135, 125, 140, 130, 128, 130.58],
18171
+ categories: fallbackCategories,
18172
+ icon: /*#__PURE__*/jsxRuntime.jsx(AverageDonationIcon, {}),
18173
+ avatarSx: avgDonationAvatarSx,
18174
+ money: true,
18175
+ error: false,
18176
+ warning: false
18177
+ }
18178
+ };
18179
+ }
18180
+ return {
18181
+ "Total Spent": {
18182
+ value: "$".concat(formatNumber((_overview$totalSpent = overview.totalSpent) !== null && _overview$totalSpent !== void 0 ? _overview$totalSpent : 0)),
18183
+ subValue: formatGrowth$2(growth.totalSpent),
18184
+ data: spendSeries.data,
18185
+ categories: spendSeries.categories,
18186
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.IndeterminateCheckBoxOutlined, {}),
18187
+ money: true,
18188
+ error: false,
18189
+ warning: false
18190
+ },
18191
+ "Revinue Raised": {
18192
+ value: "$".concat(formatNumber((_overview$totalRevenu = overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 0)),
18193
+ subValue: formatGrowth$2(growth.totalRevenue),
18194
+ data: revenueSeries.data,
18195
+ categories: revenueSeries.categories,
18196
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PaidOutlined, {}),
18197
+ money: true,
18198
+ error: false,
18199
+ warning: false
18200
+ },
18201
+ ROAS: {
18202
+ value: "".concat(Number((_overview$roas = overview.roas) !== null && _overview$roas !== void 0 ? _overview$roas : 0).toFixed(1), "x"),
18203
+ subValue: formatGrowth$2(growth.roas),
18204
+ data: roasChartData.length > 0 ? roasChartData : flatSeries((_overview$roas2 = overview.roas) !== null && _overview$roas2 !== void 0 ? _overview$roas2 : 0),
18205
+ categories: spendSeries.categories.length ? spendSeries.categories : fallbackCategories,
18206
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.TrendingUp, {}),
18207
+ money: false,
18208
+ error: false,
18209
+ warning: false
18210
+ },
18211
+ "Cost per donor": {
18212
+ value: "$".concat(formatNumber((_overview$costPerDono = overview.costPerDonor) !== null && _overview$costPerDono !== void 0 ? _overview$costPerDono : 0)),
18213
+ subValue: formatGrowth$2(growth.costPerDonor),
18214
+ data: flatSeries((_overview$costPerDono2 = overview.costPerDonor) !== null && _overview$costPerDono2 !== void 0 ? _overview$costPerDono2 : 0),
18215
+ categories: fallbackCategories,
18216
+ icon: /*#__PURE__*/jsxRuntime.jsx(iconsMaterial.PersonOutlined, {}),
18217
+ money: true,
18218
+ error: false,
18219
+ warning: false
18220
+ },
18221
+ "Conversion rate": {
18222
+ value: "".concat(Number((_overview$conversionR = overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 0).toFixed(2), "%"),
18223
+ subValue: formatGrowth$2(growth.conversionRate),
18224
+ data: flatSeries((_overview$conversionR2 = overview.conversionRate) !== null && _overview$conversionR2 !== void 0 ? _overview$conversionR2 : 0),
18225
+ categories: fallbackCategories,
18226
+ icon: /*#__PURE__*/jsxRuntime.jsx(ConversionRateIcon, {}),
18227
+ avatarSx: conversionRateAvatarSx,
18228
+ money: false,
18229
+ error: false,
18230
+ warning: false
18231
+ },
18232
+ "Avg donation": {
18233
+ value: "$".concat(formatNumber((_overview$averageDona = overview.averageDonation) !== null && _overview$averageDona !== void 0 ? _overview$averageDona : 0)),
18234
+ subValue: formatGrowth$2(growth.averageDonation),
18235
+ data: flatSeries((_overview$averageDona2 = overview.averageDonation) !== null && _overview$averageDona2 !== void 0 ? _overview$averageDona2 : 0),
18236
+ categories: fallbackCategories,
18237
+ icon: /*#__PURE__*/jsxRuntime.jsx(AverageDonationIcon, {}),
18238
+ avatarSx: avgDonationAvatarSx,
18239
+ money: true,
18240
+ error: false,
18241
+ warning: false
18242
+ }
18243
+ };
18244
+ }, [fallbackCategories, growth, hasPaidOverview, overview, revenueSeries, roasChartData, spendSeries]);
18245
+ var channelRows = React.useMemo(function () {
18246
+ var channels = apiData === null || apiData === void 0 ? void 0 : apiData.channelPerformance;
18247
+ if (!hasPaidOverview) return null;
18248
+ if (!Array.isArray(channels) || channels.length === 0) return [];
18249
+ return channels.map(function (item) {
18250
+ var _item$roas, _item$spend, _item$revenue, _item$cpa;
18251
+ var style = getChannelStyle(item.channel);
18252
+ var roas = Number((_item$roas = item.roas) !== null && _item$roas !== void 0 ? _item$roas : 0);
18253
+ return _objectSpread2({
18254
+ id: style.id,
18255
+ avatarBg: style.avatarBg,
18256
+ name: item.channel,
18257
+ val1: "$".concat(formatNumber((_item$spend = item.spend) !== null && _item$spend !== void 0 ? _item$spend : 0)),
18258
+ val2: "$".concat(formatNumber((_item$revenue = item.revenue) !== null && _item$revenue !== void 0 ? _item$revenue : 0)),
18259
+ val3: "".concat(roas.toFixed(1), "x"),
18260
+ val4: "$".concat(formatNumber((_item$cpa = item.cpa) !== null && _item$cpa !== void 0 ? _item$cpa : 0)),
18261
+ highlightVal3: true,
18262
+ val3Color: getRoasColor(roas)
18263
+ }, mapChannelTrend(item.trend));
18264
+ });
18265
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.channelPerformance, hasPaidOverview]);
18266
+ var spendAllocation = React.useMemo(function () {
18267
+ var _allocation$totalSpen, _allocation$totalSpen2;
18268
+ var allocation = apiData === null || apiData === void 0 ? void 0 : apiData.spendAllocation;
18269
+ if (!hasPaidOverview) return null;
18270
+ if (!allocation || !Array.isArray(allocation.data) || allocation.data.length === 0) {
18271
+ return null;
18272
+ }
18273
+ var items = allocation.data.map(function (item) {
18274
+ var _item$percentage, _item$spend2, _item$percentage2;
18275
+ var style = getChannelStyle(item.channel);
18276
+ return {
18277
+ label: item.channel,
18278
+ val: "".concat(Number((_item$percentage = item.percentage) !== null && _item$percentage !== void 0 ? _item$percentage : 0).toFixed(1), "%"),
18279
+ color: style.color,
18280
+ spend: (_item$spend2 = item.spend) !== null && _item$spend2 !== void 0 ? _item$spend2 : 0,
18281
+ percentage: (_item$percentage2 = item.percentage) !== null && _item$percentage2 !== void 0 ? _item$percentage2 : 0
18282
+ };
18283
+ });
18284
+ return {
18285
+ series: items.map(function (item) {
18286
+ return item.percentage;
18287
+ }),
18288
+ labels: items.map(function (item) {
18289
+ return item.label;
18290
+ }),
18291
+ colors: items.map(function (item) {
18292
+ return item.color;
18293
+ }),
18294
+ centerLabel: "total spend",
18295
+ centerValue: "$".concat(formatNumber((_allocation$totalSpen = allocation.totalSpend) !== null && _allocation$totalSpen !== void 0 ? _allocation$totalSpen : 0)),
18296
+ subtitle: "Where $".concat(formatNumber((_allocation$totalSpen2 = allocation.totalSpend) !== null && _allocation$totalSpen2 !== void 0 ? _allocation$totalSpen2 : 0), " went"),
18297
+ items: items.map(function (_ref2) {
18298
+ var label = _ref2.label,
18299
+ val = _ref2.val,
18300
+ color = _ref2.color;
18301
+ return {
18302
+ label: label,
18303
+ val: val,
18304
+ color: color
18305
+ };
18306
+ })
18307
+ };
18308
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.spendAllocation, hasPaidOverview]);
18309
+ var topCampaignsData = React.useMemo(function () {
18310
+ var campaigns = apiData === null || apiData === void 0 ? void 0 : apiData.topCampaigns;
18311
+ if (!hasPaidOverview) return null;
18312
+ if (!Array.isArray(campaigns)) return null;
18313
+ if (campaigns.length === 0) return [];
18314
+ return campaigns.map(function (item) {
18315
+ var _item$spend3, _item$revenue2, _item$roas2;
18316
+ return {
18317
+ name: item.campaign || item.name || "Unknown",
18318
+ spend: "$".concat(formatNumber((_item$spend3 = item.spend) !== null && _item$spend3 !== void 0 ? _item$spend3 : 0)),
18319
+ revenue: "$".concat(formatNumber((_item$revenue2 = item.revenue) !== null && _item$revenue2 !== void 0 ? _item$revenue2 : 0)),
18320
+ roas: "".concat(Number((_item$roas2 = item.roas) !== null && _item$roas2 !== void 0 ? _item$roas2 : 0).toFixed(1), "x")
18321
+ };
18322
+ });
18323
+ }, [apiData === null || apiData === void 0 ? void 0 : apiData.topCampaigns, hasPaidOverview]);
18056
18324
  var renderCard = function renderCard(title) {
18057
- return /*#__PURE__*/jsxRuntime.jsx(MetricCard$1
18058
- // key={title}
18059
- , {
18325
+ return /*#__PURE__*/jsxRuntime.jsx(MetricCard$1, {
18060
18326
  title: title,
18061
- value: metricInfo[title].money ? metricInfo[title].value : metricInfo[title].value,
18327
+ value: metricInfo[title].value,
18062
18328
  caption: metricInfo[title].subValue,
18063
18329
  icon: metricInfo[title].icon,
18064
18330
  avatarSx: metricInfo[title].avatarSx,
@@ -18071,32 +18337,22 @@ var PaidSection = function PaidSection(_ref) {
18071
18337
  border: "2px solid #ef4444",
18072
18338
  bgcolor: "#fffafa"
18073
18339
  } : {}
18074
- })
18075
- // <DisplayCard
18076
- // key={title}
18077
- // title={title}
18078
- // value={metricInfo[title].value}
18079
- // subValue={metricInfo[title].subValue}
18080
- // icon={metricInfo[title].icon}
18081
- // onClick={() => setActiveMetric(title)}
18082
- // isActive={activeMetric === title}
18083
- // sx={{
18084
- // // border:
18085
- // // activeMetric === title
18086
- // // ? "2px solid rgb(99, 99, 230)"
18087
- // // : "2px solid #f0f0f0",
18088
- // }}
18089
- // />
18090
- ;
18340
+ });
18091
18341
  };
18092
- var selectedInfo = metricInfo[activeMetric];
18342
+ var selectedInfo = metricInfo[activeMetric] || metricInfo["Total Spent"];
18343
+ var chartCategories = ((_selectedInfo$categor = selectedInfo.categories) === null || _selectedInfo$categor === void 0 ? void 0 : _selectedInfo$categor.length) > 0 ? selectedInfo.categories : fallbackCategories;
18093
18344
  var mainChart = {
18094
18345
  label: activeMetric,
18095
18346
  value: selectedInfo.value,
18096
18347
  trend: selectedInfo.subValue,
18097
18348
  data: selectedInfo.data,
18098
- categories: categories
18349
+ categories: chartCategories,
18350
+ hideControls: true,
18351
+ isAmount: selectedInfo.money
18099
18352
  };
18353
+ if (apiLoading) {
18354
+ return /*#__PURE__*/jsxRuntime.jsx(PaidSectionSkeleton, {});
18355
+ }
18100
18356
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
18101
18357
  children: [/*#__PURE__*/jsxRuntime.jsx(material.Box, {
18102
18358
  sx: {
@@ -18123,7 +18379,9 @@ var PaidSection = function PaidSection(_ref) {
18123
18379
  md: 12,
18124
18380
  type: "area",
18125
18381
  isPrimary: true,
18126
- isPremium: true
18382
+ isPremium: true,
18383
+ numberOfDays: numberOfDays,
18384
+ metric: activeMetric === "Conversion rate" ? "Percent" : activeMetric === "ROAS" ? "ROAS" : selectedInfo.money ? "Revenue" : "Donors"
18127
18385
  })
18128
18386
  }), /*#__PURE__*/jsxRuntime.jsxs(material.Grid, {
18129
18387
  container: true,
@@ -18145,7 +18403,7 @@ var PaidSection = function PaidSection(_ref) {
18145
18403
  columns: ["channel", "spend", "revenue", "ROAS", "CPA", "trend"],
18146
18404
  gridTemplateColumns: "2.2fr 1fr 1fr 0.8fr 0.8fr 1.2fr",
18147
18405
  height: "100%",
18148
- rows: [{
18406
+ rows: channelRows !== null && channelRows !== void 0 ? channelRows : [{
18149
18407
  id: "M",
18150
18408
  avatarBg: "#4267B2",
18151
18409
  name: "Meta Ads",
@@ -18226,13 +18484,13 @@ var PaidSection = function PaidSection(_ref) {
18226
18484
  },
18227
18485
  children: /*#__PURE__*/jsxRuntime.jsx(DonorMixCard, {
18228
18486
  title: "Spend allocation",
18229
- subtitle: "Where $80.3K went this month",
18230
- series: [40.8, 35.1, 14.2, 6.6, 3.3],
18231
- labels: ["Meta Ads", "Google Ads", "TikTok", "YouTube", "Snapchat"],
18232
- colors: ["#4267B2", "#4285F4", "#cd249dff", "#FF0000", "#FFFC00"],
18233
- centerLabel: "total spend",
18234
- centerValue: "$80.3K",
18235
- items: [{
18487
+ subtitle: (_spendAllocation$subt = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.subtitle) !== null && _spendAllocation$subt !== void 0 ? _spendAllocation$subt : "Where $80.3K went this month",
18488
+ series: (_spendAllocation$seri = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.series) !== null && _spendAllocation$seri !== void 0 ? _spendAllocation$seri : [40.8, 35.1, 14.2, 6.6, 3.3],
18489
+ labels: (_spendAllocation$labe = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.labels) !== null && _spendAllocation$labe !== void 0 ? _spendAllocation$labe : ["Meta Ads", "Google Ads", "TikTok", "YouTube", "Snapchat"],
18490
+ colors: (_spendAllocation$colo = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.colors) !== null && _spendAllocation$colo !== void 0 ? _spendAllocation$colo : ["#4267B2", "#4285F4", "#cd249dff", "#FF0000", "#FFFC00"],
18491
+ centerLabel: (_spendAllocation$cent = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.centerLabel) !== null && _spendAllocation$cent !== void 0 ? _spendAllocation$cent : "total spend",
18492
+ centerValue: (_spendAllocation$cent2 = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.centerValue) !== null && _spendAllocation$cent2 !== void 0 ? _spendAllocation$cent2 : "$80.3K",
18493
+ items: (_spendAllocation$item = spendAllocation === null || spendAllocation === void 0 ? void 0 : spendAllocation.items) !== null && _spendAllocation$item !== void 0 ? _spendAllocation$item : [{
18236
18494
  label: "Meta Ads",
18237
18495
  val: "40.8%",
18238
18496
  color: "#4267B2"
@@ -18273,7 +18531,9 @@ var PaidSection = function PaidSection(_ref) {
18273
18531
  sx: {
18274
18532
  paddingTop: "0px !important"
18275
18533
  },
18276
- children: /*#__PURE__*/jsxRuntime.jsx(TopPerformingCampaignsCard, {})
18534
+ children: /*#__PURE__*/jsxRuntime.jsx(TopPerformingCampaignsCard, {
18535
+ data: topCampaignsData
18536
+ })
18277
18537
  }), /*#__PURE__*/jsxRuntime.jsx(material.Grid, {
18278
18538
  item: true,
18279
18539
  xs: 12,
@@ -18285,7 +18545,9 @@ var PaidSection = function PaidSection(_ref) {
18285
18545
  md: "0px"
18286
18546
  }
18287
18547
  },
18288
- children: /*#__PURE__*/jsxRuntime.jsx(PaidDonorGeographyCard, {})
18548
+ children: /*#__PURE__*/jsxRuntime.jsx(PaidDonorGeographyCard, {
18549
+ donorGeographyData: apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography
18550
+ })
18289
18551
  })]
18290
18552
  })]
18291
18553
  });