contentoh-components-library 21.5.95 → 21.5.97

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.
@@ -340,6 +340,9 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
340
340
  _context2.prev = 0;
341
341
  product = productSelected ? productSelected : JSON.parse(sessionStorage.getItem("productSelected"));
342
342
  productNormalized = (0, _utils.normalizeProduct)(product);
343
+ console.log({
344
+ productNormalized: productNormalized
345
+ });
343
346
  dispatch({
344
347
  type: "SET_PRODUCT",
345
348
  payload: productNormalized
@@ -352,10 +355,10 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
352
355
 
353
356
  setStatusArray((0, _utils.getStatusArrayByRole)(user.id_role)); // Cargar usuarios y asignaciones
354
357
 
355
- _context2.next = 9;
358
+ _context2.next = 10;
356
359
  return (0, _data.fetchUsers)(token);
357
360
 
358
- case 9:
361
+ case 10:
359
362
  users = _context2.sent;
360
363
 
361
364
  if (users.length > 0) {
@@ -368,20 +371,20 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
368
371
  id_article = productNormalized.id_article;
369
372
 
370
373
  if (!id_article) {
371
- _context2.next = 15;
374
+ _context2.next = 16;
372
375
  break;
373
376
  }
374
377
 
375
- _context2.next = 15;
378
+ _context2.next = 16;
376
379
  return (0, _utils.getAuditVersion)(id_article, setAuditableVersion, token);
377
380
 
378
- case 15:
381
+ case 16:
379
382
  if (!(id_article && productNormalized.id_order)) {
380
- _context2.next = 21;
383
+ _context2.next = 22;
381
384
  break;
382
385
  }
383
386
 
384
- _context2.next = 18;
387
+ _context2.next = 19;
385
388
  return _axios.default.get(process.env.REACT_APP_READ_OBSERVATION, {
386
389
  params: {
387
390
  articleId: id_article,
@@ -392,26 +395,26 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
392
395
  }
393
396
  });
394
397
 
395
- case 18:
398
+ case 19:
396
399
  response = _context2.sent;
397
400
  parseData = JSON.parse(response.data.body).data[0];
398
401
  setObservation(parseData.observations);
399
402
 
400
- case 21:
401
- _context2.next = 26;
403
+ case 22:
404
+ _context2.next = 27;
402
405
  break;
403
406
 
404
- case 23:
405
- _context2.prev = 23;
407
+ case 24:
408
+ _context2.prev = 24;
406
409
  _context2.t0 = _context2["catch"](0);
407
410
  console.log("Error setting product data: ", _context2.t0);
408
411
 
409
- case 26:
412
+ case 27:
410
413
  case "end":
411
414
  return _context2.stop();
412
415
  }
413
416
  }
414
- }, _callee2, null, [[0, 23]]);
417
+ }, _callee2, null, [[0, 24]]);
415
418
  }));
416
419
 
417
420
  return function initializeProduct() {
@@ -989,7 +992,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
989
992
  var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(result) {
990
993
  var _state$product$id_ord, _state$active_retaile3;
991
994
 
992
- var concept, articleId, orderId, sectionStatusKey, evalStatus, retailerId, data, res, message, icon, activeTab, newStatuses, serviceStatus, updatedStatusByRetailer, updatedProduct, specialistDone, _objectSpread2, _state$services_data2, _JSON$parse2, newStatus, newOrderStatus, newArticleStatus, _updatedProduct, updatedServicesData, sessionProduct, _objectSpread3, productInSession, updatedProductInSession;
995
+ var concept, articleId, orderId, sectionStatusKey, evalStatus, retailerId, data, res, message, icon, activeTab, newStatuses, serviceStatus, articleStatus, updatedStatusByRetailer, updatedProduct, specialistDone, _objectSpread2, _state$services_data2, _JSON$parse2, newStatus, newOrderStatus, newArticleStatus, _articleStatus, _updatedProduct, updatedServicesData, sessionProduct, _objectSpread3, productInSession, updatedProductInSession;
993
996
 
994
997
  return _regenerator.default.wrap(function _callee7$(_context7) {
995
998
  while (1) {
@@ -1024,7 +1027,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1024
1027
  _context7.prev = 11;
1025
1028
 
1026
1029
  if (!result) {
1027
- _context7.next = 26;
1030
+ _context7.next = 28;
1028
1031
  break;
1029
1032
  }
1030
1033
 
@@ -1040,7 +1043,11 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1040
1043
  case 17:
1041
1044
  res = _context7.sent;
1042
1045
  newStatuses = JSON.parse(res.data.body);
1043
- serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")]; // Actualizar el producto con los nuevos estados
1046
+ serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")];
1047
+ articleStatus = newStatuses.newArticleStatus[articleId];
1048
+ console.log({
1049
+ newStatuses: newStatuses
1050
+ }); // Actualizar el producto con los nuevos estados
1044
1051
 
1045
1052
  updatedStatusByRetailer = state.product.statusByRetailer.map(function (item) {
1046
1053
  return item.retailer_id === retailerId && item.service === concept ? (0, _objectSpread5.default)((0, _objectSpread5.default)({}, item), {}, {
@@ -1048,7 +1055,10 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1048
1055
  }) : item;
1049
1056
  });
1050
1057
  updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, {
1051
- statusByRetailer: updatedStatusByRetailer
1058
+ statusByRetailer: updatedStatusByRetailer // version_status: articleStatus,
1059
+ // status: articleStatus,
1060
+ // article_status: articleStatus
1061
+
1052
1062
  });
1053
1063
  dispatch({
1054
1064
  type: "SET_PRODUCT",
@@ -1064,10 +1074,10 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1064
1074
  image: _genericModalCheck.default
1065
1075
  }
1066
1076
  });
1067
- _context7.next = 31;
1077
+ _context7.next = 33;
1068
1078
  break;
1069
1079
 
1070
- case 26:
1080
+ case 28:
1071
1081
  //Caso del botón "Enviar evaluación"
1072
1082
  //Se construye el mensaje y se actualiza el estatus
1073
1083
  specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
@@ -1080,19 +1090,23 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1080
1090
  icon = _genericModalCheck.default;
1081
1091
  }
1082
1092
 
1083
- _context7.next = 30;
1093
+ _context7.next = 32;
1084
1094
  return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1085
1095
  headers: {
1086
1096
  Authorization: token
1087
1097
  }
1088
1098
  });
