contentoh-components-library 21.4.65 → 21.4.67

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.
@@ -175,19 +175,22 @@ var Dashboard = function Dashboard(_ref) {
175
175
 
176
176
  case 8:
177
177
  response = _context.sent;
178
+ console.log({
179
+ res: JSON.parse(response.data.body).data
180
+ });
178
181
  return _context.abrupt("return", JSON.parse(response.data.body).data);
179
182
 
180
- case 12:
181
- _context.prev = 12;
183
+ case 13:
184
+ _context.prev = 13;
182
185
  _context.t0 = _context["catch"](5);
183
186
  console.log(_context.t0);
184
187
 
185
- case 15:
188
+ case 16:
186
189
  case "end":
187
190
  return _context.stop();
188
191
  }
189
192
  }
190
- }, _callee, null, [[5, 12]]);
193
+ }, _callee, null, [[5, 13]]);
191
194
  }));
192
195
 
193
196
  return function loadProductVersions(_x) {
@@ -247,28 +250,35 @@ var Dashboard = function Dashboard(_ref) {
247
250
  while (1) {
248
251
  switch (_context3.prev = _context3.next) {
249
252
  case 0:
253
+ _context3.prev = 0;
250
254
  isRetailer = user.is_retailer && company.retailers;
251
255
  isProvider = !user.is_retailer && user.id_role === 0;
252
256
  isCollaborator = user.id_role > 0;
253
- _context3.next = 5;
257
+ _context3.next = 6;
254
258
  return loadProductVersions(orderByStatus);
255
259
 
256
- case 5:
260
+ case 6:
257
261
  _context3.t0 = _context3.sent;
258
262
 
259
263
  if (_context3.t0) {
260
- _context3.next = 8;
264
+ _context3.next = 9;
261
265
  break;
262
266
  }
263
267
 
264
268
  _context3.t0 = {};
265
269
 
266
- case 8:
270
+ case 9:
267
271
  _ref5 = _context3.t0;
268
272
  ordersBydate = _ref5.ordersBydate;
269
273
  ordersByStatus = _ref5.ordersByStatus;
270
274
  ordersByActive = _ref5.ordersByActive;
271
275
  companyTrades = _ref5.companyTrades;
276
+ console.log({
277
+ ordersBydate: ordersBydate,
278
+ ordersByStatus: ordersByStatus,
279
+ ordersByActive: ordersByActive,
280
+ companyTrades: companyTrades
281
+ });
272
282
  if (trades.length === 0) setTrades(companyTrades);
273
283
  _ordersByStatus$total = ordersByStatus.total, total = _ordersByStatus$total === void 0 ? 0 : _ordersByStatus$total, _ordersByStatus$R = ordersByStatus.R, R = _ordersByStatus$R === void 0 ? 0 : _ordersByStatus$R, _ordersByStatus$PA = ordersByStatus.PA, PA = _ordersByStatus$PA === void 0 ? 0 : _ordersByStatus$PA, _ordersByStatus$Ex = ordersByStatus.Ex, Ex = _ordersByStatus$Ex === void 0 ? 0 : _ordersByStatus$Ex, _ordersByStatus$ACA = ordersByStatus.ACA, ACA = _ordersByStatus$ACA === void 0 ? 0 : _ordersByStatus$ACA;
274
284
  productsFinished = 0;
@@ -302,15 +312,26 @@ var Dashboard = function Dashboard(_ref) {
302
312
  setMetricsData(metricsArray);
303
313
  setTotalCount(total);
304
314
  delete ordersByStatus.total;
315
+ console.log({
316
+ ordersBydate: ordersBydate,
317
+ ordersByStatus: ordersByStatus
318
+ });
305
319
  setRequiredProducts(ordersBydate);
306
320
  setProductsByStatus(ordersByStatus);
321
+ _context3.next = 36;
322
+ break;
323
+
324
+ case 33:
325
+ _context3.prev = 33;
326
+ _context3.t1 = _context3["catch"](0);
327
+ console.log("Ismael", _context3.t1);
307
328
 
308
- case 28:
329
+ case 36:
309
330
  case "end":
310
331
  return _context3.stop();
311
332
  }
312
333
  }
313
- }, _callee3);
334
+ }, _callee3, null, [[0, 33]]);
314
335
  }));
