@ammarkhalidfarooq/dashboard-package 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -89,6 +89,15 @@ function _toPropertyKey(t) {
89
89
  var i = _toPrimitive(t, "string");
90
90
  return "symbol" == typeof i ? i : i + "";
91
91
  }
92
+ function _typeof(o) {
93
+ "@babel/helpers - typeof";
94
+
95
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
96
+ return typeof o;
97
+ } : function (o) {
98
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
99
+ }, _typeof(o);
100
+ }
92
101
  function _unsupportedIterableToArray(r, a) {
93
102
  if (r) {
94
103
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
@@ -367,12 +376,18 @@ var RevenueChart = function RevenueChart(_ref) {
367
376
  if (isRadial) {
368
377
  var _series$;
369
378
  // For donut/pie, series must be a simple array of numbers
370
- chartSeries = Array.isArray(data) ? data : (series === null || series === void 0 || (_series$ = series[0]) === null || _series$ === void 0 ? void 0 : _series$.data) || [];
379
+ var processedData = Array.isArray(data) ? data.map(function (v) {
380
+ return _typeof(v) === 'object' && v !== null ? v.value : v;
381
+ }) : [];
382
+ chartSeries = processedData.length > 0 ? processedData : (series === null || series === void 0 || (_series$ = series[0]) === null || _series$ === void 0 ? void 0 : _series$.data) || [];
371
383
  } else {
372
384
  // For bar/line/area, series must be an array of objects [{ name: '', data: [] }]
385
+ var _processedData = Array.isArray(data) ? data.map(function (v) {
386
+ return _typeof(v) === 'object' && v !== null ? v.value : v;
387
+ }) : [];
373
388
  chartSeries = Array.isArray(series) ? series : [{
374
389
  name: metric || "Value",
375
- data: Array.isArray(data) ? data : []
390
+ data: _processedData
376
391
  }];
377
392
  }
378
393
  return /*#__PURE__*/jsx(ReactApexChart, {
@@ -446,14 +461,14 @@ var RenderChartCard = function RenderChartCard(_ref) {
446
461
  color: "#000000",
447
462
  mb: 0.5
448
463
  },
449
- children: item.value
464
+ children: _typeof(item.value) === 'object' && item.value !== null ? item.value.value !== undefined ? item.value.value : JSON.stringify(item.value) : item.value
450
465
  }), item.subValue && /*#__PURE__*/jsx(Typography, {
451
466
  variant: "subtitle2",
452
467
  sx: {
453
468
  color: "#000000",
454
469
  fontWeight: 600
455
470
  },
456
- children: item.subValue
471
+ children: _typeof(item.subValue) === 'object' && item.subValue !== null ? JSON.stringify(item.subValue) : item.subValue
457
472
  })]
458
473
  }), /*#__PURE__*/jsxs(Box, {
459
474
  sx: {
@@ -721,7 +736,7 @@ var DisplayCard = function DisplayCard(_ref) {
721
736
  fontSize: '22px',
722
737
  fontWeight: '500'
723
738
  },
724
- children: value
739
+ children: _typeof(value) === 'object' && value !== null ? value.value !== undefined ? value.value : JSON.stringify(value) : value
725
740
  })]
726
741
  })
727
742
  });