1089
1099
 
1090
- case 30:
1100
+ case 32:
1091
1101
  res = _context7.sent;
1092
1102
 
1093
- case 31:
1103
+ case 33:
1094
1104
  if (res.data.statusCode === 200) {
1095
- _JSON$parse2 = JSON.parse(res.data.body), newStatus = _JSON$parse2.newStatus, newOrderStatus = _JSON$parse2.newOrderStatus, newArticleStatus = _JSON$parse2.newArticleStatus; // const retailers = state.product.categoryRetailer.map((r) => ({
1105
+ _JSON$parse2 = JSON.parse(res.data.body), newStatus = _JSON$parse2.newStatus, newOrderStatus = _JSON$parse2.newOrderStatus, newArticleStatus = _JSON$parse2.newArticleStatus;
1106
+ _articleStatus = newArticleStatus[articleId];
1107
+ console.log({
1108
+ newArticleStatus: newArticleStatus
1109
+ }); // const retailers = state.product.categoryRetailer.map((r) => ({
1096
1110
  // id: r.id_retailer,
1097
1111
  // name: r.retailerName,
1098
1112
  // }));
@@ -1168,11 +1182,11 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1168
1182
  });
1169
1183
  }
1170
1184
 
1171
- _context7.next = 38;
1185
+ _context7.next = 40;
1172
1186
  break;
1173
1187
 
1174
- case 34:
1175
- _context7.prev = 34;
1188
+ case 36:
1189
+ _context7.prev = 36;
1176
1190
  _context7.t0 = _context7["catch"](11);
1177
1191
  console.error("Error sending evaluation:", _context7.t0);
1178
1192
  dispatch({
@@ -1185,20 +1199,20 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1185
1199
  }
1186
1200
  });
1187
1201
 
1188
- case 38:
1189
- _context7.prev = 38;
1202
+ case 40:
1203
+ _context7.prev = 40;
1190
1204
  dispatch({
1191
1205
  type: "SET_SAVING",
1192
1206
  payload: false
1193
1207
  });
1194
- return _context7.finish(38);
1208
+ return _context7.finish(40);
1195
1209
 
1196
- case 41:
1210
+ case 43:
1197
1211
  case "end":
1198
1212
  return _context7.stop();
1199
1213
  }
1200
1214
  }
1201
- }, _callee7, null, [[11, 34, 38, 41]]);
1215
+ }, _callee7, null, [[11, 36, 40, 43]]);
1202
1216
  }));
1203
1217
 
1204
1218
  return function sendSingleEvaluation(_x2) {
@@ -1540,6 +1554,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1540
1554
  };
1541
1555
 
1542
1556
  var handleOnChangeProductVersion = function handleOnChangeProductVersion(version) {
1557
+ console.log('se cambia la version');
1543
1558
  dispatch({
1544
1559
  type: "SET_PRODUCT_VERSION",
1545
1560
  payload: version
@@ -1734,6 +1749,11 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1734
1749
  });
1735
1750
  };
1736
1751
 
