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.
@@ -68,7 +68,6 @@ export const ContentChat = (props) => {
68
68
  // matar update al desmontar el componente del chat
69
69
  useEffect(() => {
70
70
  return () => {
71
- console.log("componente chat desmontado");
72
71
  if (processUpdateID !== undefined) clearTimeout(processUpdateID);
73
72
  };
74
73
  }, []);
@@ -96,9 +95,8 @@ export const ContentChat = (props) => {
96
95
  useEffect(() => {
97
96
  //return; -- descomentarizar para hacer pruebas sin update
98
97
  if (startUpdate == 0) return;
99
- console.log("START UPDATE en 5s");
100
98
  const processID = setTimeout(() => {
101
- console.log("update");
99
+ console.log("update chat execute");
102
100
  setRunUpdate((prev) => prev + 1);
103
101
  }, 5000);
104
102
  setProcessUpdateID(processID);
@@ -146,7 +144,6 @@ export const ContentChat = (props) => {
146
144
  return;
147
145
  }
148
146
  // success
149
- console.log(response.body);
150
147
  setCurrentUser({
151
148
  id: response.body.data.currentUserId,
152
149
  companyId: response.body.data.currentCompanyId,
@@ -187,7 +184,6 @@ export const ContentChat = (props) => {
187
184
  return;
188
185
  }
189
186
  // success
190
- console.log(response.body);
191
187
  setCurrentUser({
192
188
  id: response.body.data.currentUserId,
193
189
  companyId: response.body.data.currentCompanyId,
@@ -216,8 +212,6 @@ export const ContentChat = (props) => {
216
212
  if (!companyActive && companiesIdList.length) {
217
213
  companyActive = Number(companiesIdList[0]);
218
214
  }
219
- //console.log("companies: ", companiesList);
220
- //console.log("companyActive: ", companyActive);
221
215
  setCompanies(companiesList);
222
216
  if (companyActive) setActiveCompanyId(companyActive);
223
217
  setErrorChat({ existError: false });
@@ -225,21 +219,12 @@ export const ContentChat = (props) => {
225
219
  };
226
220
 
227
221
  const getInitialTicket = async () => {
228
- console.log("\n======== INITIAL chat =======");
229
222
  stopUpdate(); // finalizamos el temporizador
230
223
  const dataUser = {
231
224
  id: dataChat.currentUser?.id,
232
225
  companyId: dataChat.currentUser?.companyId,
233
226
  isUserTech: dataChat.currentUser?.isUserTech,
234
227
  };
235
- /*
236
- console.log("values send query:", {
237
- id: dataChat.id,
238
- getType: "initial",
239
- currentUser: dataUser,
240
- currentItemsFront: getItemsIdSingleChat(),
241
- });
242
- */
243
228
  const paramsQuery = {
244
229
  id: JSON.stringify(dataChat.id),
245
230
  getType: "initial",
@@ -264,7 +249,6 @@ export const ContentChat = (props) => {
264
249
  return;
265
250
  }
266
251
  // success
267
- console.log("response initial:", response.body);
268
252
  setLastUpdateDate(response.body.data.lastUpdateDate);
269
253
  setAllUsers(response.body.users);
270
254
  setSingleChat({
@@ -300,7 +284,6 @@ export const ContentChat = (props) => {
300
284
  };
301
285
  }
302
286
  // success
303
- console.log(response.body);
304
287
  // actualizar la lista de los users
305
288
  updateAllUsers(response.body.users);
306
289
  // actualizar los items del chat
@@ -338,7 +321,6 @@ export const ContentChat = (props) => {
338
321
  };
339
322
  }
340
323
  // success
341
- console.log(response.body);
342
324
  // actualizar la lista de los users
343
325
  updateAllUsers(response.body.users);
344
326
  // actualizar los items del chat y la lista de users
@@ -352,7 +334,6 @@ export const ContentChat = (props) => {
352
334
 
353
335
  // este GET obtiene la lista de compañoas con las que se puede chatear
354
336
  const getLoadMoreTicket = async () => {
355
- console.log("\n======== LOAD MORE chat =======");
356
337
  stopUpdate(); // finalizamos el temporizador
357
338
  let date = singleChat.items[singleChat.items.length - 1].date;
358
339
  const dataUser = {
@@ -381,7 +362,6 @@ export const ContentChat = (props) => {
381
362
  };
382
363
  }
383
364
  // success
384
- console.log("response loadMore:", response.body);
385
365
  // actualizar la lista de los users
386
366
  updateAllUsers(response.body.users);
387
367
  // actualizar los items del chat
@@ -398,7 +378,6 @@ export const ContentChat = (props) => {
398
378
  PETICION GET UPDATE_LATEST SEGUN EL TIPO DE CHAT
399
379
  ======================================================================= */
400
380
  const getUpdateLatestMerchantProduct = async () => {
401
- console.log(lastUpdateDate);
402
381
  const paramsQuery = {
403
382
  getType: "updateLatest",
404
383
  id: JSON.stringify(dataChat.id),
@@ -417,7 +396,6 @@ export const ContentChat = (props) => {
417
396
  return;
418
397
  }
419
398
  // success
420
- console.log(response.body);
421
399
  setLastUpdateDate(response.body.data.lastUpdateDate);
422
400
  // actualizar la lista de los users
423
401
  updateAllUsers(response.body.users);
@@ -431,7 +409,6 @@ export const ContentChat = (props) => {
431
409
  };
432
410
 
433
411
  const getUpdateLatestOrderProduct = async () => {
434
- console.log(lastUpdateDate);
435
412
  const paramsQuery = {
436
413
  getType: "updateLatest",
437
414
  id: JSON.stringify(dataChat.id),
@@ -457,7 +434,6 @@ export const ContentChat = (props) => {
457
434
  return;
458
435
  }
459
436
  // success
460
- console.log(response.body);
461
437
 
462
438
  // cuando cambie la lista de chats por un cambio de version o estatus
463
439
  if (response.body.data.status) {
@@ -487,8 +463,6 @@ export const ContentChat = (props) => {
487
463
  if (!companyActive && companiesIdList.length) {
488
464
  companyActive = Number(companiesIdList[0]);
489
465
  }
490
- //console.log("new companies: ", companiesList);
491
- //console.log("new companyActive: ", companyActive);
492
466
  setCompanies(companiesList);
493
467
  if (companyActive) setActiveCompanyId(companyActive);
494
468
  setErrorChat({ existError: false });
@@ -508,28 +482,16 @@ export const ContentChat = (props) => {
508
482
  response.body.companies[companyId].items
509
483
  );
510
484
  });
511
- //console.log("new items companies: ", companiesList);
512
485
  setCompanies(companiesList);
513
486
  }
514
487
  };
515
488
 
516
489
  const getUpdateLatestTicket = async () => {
517
- console.log("\n======== UPDATE chat =======");
518
- console.log("lastUpdate:", lastUpdateDate);
519
490
  const dataUser = {
520
491
  id: dataChat.currentUser?.id,
521
492
  companyId: dataChat.currentUser?.companyId,
522
493
  isUserTech: dataChat.currentUser?.isUserTech,
523
494
  };
524
- /*
525
- console.log("values send query:", {
526
- id: dataChat.id,
527
- getType: "updateLatest",
528
- date: lastUpdateDate,
529
- currentUser: dataUser,
530
- currentItemsFront: getItemsIdSingleChat(),
531
- });
532
- */
533
495
  const paramsQuery = {
534
496
  id: JSON.stringify(dataChat.id),
535
497
  getType: "updateLatest",
@@ -566,7 +528,6 @@ export const ContentChat = (props) => {
566
528
  setErrorUpdate({});
567
529
  }
568
530
  // success
569
- //console.log("response update:", response.body);
570
531
  setLastUpdateDate(response.body.data.lastUpdateDate);
571
532
  // actualizar la lista de los users
572
533
  updateAllUsers(response.body.users);
@@ -618,8 +579,6 @@ export const ContentChat = (props) => {
618
579
  };
619
580
  }
620
581
  }
621
- console.log("======= create items ========");
622
- console.log("items a enviar:", items);
623
582
  let errorCreate;
624
583
  stopUpdate(); // finalizamos el temporizador
625
584
 
@@ -644,7 +603,6 @@ export const ContentChat = (props) => {
644
603
  };
645
604
 
646
605
  const createItemsMerchantProduct = async (items = []) => {
647
- console.log("create items merchants");
648
606
  const paramsBody = {
649
607
  id: JSON.stringify(dataChat.id),
650
608
  version: JSON.stringify(dataChat.version),
@@ -664,7 +622,6 @@ export const ContentChat = (props) => {
664
622
  };
665
623
 
666
624
  const createItemsOrderProduct = async (items = []) => {
667
- console.log("create items order");
668
625
  const paramsBody = {
669
626
  id: JSON.stringify(dataChat.id),
670
627
  version: JSON.stringify(currentArticle.version),
@@ -674,7 +631,6 @@ export const ContentChat = (props) => {
674
631
  sentCompanyId: JSON.stringify(currentUser.companyId),
675
632
  receivedCompanyId: JSON.stringify(activeCompanyId),
676
633
  };
677
- console.log(paramsBody);
678
634
  const response = await fetchPOST(
679
635
  process.env.REACT_APP_PRODUCTS_CHAT_ENDPOINT,
680
636
  paramsBody
@@ -751,23 +707,18 @@ export const ContentChat = (props) => {
751
707
  itemsId[item.id] = true;
752
708
  }
753
709
  });
754
- //console.log("newItems: ", items);
755
710
  return items;
756
711
  };
757
712
 
758
713
  const addNewItemsChat = (currentItems = [], newItems = []) => {
759
714
  let items = currentItems.slice();
760
- let itemsId = {};
761
- items.forEach((item) => {
762
- itemsId[item.id] = true;
763
- });
715
+ let itemsId = items.map((item) => item.id);
764
716
  for (let i = newItems.length - 1; i >= 0; i--) {
765
- if (!itemsId[newItems[i].id]) {
766
- items.unshift(newItems[i]);
767
- itemsId[newItems[i].id] = true;
717
+ if (!itemsId.includes(newItems[i].id)) {
718
+ items.push(newItems[i]);
719
+ itemsId.push(newItems[i].id);
768
720
  }
769
721
  }
770
- //console.log("newItems: ", items);
771
722
  return items;
772
723
  };
773
724
 
@@ -778,7 +729,6 @@ export const ContentChat = (props) => {
778
729
  currentUsers[userId] = newUsers[userId];
779
730
  }
780
731
  });
781
- //console.log("newUsers: ", currentUsers);
782
732
  setAllUsers(currentUsers);
783
733
  };
784
734
 
@@ -816,7 +766,7 @@ export const ContentChat = (props) => {
816
766
  // mostrar chat?
817
767
  let items;
818
768
  let enabledLoadMore;
819
- if (chatType === "merchant_product" || chatType === "ticket") {
769
+ if (["merchant_product", "ticket"].includes(chatType)) {
820
770
  items = singleChat.items;
821
771
  enabledLoadMore = singleChat.enabledLoadMore;
822
772
  }
@@ -90,7 +90,6 @@ export const Footer = (props) => {
90
90
  const refInputTextMessage = useRef();
91
91
 
92
92
  useEffect(() => {
93
- //console.log("filesPreview: ", filesPreview.slice());
94
93
  setTooltipFileName({
95
94
  show: false,
96
95
  fileName: "",
@@ -125,9 +124,7 @@ export const Footer = (props) => {
125
124
  // subir archivos a AWS
126
125
  const customFiles = [];
127
126
  try {
128
- //console.log("files:", files);
129
127
  const fileUploadRequests = [];
130
- //console.log(dataChat);
131
128
  for (const file of files) {
132
129
  let errorMessage;
133
130
  // obtener base64
@@ -187,7 +184,6 @@ export const Footer = (props) => {
187
184
  } else {
188
185
  fileKey = undefined;
189
186
  }
190
- //console.log("fileKey: ", fileKey);
191
187
  // enviar file a AWS
192
188
  customFiles.push({
193
189
  itemType: file.type.split("/")[0] == "image" ? "img" : "file",
@@ -203,7 +199,6 @@ export const Footer = (props) => {
203
199
  fileUploadRequests.push(myBucket.putObject(paramsCreate).promise());
204
200
  }
205
201
  const responseAWS = await Promise.allSettled(fileUploadRequests);
206
- console.log("responseAWS:", responseAWS);
207
202
  responseAWS.forEach((responseFile, index) => {
208
203
  if (responseFile.status === "rejected") {
209
204
  customFiles[index].errorAWS = responseFile.reason.message;
@@ -212,7 +207,6 @@ export const Footer = (props) => {
212
207
  customFiles[index].uploaded = true;
213
208
  }
214
209
  });
215
- //console.log("customFiles:", customFiles);
216
210
  } catch (err) {
217
211
  disableSecondaryContainer(false);
218
212
  setModalAlert({
@@ -242,7 +236,6 @@ export const Footer = (props) => {
242
236
  valueItem.height = imgSize.height;
243
237
  }
244
238
  }
245
- console.log("valueItemFile:", valueItem);
246
239
  items.push({
247
240
  type: file.itemType,
248
241
  value: JSON.stringify(valueItem),
@@ -429,7 +422,6 @@ export const Footer = (props) => {
429
422
  };
430
423
 
431
424
  const onChangeFiles = async (selectedFiles) => {
432
- //console.log("selected files: ", selectedFiles);
433
425
  let newFiles = filesPreview.slice();
434
426
  newFiles = newFiles.concat(selectedFiles);
435
427
  setFilesPreview(newFiles);
@@ -20,7 +20,6 @@ export const fetchGET = (
20
20
  paramsHeaders = {}
21
21
  ) => {
22
22
  return new Promise(async (response) => {
23
- //console.log("======= fetchGET =========");
24
23
  try {
25
24
  let URL = endpoint;
26
25
  const keysParamsQuery = Object.keys(paramsQuery);
@@ -32,7 +31,6 @@ export const fetchGET = (
32
31
  URL += `&${key}=${paramsQuery[key]}`;
33
32
  }
34
33
  });
35
- //console.log("URL:", URL);
36
34
  const respHTTPjson = await axios.get(URL, { headers: paramsHeaders });
37
35
  // verificar si existe un error en la peticion realizada
38
36
  if (respHTTPjson.status !== 200) {
@@ -82,7 +80,6 @@ export const fetchPOST = (
82
80
  paramsHeaders = {}
83
81
  ) => {
84
82
  return new Promise(async (response) => {
85
- //console.log("======= fetchPOST =========");
86
83
  try {
87
84
  const respHTTPjson = await axios.post(endpoint, paramsBody, {
88
85
  headers: paramsHeaders,
@@ -100,7 +97,6 @@ export const fetchPOST = (
100
97
 
101
98
  // verificar si existe error desde el backend
102
99
  if (respHTTPjson.data.statusCode !== 200) {
103
- console.log(body);
104
100
  return response({
105
101
  message: body.message ?? "",
106
102
  errorDetail: body.errorDetail ?? "",
@@ -137,7 +133,6 @@ export const fetchPUT = (
137
133
  paramsHeaders = {}
138
134
  ) => {
139
135
  return new Promise(async (response) => {
140
- //console.log("======= fetchPUT =========");
141
136
  try {
142
137
  const respHTTPjson = await axios.put(endpoint, paramsBody, {
143
138
  headers: paramsHeaders,
@@ -193,7 +188,6 @@ export const fetchDELETE = (
193
188
  paramsHeaders = {}
194
189
  ) => {
195
190
  return new Promise(async (response) => {
196
- //console.log("======= fetchDELETE =========");
197
191
  try {
198
192
  const respHTTPjson = await axios.delete(endpoint, {
199
193
  data: paramsBody,
@@ -133,14 +133,7 @@ NOTA regresa <undefined> si no se pudo
133
133
  obtener el nuevo <height> de la imagen
134
134
  --------------------------*/
135
135
  export const getResizeImgHeight = (originalWidth, originalHeight, newWidth) => {
136
- /*
137
- console.log(`==================
138
- original width: ${originalWidth}
139
- original height: ${originalHeight}
140
- newWidth: ${newWidth}`);
141
- */
142
136
  const scale = (newWidth * 100) / originalWidth / 100;
143
- //console.log("scale:", scale);
144
137
  return Math.ceil(originalHeight * scale);
145
138
  };
146
139
 
@@ -243,7 +236,7 @@ ejemplo: '12:34 PM'
243
236
  export const getTime = (time = "") => {
244
237
  if ([undefined, null, ""].includes(time))
245
238
  return moment(new Date()).format("LT");
246
- else return moment(time).format("LT");
239
+ return moment(time).format("LT");
247
240
  };
248
241
 
249
242
  /*====================================================================