315
336
 
316
337
  return function loadProductsByStatus(_x2) {
@@ -437,7 +458,9 @@ var Dashboard = function Dashboard(_ref) {
437
458
  }, _callee4);
438
459
  })), []);
439
460
  (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);
461
+ if (orderByRequired !== null && orderByRequired !== void 0 && orderByRequired.startDate && orderByStatus !== null && orderByStatus !== void 0 && orderByStatus.endDate && metricsData.length > 0) {
462
+ setLoading(false);
463
+ }
441
464
  }, [orderByRequired, orderByStatus, metricsData]);
442
465
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
443
466
  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.67",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -55,6 +55,7 @@ export const Dashboard = ({ jwt, user, company }) => {
55
55
  Authorization: jwt,
56
56
  },
57
57
  });
58
+ console.log({ res: JSON.parse(response.data.body).data });
58
59
  return JSON.parse(response.data.body).data;
59
60
  } catch (error) {
60
61
  console.log(error);
@@ -83,46 +84,57 @@ export const Dashboard = ({ jwt, user, company }) => {
83
84
  };
84
85
 
85
86
  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)) || {};
87
+ try {
88
+ const isRetailer = user.is_retailer && company.retailers;
89
+ const isProvider = !user.is_retailer && user.id_role === 0;
90
+ const isCollaborator = user.id_role > 0;
91
+ const { ordersBydate, ordersByStatus, ordersByActive, companyTrades } =
92
+ (await loadProductVersions(orderByStatus)) || {};
93
+ console.log({
94
+ ordersBydate,
95
+ ordersByStatus,
96
+ ordersByActive,
97
+ companyTrades,
98
+ });
91
99
 
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;
100
+ if (trades.length === 0) setTrades(companyTrades);
101
+ const { total = 0, R = 0, PA = 0, Ex = 0, ACA = 0 } = ordersByStatus;
102
+ let productsFinished = 0;
103
+ if (isRetailer) productsFinished = Ex;
104
+ if (isProvider) productsFinished = ACA;
105
+ if (isCollaborator) productsFinished = Ex + ACA;
98
106
 
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
- );
107
+ const inProcess = Object.keys(ordersByStatus).reduce(
108
+ (prev, curr) =>
109
+ !["total", "PA", "R", "Ex", "ACA"].includes(curr)
110
+ ? prev + ordersByStatus[curr]
111
+ : prev,
112
+ 0
113
+ );
106
114
 
107
- const registeredProducts = ordersByActive.registered;
108
- let metricsArray = [
109
- metricsData[0]
110
- ? metricsData[0]
111
- : { label: "Productos totales", value: total },
112
- ];
115
+ const registeredProducts = ordersByActive.registered;
116
+ let metricsArray = [
117
+ metricsData[0]
118
+ ? metricsData[0]
119
+ : { label: "Productos totales", value: total },
120
+ ];
113
121
 
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);
122
+ metricsArray.push(
123
+ { label: "Productos activos", value: registeredProducts },
124
+ { label: "Productos filtrados", value: total },
125
+ { label: "Productos sin asignar", value: PA + R },
126
+ { label: "Productos en proceso", value: inProcess },
127
+ { label: "Productos terminados", value: productsFinished }
128
+ );
129
+ setMetricsData(metricsArray);
130
+ setTotalCount(total);
131
+ delete ordersByStatus.total;
132
+ console.log({ ordersBydate, ordersByStatus });
133
+ setRequiredProducts(ordersBydate);
134
+ setProductsByStatus(ordersByStatus);
135
+ } catch (err) {
136
+ console.log("Ismael", err);
137
+ }
126
138
  };
127
139
 
128
140
  const datesSelect = () => {
@@ -223,10 +235,13 @@ export const Dashboard = ({ jwt, user, company }) => {
223
235
  }, []);
224
236
 
225
237
  useEffect(() => {
226
- orderByRequired?.startDate &&
238
+ if (
239
+ orderByRequired?.startDate &&
227
240
  orderByStatus?.endDate &&
228
- metricsData.length > 0 &&
241
+ metricsData.length > 0
242
+ ) {
229
243
  setLoading(false);
244
+ }
230
245
  }, [orderByRequired, orderByStatus, metricsData]);
231
246
 
232
247
  useEffect(async () => {