contentoh-components-library 21.3.11 → 21.3.12

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.
@@ -148,7 +148,6 @@ var Footer = function Footer(props) {
148
148
  var containerRef = (0, _react.useRef)();
149
149
  var refInputTextMessage = (0, _react.useRef)();
150
150
  (0, _react.useEffect)(function () {
151
- //console.log("filesPreview: ", filesPreview.slice());
152
151
  setTooltipFileName({
153
152
  show: false,
154
153
  fileName: ""
@@ -171,7 +170,7 @@ var Footer = function Footer(props) {
171
170
  switch (_context.prev = _context.next) {
172
171
  case 0:
173
172
  if (!createItemsChat) {
174
- _context.next = 89;
173
+ _context.next = 87;
175
174
  break;
176
175
  }
177
176
 
@@ -195,9 +194,7 @@ var Footer = function Footer(props) {
195
194
 
196
195
  customFiles = [];
197
196
  _context.prev = 7;
198
- //console.log("files:", files);
199
- fileUploadRequests = []; //console.log(dataChat);
200
-
197
+ fileUploadRequests = [];
201
198
  _iterator = (0, _createForOfIteratorHelper2.default)(files);
202
199
  _context.prev = 10;
203
200
 
@@ -272,8 +269,7 @@ var Footer = function Footer(props) {
272
269
  fileKey += "".concat((0, _uuid.v4)(), "-").concat(today.getTime(), ".").concat((0, _utils.getFileExtension)(file.name));
273
270
  } else {
274
271
  fileKey = undefined;
275
- } //console.log("fileKey: ", fileKey);
276
- // enviar file a AWS
272
+ } // enviar file a AWS
277
273
 
278
274
 
279
275
  customFiles.push({
@@ -316,7 +312,6 @@ var Footer = function Footer(props) {
316
312
 
317
313
  case 49:
318
314
  responseAWS = _context.sent;
319
- console.log("responseAWS:", responseAWS);
320
315
  responseAWS.forEach(function (responseFile, index) {
321
316
  if (responseFile.status === "rejected") {
322
317
  customFiles[index].errorAWS = responseFile.reason.message;
@@ -324,13 +319,12 @@ var Footer = function Footer(props) {
324
319
  } else {
325
320
  customFiles[index].uploaded = true;
326
321
  }
327
- }); //console.log("customFiles:", customFiles);
328
-
329
- _context.next = 59;
322
+ });
323
+ _context.next = 58;
330
324
  break;
331
325
 
332
- case 54:
333
- _context.prev = 54;
326
+ case 53:
327
+ _context.prev = 53;
334
328
  _context.t2 = _context["catch"](7);
335
329
  disableSecondaryContainer(false);
336
330
  setModalAlert({
@@ -341,21 +335,21 @@ var Footer = function Footer(props) {
341
335
  });
342
336
  return _context.abrupt("return");
343
337
 
344
- case 59:
338
+ case 58:
345
339
  // obtener las keys de los files subidos
346
340
  items = [];
347
341
  index = 0;
348
342
 
349
- case 61:
343
+ case 60:
350
344
  if (!(index < customFiles.length)) {
351
- _context.next = 75;
345
+ _context.next = 73;
352
346
  break;
353
347
  }
354
348
 
355
349
  _file = customFiles[index];
356
350
 
357
351
  if (!_file.uploaded) {
358
- _context.next = 72;
352
+ _context.next = 70;
359
353
  break;
360
354
  }
361
355
 
@@ -365,14 +359,14 @@ var Footer = function Footer(props) {
365
359
  }; // caso imagen -> obtener width y height
366
360
 
367
361
  if (!(_file.itemType === "img")) {
368
- _context.next = 70;
362
+ _context.next = 69;
369
363
  break;
370
364
  }
371
365
 
372
- _context.next = 68;
366
+ _context.next = 67;
373
367
  return (0, _utils.getImageSize)(files[index]);
374
368
 
375
- case 68:
369
+ case 67:
376
370
  imgSize = _context.sent;
377
371
 
378
372
  if (imgSize) {
@@ -380,32 +374,31 @@ var Footer = function Footer(props) {
380
374
  valueItem.height = imgSize.height;
381
375
  }
382
376
 
383
- case 70:
384
- console.log("valueItemFile:", valueItem);
377
+ case 69:
385
378
  items.push({
386
379
  type: _file.itemType,
387
380
  value: JSON.stringify(valueItem)
388
381
  });
389
382
 
390
- case 72:
383
+ case 70:
391
384
  index++;
392
- _context.next = 61;
385
+ _context.next = 60;
393
386
  break;
394
387
 
395
- case 75:
388
+ case 73:
396
389
  if (!items.length) {
397
- _context.next = 83;
390
+ _context.next = 81;
398
391
  break;
399
392
  }
400
393
 
401
- _context.next = 78;
394
+ _context.next = 76;
402
395
  return createItemsChat(items);
403
396
 
404
- case 78:
397
+ case 76:
405
398
  responseError = _context.sent;
406
399
 
407
400
  if (!responseError) {
408
- _context.next = 83;
401
+ _context.next = 81;
409
402
  break;
410
403
  }
411
404
 
@@ -418,7 +411,7 @@ var Footer = function Footer(props) {
418
411
  disableSecondaryContainer(false);
419
412
  return _context.abrupt("return");
420
413
 
421
- case 83:
414
+ case 81:
422
415
  // obtener los errores de los files no subidos a AWS
423
416
  failedFiles = [];
424
417
  errorDetailFiles = "";
@@ -447,12 +440,12 @@ var Footer = function Footer(props) {
447
440
  disableSecondaryContainer(false);
448
441
  setFilesPreview(failedFiles);
449
442
 
450
- case 89:
443
+ case 87:
451
444
  case "end":
452
445
  return _context.stop();
453
446
  }
454
447
  }
455
- }, _callee, null, [[7, 54], [10, 41, 44, 47]]);
448
+ }, _callee, null, [[7, 53], [10, 41, 44, 47]]);
456
449
  }));
457
450
 
458
451
  return function sendFilesPreview() {
@@ -696,7 +689,6 @@ var Footer = function Footer(props) {
696
689
  while (1) {
697
690
  switch (_context7.prev = _context7.next) {
698
691
  case 0:
699
- //console.log("selected files: ", selectedFiles);
700
692
  newFiles = filesPreview.slice();
701
693
  newFiles = newFiles.concat(selectedFiles);
702
694
  setFilesPreview(newFiles);
@@ -50,8 +50,7 @@ var fetchGET = function fetchGET() {
50
50
  } else {
51
51
  URL += "&".concat(key, "=").concat(paramsQuery[key]);
52
52
  }
53
- }); //console.log("URL:", URL);
54
-
53
+ });
55
54
  _context.next = 6;
56
55
  return _axios.default.get(URL, {
57
56
  headers: paramsHeaders
@@ -164,35 +163,34 @@ var fetchPOST = function fetchPOST() {
164
163
  body = JSON.parse(respHTTPjson.data.body); // verificar si existe error desde el backend
165
164
 
166
165
  if (!(respHTTPjson.data.statusCode !== 200)) {
167
- _context2.next = 10;
166
+ _context2.next = 9;
168
167
  break;
169
168
  }
170
169
 
171
- console.log(body);
172
170
  return _context2.abrupt("return", response({
173
171
  message: (_body$message2 = body.message) !== null && _body$message2 !== void 0 ? _body$message2 : "",
174
172
  errorDetail: (_body$errorDetail2 = body.errorDetail) !== null && _body$errorDetail2 !== void 0 ? _body$errorDetail2 : ""
175
173
  }));
176
174
 
177
- case 10:
175
+ case 9:
178
176
  return _context2.abrupt("return", response({
179
177
  body: body
180
178
  }));
181
179
 
182
- case 13:
183
- _context2.prev = 13;
180
+ case 12:
181
+ _context2.prev = 12;
184
182
  _context2.t0 = _context2["catch"](0);
185
183
  return _context2.abrupt("return", response({
186
184
  message: "Error al guardar los datos",
187
185
  errorDetail: _context2.t0.message
188
186
  }));
189
187
 
190
- case 16:
188
+ case 15:
191
189
  case "end":
192
190
  return _context2.stop();
193
191
  }
194
192
  }
195
- }, _callee2, null, [[0, 13]]);
193
+ }, _callee2, null, [[0, 12]]);
196
194
  }));
