contentoh-components-library 21.4.65 → 21.4.66

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.
@@ -247,23 +247,24 @@ var Dashboard = function Dashboard(_ref) {
247
247
  while (1) {
248
248
  switch (_context3.prev = _context3.next) {
249
249
  case 0:
250
+ _context3.prev = 0;
250
251
  isRetailer = user.is_retailer && company.retailers;
251
252
  isProvider = !user.is_retailer && user.id_role === 0;
252
253
  isCollaborator = user.id_role > 0;
253
- _context3.next = 5;
254
+ _context3.next = 6;
254
255
  return loadProductVersions(orderByStatus);
255
256
 
256
- case 5:
257
+ case 6:
257
258
  _context3.t0 = _context3.sent;
258
259
 
259
260
  if (_context3.t0) {
260
- _context3.next = 8;
261
+ _context3.next = 9;
261
262
  break;
262
263
  }
263
264
 
264
265
  _context3.t0 = {};
265
266
 
266
- case 8:
267
+ case 9:
267
268
  _ref5 = _context3.t0;
268
269
  ordersBydate = _ref5.ordersBydate;
269
270
  ordersByStatus = _ref5.ordersByStatus;
@@ -304,13 +305,20 @@ var Dashboard = function Dashboard(_ref) {
304
305
  delete ordersByStatus.total;
305
306
  setRequiredProducts(ordersBydate);
306
307
  setProductsByStatus(ordersByStatus);
308
+ _context3.next = 34;
309
+ break;
310
+
311
+ case 31:
312
+ _context3.prev = 31;
313
+ _context3.t1 = _context3["catch"](0);
314
+ console.log(_context3.t1);
307
315
 
308
- case 28:
316
+ case 34:
309
317
  case "end":
310
318
  return _context3.stop();
311
319
  }
312
320
  }
313
- }, _callee3);
321
+ }, _callee3, null, [[0, 31]]);
314
322
  }));
315
323
 
316
324
  return function loadProductsByStatus(_x2) {
@@ -437,7 +445,15 @@ var Dashboard = function Dashboard(_ref) {
437
445
  }, _callee4);
438
446
  })), []);
439
447
  (0, _react.useEffect)(function () {
440
- (orderByRequired === null || orderByRequired === void 0 ? void 0 : orderByRequired.startDate) && (orderByStatus === null || orderByStatus === void 0 ? void 0 : orderByStatus.endDate) && metricsData.length > 0 && setLoading(false);
448
+ console.log({
449
+ orderByRequired: orderByRequired,
450
+ orderByStatus: orderByStatus,
451
+ metricsData: metricsData
452
+ });
453
+
454
+ if (orderByRequired !== null && orderByRequired !== void 0 && orderByRequired.startDate && orderByStatus !== null && orderByStatus !== void 0 && orderByStatus.endDate && metricsData.length > 0) {
455
+ setLoading(false);
456
+ }
441
457
  }, [orderByRequired, orderByStatus, metricsData]);
442
458
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
443
459
  var startDate, endDate, queryObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.65",
3
+ "version": "21.4.66",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -83,46 +83,50 @@ export const Dashboard = ({ jwt, user, company }) => {
83
83
  };
84
84
 
