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 =
|
|
254
|
+
_context3.next = 6;
|
|
254
255
|
return loadProductVersions(orderByStatus);
|
|
255
256
|
|
|
256
|
-
case
|
|
257
|
+
case 6:
|
|
257
258
|
_context3.t0 = _context3.sent;
|
|
258
259
|
|
|
259
260
|
if (_context3.t0) {
|
|
260
|
-
_context3.next =
|
|
261
|
+
_context3.next = 9;
|
|
261
262
|
break;
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
_context3.t0 = {};
|
|
265
266
|
|
|
266
|
-
case
|
|
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
|
|
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
|
-
|
|
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
|
@@ -83,46 +83,50 @@ export const Dashboard = ({ jwt, user, company }) => {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
const loadProductsByStatus = async (orderByStatus) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
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 () => {
|