1752
+ (0, _react.useEffect)(function () {
1753
+ console.log({
1754
+ stateProduct: state.product
1755
+ });
1756
+ }, [state.product]);
1737
1757
  if (state.loading || !state.services || !state.product) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1738
1758
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProductEditionSkeleton, {})
1739
1759
  });
@@ -28,7 +28,7 @@ exports.AiProductEdition = AiProductEdition;
28
28
 
29
29
  var useAiProductEdition = function useAiProductEdition() {
30
30
  var context = (0, _react.useContext)(AiProductEdition);
31
- if (!context) throw new Error("El contexto debe tener un provider");
31
+ if (!context) return {};
32
32
  return context;
33
33
  };
34
34
 
@@ -219,7 +219,7 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
219
219
 
220
220
  function _generateProductSuggestions() {
221
221
  _generateProductSuggestions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref4) {
222
- var _ref4$inputName, inputName, _ref4$currentValue, currentValue, _ref4$description, description, _ref4$maxChar, maxChar, _ref4$type, type, articleId, versionId, descriptionId, attributeId, _state$product, _JSON$parse$data, _JSON$parse, rateLimitStatus, upc, productName, retailer, category, version, payload, _yield$axios$post, data, results, _error$message;
222
+ var _ref4$inputName, inputName, _ref4$currentValue, currentValue, _ref4$description, description, _ref4$maxChar, maxChar, _ref4$type, type, articleId, versionId, descriptionId, attributeId, _state$product, _JSON$parse, _JSON$parse2, _JSON$parse2$error, _JSON$parse$data, _JSON$parse3, rateLimitStatus, upc, productName, retailer, category, version, payload, _yield$axios$post, data, errorsRaw, errorMessage, results, _error$message;
223
223
 
224
224
  return _regenerator.default.wrap(function _callee2$(_context2) {
225
225
  while (1) {
@@ -311,32 +311,43 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
311
311
  case 20:
312
312
  _yield$axios$post = _context2.sent;
313
313
  data = _yield$axios$post.data;
314
- results = (_JSON$parse$data = (_JSON$parse = JSON.parse(data === null || data === void 0 ? void 0 : data.body)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.data) !== null && _JSON$parse$data !== void 0 ? _JSON$parse$data : [];
314
+ errorsRaw = (_JSON$parse = JSON.parse(data === null || data === void 0 ? void 0 : data.body)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.error;
315
+ errorMessage = errorsRaw ? (_JSON$parse2 = JSON.parse(errorsRaw)) === null || _JSON$parse2 === void 0 ? void 0 : (_JSON$parse2$error = _JSON$parse2.error) === null || _JSON$parse2$error === void 0 ? void 0 : _JSON$parse2$error.message : null;
316
+
317
+ if (!errorMessage) {
318
+ _context2.next = 26;
319
+ break;
320
+ }
321
+
322
+ throw new Error(errorMessage !== null && errorMessage !== void 0 ? errorMessage : 'Error desconocido');
323
+
324
+ case 26:
325
+ results = (_JSON$parse$data = (_JSON$parse3 = JSON.parse(data === null || data === void 0 ? void 0 : data.body)) === null || _JSON$parse3 === void 0 ? void 0 : _JSON$parse3.data) !== null && _JSON$parse$data !== void 0 ? _JSON$parse$data : [];
315
326
 
316
327
  if (results) {
317
- _context2.next = 25;
328
+ _context2.next = 29;
318
329
  break;
319
330
  }
320
331
 
321
332
  throw new Error("No se encontraron resultados");
322
333
 
323
- case 25:
334
+ case 29:
324
335
  return _context2.abrupt("return", results);
325
336
 
326
- case 28:
327
- _context2.prev = 28;
337
+ case 32:
338
+ _context2.prev = 32;
328
339
  _context2.t0 = _context2["catch"](1);
329
340
  console.log("Error generating AI suggestions:", _context2.t0);
330
341
  return _context2.abrupt("return", {
331
342
  error: (_error$message = _context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message) !== null && _error$message !== void 0 ? _error$message : "Error generating AI suggestions"
332
343
  });
333
344
 
334
- case 32:
345
+ case 36:
335
346
  case "end":
336
347
  return _context2.stop();
337
348
  }
338
349
  }
339
- }, _callee2, null, [[1, 28]]);
350
+ }, _callee2, null, [[1, 32]]);
340
351
  }));
341
352
  return _generateProductSuggestions.apply(this, arguments);
342
353
  }
@@ -344,7 +355,7 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
344
355
  (0, _react.useEffect)(function () {
345
356
  var _productSelected$perc;
346
357
 
347
- if (!productSelected) return;
358
+ if (!productSelected || !isCreators) return;
348
359
  var productName = productSelected.name,
349
360
  upc = productSelected.upc,
350
361
  categoryRetailer = productSelected.categoryRetailer;
@@ -380,7 +391,7 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
380
391
  }, [productSelected]); // Inicializamos la ficha técnica con el objetivo de posteriormente pasarlo a la generación con IA