197
195
 
198
196
  return function (_x2) {
@@ -226,14 +226,7 @@ obtener el nuevo <height> de la imagen
226
226
  exports.getImageSize = getImageSize;
227
227
 
228
228
  var getResizeImgHeight = function getResizeImgHeight(originalWidth, originalHeight, newWidth) {
229
- /*
230
- console.log(`==================
231
- original width: ${originalWidth}
232
- original height: ${originalHeight}
233
- newWidth: ${newWidth}`);
234
- */
235
- var scale = newWidth * 100 / originalWidth / 100; //console.log("scale:", scale);
236
-
229
+ var scale = newWidth * 100 / originalWidth / 100;
237
230
  return Math.ceil(originalHeight * scale);
238
231
  };
239
232
  /*====================================================================
@@ -397,7 +390,8 @@ exports.getCustomDate = getCustomDate;
397
390
 
398
391
  var getTime = function getTime() {
399
392
  var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
400
- if ([undefined, null, ""].includes(time)) return (0, _moment.default)(new Date()).format("LT");else return (0, _moment.default)(time).format("LT");
393
+ if ([undefined, null, ""].includes(time)) return (0, _moment.default)(new Date()).format("LT");
394
+ return (0, _moment.default)(time).format("LT");
401
395
  };
402
396
  /*====================================================================
403
397
  UTILERIAS PARA EL MANEJO DE VALIDACIONES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.3.11",
3
+ "version": "21.3.12",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -35,8 +35,7 @@ export const ButtonFileChooser = (props) => {
35
35
  chooser.style.display = "none";
36
36
  if (multipleFiles) chooser.multiple = true;
37
37
  if (filters) chooser.accept = filters; // "image/*,text/*,application/*"
38
- chooser.onchange = async (event) => {
39
- //console.log("files:", chooser.files);
38
+ chooser.onchange = async () => {
40
39
  for (const file of chooser.files) {
41
40
  files.push(file);
42
41
  }
@@ -85,19 +85,6 @@ export const ImagePreview = (props) => {
85
85
  document.body.removeChild(link);
86
86
  };
87
87
 
88
- /* solo para hacer pruebas en modo dev
89
- useEffect(() => {
90
- setTimeout(() => {
91
- setLoading(false);
92
- }, 5000);
93
- }, []); */
94
- /*
95
- useEffect(() => {
96
- console.log("imgURL:", imgURL);
97
- console.log("modalImgURL:", modalImgURL);
98
- }, []);
99
- */
100
-
101
88
  return (
102
89
  <Container className={className} width={width}>
103
90
  {imgURL && (imgLoad === undefined || loading) && (
@@ -72,13 +72,11 @@ export const ButtonDownloadFile = (props) => {
72
72
  onMouseEnter={(event) => {
73
73
  if (!showDownload) {
74
74
  setShowDownload(true);
75
- //console.log("showDownload");
76
75
  }
77
76
  }}
78
77
  onMouseLeave={(event) => {
79
78
  if (!loading) {
80
79
  setShowDownload(false);
81
- //console.log("showIconFile");
82
80
  }
83
81
  }}
84
82
  >
@@ -50,34 +50,10 @@ export const ContainerItems = (props) => {
50
50
  });
51
51
  const containerList = useRef(null);
52
52
 
53
- /*
54
- useEffect(() => {
55
- //console.log("new observer");
56
- const observer = new MutationObserver((mutationList) => {
57
- updateScroll();
58
- });
59
- const itemsList = document.getElementById("ulItems");
60
- const observerOptions = {
61
- attributes: false,
62
- childList: true,
63
- subtree: false,
64
- characterData: false,
65
- attributeOldValue: false,
66
- characterDataOldValue: false,
67
- };
68
- observer.observe(itemsList, observerOptions);
69
-
70
- return () => {
71
- observer.disconnect();
72
- //console.log("remove observer");
73
- };
74
- }, [scrollHeight]);
75
- */
76
53
 
77
54
  useEffect(() => {
78
55
  if (!items) return;
79
- if (chatType === "merchant_product") renderItems();
80
- else if (chatType === "order_product") renderItems();
56
+ if (["merchant_product", "order_product"].includes(chatType)) renderItems();
81
57
  else if (chatType === "ticket") renderItemsTicket();
82
58
  else setCustomItems([]);
83
59
  }, [items]);
@@ -88,14 +64,6 @@ export const ContainerItems = (props) => {
88
64
  const newScrollHeight = containerScroll.scrollHeight + 15;
89
65
  const positionScroll = newScrollHeight - scrollHeight;
90
66
 
91
- /*
92
- console.log("========");
93
- console.log("old:", scrollHeight);
94
- console.log("new:", newScrollHeight);
95
- console.log("pos:", positionScroll);
96
- console.log("========");
97
- */
98
-
99
67
  if (newScrollHeight !== scrollHeight) {
100
68
  containerScroll.scrollTop = positionScroll;
101
69
  setScrollHeight(newScrollHeight);
@@ -182,7 +150,6 @@ export const ContainerItems = (props) => {
182
150
  value.height ?? 400,
183
151
  400
184
152
  );
185
- //console.log("newHeight imgURL:", imgHeight);
186
153
  const imgURL = getImageURL(
187
154
  process.env.REACT_APP_IMAGES_BUCKET,
188
155
  value.key,
@@ -195,7 +162,6 @@ export const ContainerItems = (props) => {
195
162
  value.height ?? screen.height,
196
163
  screen.width
197
164
  );
198
- //console.log("height full:", modalImgHeight);
199
165
  const modalImgURL = getImageURL(
200
166
  process.env.REACT_APP_IMAGES_BUCKET,
201
167
  value.key,
@@ -316,7 +282,7 @@ export const ContainerItems = (props) => {
316
282
  <li
317
283
  className={
318
284
  (ownMessage ? "own-message " : "") +
319
- (lastUserId == item.userId ? "sameUser" : "")
285
+ (lastUserId === item.userId ? "sameUser" : "")
320
286
  }
321
287
  >
322
288
  {/* img del user */}
@@ -387,10 +353,11 @@ export const ContainerItems = (props) => {
387
353
  // manejo de las etiquetas fechas
388
354
  if (!date) {
389
355
  date = getFullDate(new Date(item.date));
356
+ jsxItems.push(renderGrayLabel(date, `itemDate-${countDate++}`));
390
357
  } else {
391
358
  let newDate = getFullDate(new Date(item.date));
392
359
  if (newDate !== date) {
393
- jsxItems.push(renderGrayLabel(date, `itemDate-${countDate++}`));
360
+ jsxItems.push(renderGrayLabel(newDate, `itemDate-${countDate++}`));
394
361
  date = newDate;
395
362
  }
396
363
  }
@@ -399,25 +366,25 @@ export const ContainerItems = (props) => {
399
366
  switch (item.type) {
400
367
  case "statusArticle":
401
368
  jsxItems.push(renderStatusArticle(item.value, `item-${item.id}`));
402
- continue;
369
+ break;
403
370
  case "statusService":
404
371
  jsxItems.push(renderStatusService(item.value, `item-${item.id}`));
405
- continue;
372
+ break;
406
373
  }
407
374
 
408
375
  // acomodo del item (left o right)
409
376
  let ownMessage = false;
410
377
  // CHAT MERCHANT ARTICLE
411
378
  if (chatType === "merchant_product") {
412
- if (currentUser.companyId == users[item.userId].companyId) {
379
+ if (currentUser.companyId === users[item.userId].companyId) {
413
380
  ownMessage = true;
414
381
  }
415
382
  }
416
383
  // CHAT ORDER ARTICLE
417
384
  else if (chatType === "order_product") {
418
- if (currentUser.companyId == users[item.userId].companyId) {
419
- if (activeCompanyId && activeCompanyId == currentUser.companyId) {
420
- if (item.userId == currentUser.id) {
385
+ if (currentUser.companyId === users[item.userId].companyId) {
386
+ if (activeCompanyId && activeCompanyId === currentUser.companyId) {
387
+ if (item.userId === currentUser.id) {
421
388
  ownMessage = true;
422
389
  }
423
390
  } else {
@@ -429,10 +396,6 @@ export const ContainerItems = (props) => {
429
396
  // renderizar tipo de item
430
397
  jsxItems.push(getUserCreatedItem(ownMessage, item));
431
398
  }
432
- if (date)
433
- jsxItems.push(
434
- renderGrayLabel(date, `itemDate-${countDate}`, "label-date")
435
- );
436
399
  setCustomItems(jsxItems);
437
400
  };
438
401
 
@@ -441,7 +404,7 @@ export const ContainerItems = (props) => {
441
404
  let date = undefined;
442
405
  let countDate = 1;
443
406
  let lastUserId = undefined;
444
- //console.log("isUserTech:", currentUser.isUserTech);
407
+
445
408
 
446
409
  // recorrido de los items (del mas viejo al mas reciente)
447
410
  for (let index = items.length - 1; index >= 0; index--) {
@@ -479,16 +442,15 @@ export const ContainerItems = (props) => {
479
442
  // user normal
480
443
  else {
481
444
  if (!isUserTech(users[item.userId].isUserTech)) {
482
- if (currentUser.companyId == users[item.userId].companyId) {
445
+ if (currentUser.companyId === users[item.userId].companyId) {
483
446
  ownMessage = true;
484
447
  }
485
- } else if (currentUser.id == item.userId) {
448
+ } else if (currentUser.id === item.userId) {
486
449
  ownMessage = true;
487
450
  }
488
451
  }
489
452
 
490
453
  // renderizar tipo de item
491
- //console.log(lastUserId + "<>" + item.userId);
492
454
  jsxItems.push(getUserCreatedItem(ownMessage, item, lastUserId));
493
455
  lastUserId = item.userId;
494
456
  }