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
|
|
181
|
-
_context.prev =
|
|
183
|
+
case 13:
|
|
184
|
+
_context.prev = 13;
|
|
182
185
|
_context.t0 = _context["catch"](5);
|
|
183
186
|
console.log(_context.t0);
|
|
184
187
|
|
|
185
|
-
case
|
|
188
|
+
case 16:
|
|
186
189
|
case "end":
|
|
187
190
|
return _context.stop();
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
|
-
}, _callee, null, [[5,
|
|
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 =
|
|
257
|
+
_context3.next = 6;
|
|
254
258
|
return loadProductVersions(orderByStatus);
|
|
255
259
|
|
|
256
|
-
case
|
|
260
|
+
case 6:
|
|
257
261
|
_context3.t0 = _context3.sent;
|
|
258
262
|
|
|
259
263
|
if (_context3.t0) {
|
|
260
|
-
_context3.next =
|
|
264
|
+
_context3.next = 9;
|
|
261
265
|
break;
|
|
262
266
|
}
|
|
263
267
|
|
|
264
268
|
_context3.t0 = {};
|
|
265
269
|
|
|
266
|
-
case
|
|
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
|
|
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
|
|
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
|
@@ -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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
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 () => {
|