381
392
 
382
393
  (0, _react.useEffect)(function () {
383
- if (!datasheetInputs) return;
394
+ if (!datasheetInputs || !isCreators) return;
384
395
  var datasheetToArray = Object.values(datasheetInputs);
385
396
  var normalizedDatasheet = datasheetToArray.map(function (attribute) {
386
397
  return {
@@ -396,6 +407,7 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
396
407
  (0, _react.useEffect)(function () {
397
408
  var _imagesData$inputsByR, _imagesData$inputsByR2;
398
409
 
410
+ if (!isCreators) return;
399
411
  var currentRetailerImageInputs = imagesData === null || imagesData === void 0 ? void 0 : (_imagesData$inputsByR = imagesData.inputsByRetailer) === null || _imagesData$inputsByR === void 0 ? void 0 : (_imagesData$inputsByR2 = _imagesData$inputsByR[0]) === null || _imagesData$inputsByR2 === void 0 ? void 0 : _imagesData$inputsByR2.filter(function (input) {
400
412
  return (input === null || input === void 0 ? void 0 : input.id_retailer) === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id_retailer);
401
413
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.5.95",
3
+ "version": "21.5.97",
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 GeneralInput = ({
55
55
  }) => {
56
56
 
57
57
  const {
58
+ isCreators,
58
59
  suggestions,
59
60
  currentSuggestion,
60
61
  setCurrentSuggestionValue
@@ -140,6 +141,8 @@ export const GeneralInput = ({
140
141
 
141
142
  useEffect(() => {
142
143
 
144
+ if(!isCreators) return;
145
+
143
146
  if(Object.keys(suggestions).length === 0) return;
144
147
 
145
148
  if(currentSuggestion?.[inputId]) return
@@ -158,11 +161,12 @@ export const GeneralInput = ({
158
161
  }, [suggestions]);
159
162
 
160
163
  useEffect(() => {
161
- if(!isAiActive) return;
164
+ if(!isAiActive || !isCreators) return;
162
165
  setAiSuggestionAccepted(false);
163
166
  }, [isAiActive]);
164
167
 
165
168
  useEffect(() => {
169
+ if(!isCreators) return;
166
170
  if(!isAiActive && !aiSuggestionAccepted) {
167
171
  setTextValue({ value: valueAccepted });
168
172
  }
@@ -187,7 +191,7 @@ export const GeneralInput = ({
187
191
  //AI Generation
188
192
 
189
193
  const handleAcceptSuggestion = (suggestionValue) => {
190
- if(!suggestionValue) return;
194
+ if(!suggestionValue || !isCreators) return;
191
195
 
192
196
  setValueAccepted(suggestionValue);
193
197
  setAiSuggestionAccepted(true);
@@ -20,6 +20,17 @@ export const TabsMenu = ({
20
20
  }) => {
21
21
  const [sections, setSections] = useState(tabsSections);
22
22
 
23
+ useEffect(() => {
24
+ if (!activeTab) return;
25
+ setSections((prev) => {
26
+ const updated = {};
27
+ Object.keys(prev).forEach((key) => {
28
+ updated[key] = key === activeTab;
29
+ });
30
+ return updated;
31
+ });
32
+ }, [activeTab]);
33
+
23
34
  const [modal, setModal] = useState(false);
24
35
  const [cancelAccept, setCancelAccept] = useState("");
25
36
  const [llave, setLlave] = useState("");
@@ -257,6 +257,9 @@ export const TagAndInput = ({
257
257
  }, [boxOnboardingList]);
258
258
 
259
259
  useEffect(() => {
260
+
261
+ if(!isCreators) return;
262
+
260
263
  const currentDescriptionUpdate = Array.isArray(updatedDescriptions)
261
264
  ? updatedDescriptions.find(desc => desc?.attributeId === inputId)
262
265
  : null;
@@ -287,11 +290,16 @@ export const TagAndInput = ({
287
290
  }, [updatedDescriptions, updatedDatasheets, aiGenerated, inputId]);
288
291
 
289
292
  useEffect(() => {
293
+
294
+ if(!isCreators) return;
295
+
290
296
  setIsAiGenerated(!!inputsGeneratedWithAi[`${inputId}-${inputType}-${version}`]?.isAiGenerated);
291
297
  }, [inputsGeneratedWithAi]);
292
298
 
293
299
  useEffect(() => {
294
300
 
301
+ if(!isCreators) return;
302
+
295
303
  setInputsUsingAi(prev => ({
296
304
  ...prev,
297
305
  [`${inputId}-${inputType}-${version}`]: {