@@ -858,6 +873,16 @@ var NewOverview = function NewOverview(_ref) {
858
873
  var oneTimeTotal = oneTimeData.length > 0 ? oneTimeValues.reduce(function (sum, val) {
859
874
  return sum + val;
860
875
  }, 0) : 7100;
876
+ var firstInstData = (apiData === null || apiData === void 0 ? void 0 : apiData.firstInstallmentRevenue) || [];
877
+ var firstInstValues = firstInstData.length > 0 ? firstInstData.map(function (item) {
878
+ return item.value;
879
+ }) : currentData.slice(-7);
880
+ var firstInstCategories = firstInstData.length > 0 ? firstInstData.map(function (item) {
881
+ return item.date;
882
+ }) : categories.slice(-7);
883
+ var firstInstTotal = firstInstData.length > 0 ? firstInstValues.reduce(function (sum, val) {
884
+ return sum + val;
885
+ }, 0) : 510;
861
886
  var primaryCharts = [{
862
887
  label: "Total Revenue",
863
888
  value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRevenue) || "$9,200.00",
@@ -867,9 +892,9 @@ var NewOverview = function NewOverview(_ref) {
867
892
  showSelector: true
868
893
  }, {
869
894
  label: "First installments",
870
- value: "$510.00",
871
- data: currentData.slice(-7),
872
- categories: categories.slice(-7)
895
+ value: apiData !== null && apiData !== void 0 && apiData.firstInstallmentRevenue ? "$".concat(firstInstTotal.toLocaleString()) : "$510.00",
896
+ data: firstInstValues,
897
+ categories: firstInstCategories
873
898
  }, {
874
899
  label: "One-time donations",
875
900
  value: apiData !== null && apiData !== void 0 && apiData.oneTimeDonations ? "$".concat(oneTimeTotal.toLocaleString()) : "$7,100.00",
@@ -5178,7 +5203,9 @@ var index = /*#__PURE__*/Object.freeze({
5178
5203
  });
5179
5204
 
5180
5205
  var OverallSection = function OverallSection(_ref) {
5181
- var primaryCharts = _ref.primaryCharts,
5206
+ var _ref$apiData = _ref.apiData,
5207
+ apiData = _ref$apiData === void 0 ? {} : _ref$apiData,
5208
+ primaryCharts = _ref.primaryCharts,
5182
5209
  secondaryCharts = _ref.secondaryCharts,
5183
5210
  tertiaryCharts = _ref.tertiaryCharts,
5184
5211
  quaternaryCharts = _ref.quaternaryCharts;
@@ -5191,31 +5218,31 @@ var OverallSection = function OverallSection(_ref) {
5191
5218
  },
5192
5219
  children: [/*#__PURE__*/jsx(DisplayCard, {
5193
5220
  title: "Total Raised",
5194
- value: "$9,200",
5221
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRaised) || "$9,200",
5195
5222
  sx: {
5196
5223
  flex: 1
5197
5224
  }
5198
5225
  }), /*#__PURE__*/jsx(DisplayCard, {
5199
5226
  title: "Net Raised",
5200
- value: "$9,200",
5227
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.netRaised) || "$9,200",
5201
5228
  sx: {
5202
5229
  flex: 1
5203
5230
  }
5204
5231
  }), /*#__PURE__*/jsx(DisplayCard, {
5205
5232
  title: "Total Spent",
5206
- value: "$9,200",
5233
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalSpent) || "$9,200",
5207
5234
  sx: {
5208
5235
  flex: 1
5209
5236
  }
5210
5237
  }), /*#__PURE__*/jsx(DisplayCard, {
5211
5238
  title: "Total ROAS",
5212
- value: "3.0",
5239
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalRoas) || "3.0",
5213
5240
  sx: {
5214
5241
  flex: 1
5215
5242
  }
5216
5243
  }), /*#__PURE__*/jsx(DisplayCard, {
5217
5244
  title: "Total Donors",
5218
- value: "215",
5245
+ value: (apiData === null || apiData === void 0 ? void 0 : apiData.totalDonors) || "215",
5219
5246
  sx: {
5220
5247
  flex: 1
5221
5248
  }
@@ -5230,7 +5257,7 @@ var OverallSection = function OverallSection(_ref) {
5230
5257
  return /*#__PURE__*/jsx(RenderChartCard, {
5231
5258
  item: item,
5232
5259
  index: index
5233
- });
5260
+ }, "primary-".concat(index));
5234
5261
  })
5235
5262
  }), /*#__PURE__*/jsx(Grid, {
5236
5263
  container: true,
@@ -5242,7 +5269,7 @@ var OverallSection = function OverallSection(_ref) {
5242
5269
  return /*#__PURE__*/jsx(RenderChartCard, {
5243
5270
  item: item,
5244
5271
  index: index
5245
- });
5272
+ }, "secondary-".concat(index));
5246
5273
  })
5247
5274
  }), /*#__PURE__*/jsx(Grid, {
5248
5275
  container: true,
@@ -5254,7 +5281,7 @@ var OverallSection = function OverallSection(_ref) {
5254
5281
  return /*#__PURE__*/jsx(RenderChartCard, {
5255
5282
  item: item,
5256
5283
  index: index
5257
- });
5284
+ }, "tertiary-".concat(index));
5258
5285
  })
5259
5286
  }), /*#__PURE__*/jsx(Grid, {
5260
5287
  container: true,
@@ -5266,7 +5293,7 @@ var OverallSection = function OverallSection(_ref) {
5266
5293
  return /*#__PURE__*/jsx(RenderChartCard, {
5267
5294
  item: item,
5268
5295
  index: index
5269
- });
5296
+ }, "quaternary-".concat(index));
5270
5297
  })
5271
5298
  })]
5272
5299
  });