85
85
  const loadProductsByStatus = async (orderByStatus) => {
86
- const isRetailer = user.is_retailer && company.retailers;
87
- const isProvider = !user.is_retailer && user.id_role === 0;
88
- const isCollaborator = user.id_role > 0;
89
- const { ordersBydate, ordersByStatus, ordersByActive, companyTrades } =
90
- (await loadProductVersions(orderByStatus)) || {};
86
+ try {
87
+ const isRetailer = user.is_retailer && company.retailers;
88
+ const isProvider = !user.is_retailer && user.id_role === 0;
89
+ const isCollaborator = user.id_role > 0;
90
+ const { ordersBydate, ordersByStatus, ordersByActive, companyTrades } =
91
+ (await loadProductVersions(orderByStatus)) || {};
91
92
 
92
- if (trades.length === 0) setTrades(companyTrades);
93
- const { total = 0, R = 0, PA = 0, Ex = 0, ACA = 0 } = ordersByStatus;
94
- let productsFinished = 0;
95
- if (isRetailer) productsFinished = Ex;
96
- if (isProvider) productsFinished = ACA;
97
- if (isCollaborator) productsFinished = Ex + ACA;
93
+ if (trades.length === 0) setTrades(companyTrades);
94
+ const { total = 0, R = 0, PA = 0, Ex = 0, ACA = 0 } = ordersByStatus;
95
+ let productsFinished = 0;
96
+ if (isRetailer) productsFinished = Ex;
97
+ if (isProvider) productsFinished = ACA;
98
+ if (isCollaborator) productsFinished = Ex + ACA;
98
99
 
99
- const inProcess = Object.keys(ordersByStatus).reduce(
100
- (prev, curr) =>
101
- !["total", "PA", "R", "Ex", "ACA"].includes(curr)
102
- ? prev + ordersByStatus[curr]
103
- : prev,
104
- 0
105
- );
100
+ const inProcess = Object.keys(ordersByStatus).reduce(
101
+ (prev, curr) =>
102
+ !["total", "PA", "R", "Ex", "ACA"].includes(curr)
103
+ ? prev + ordersByStatus[curr]
104
+ : prev,
105
+ 0
106
+ );
106
107
 
107
- const registeredProducts = ordersByActive.registered;
108
- let metricsArray = [
109
- metricsData[0]
110
- ? metricsData[0]
111
- : { label: "Productos totales", value: total },
112
- ];
108
+ const registeredProducts = ordersByActive.registered;
109
+ let metricsArray = [
110
+ metricsData[0]
111
+ ? metricsData[0]
112
+ : { label: "Productos totales", value: total },
113
+ ];
113
114
 
114
- metricsArray.push(
115
- { label: "Productos activos", value: registeredProducts },
116
- { label: "Productos filtrados", value: total },
117
- { label: "Productos sin asignar", value: PA + R },
118
- { label: "Productos en proceso", value: inProcess },
119
- { label: "Productos terminados", value: productsFinished }
120
- );
121
- setMetricsData(metricsArray);
122
- setTotalCount(total);
123
- delete ordersByStatus.total;
124
- setRequiredProducts(ordersBydate);
125
- setProductsByStatus(ordersByStatus);
115
+ metricsArray.push(
116
+ { label: "Productos activos", value: registeredProducts },
117
+ { label: "Productos filtrados", value: total },
118
+ { label: "Productos sin asignar", value: PA + R },
119
+ { label: "Productos en proceso", value: inProcess },
120
+ { label: "Productos terminados", value: productsFinished }
121
+ );
122
+ setMetricsData(metricsArray);
123
+ setTotalCount(total);
124
+ delete ordersByStatus.total;
125
+ setRequiredProducts(ordersBydate);
126
+ setProductsByStatus(ordersByStatus);
127
+ } catch (err) {
128
+ console.log(err);
129
+ }
126
130
  };
127
131
 
128
132
  const datesSelect = () => {
@@ -223,10 +227,14 @@ export const Dashboard = ({ jwt, user, company }) => {
223
227
  }, []);
224
228
 
225
229
  useEffect(() => {
226
- orderByRequired?.startDate &&
230
+ console.log({ orderByRequired, orderByStatus, metricsData });
231
+ if (
232
+ orderByRequired?.startDate &&
227
233
  orderByStatus?.endDate &&
228
- metricsData.length > 0 &&
234
+ metricsData.length > 0
235
+ ) {
229
236
  setLoading(false);
237
+ }
230
238
  }, [orderByRequired, orderByStatus, metricsData]);
231
239
 
232
240
  useEffect(async () => {