@ammarkhalidfarooq/dashboard-package 0.6.82 → 0.6.84

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