contentoh-components-library 21.1.95 → 21.1.96

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.
@@ -179,7 +179,7 @@ var reducerImages = function reducerImages(state, action) {
179
179
  inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
180
180
  return imageIdArray.includes(input.id);
181
181
  });
182
- values = orderedImages.length > 0 ? orderedImages : valuesInitial;
182
+ values = orderedImages.length > 0 ? orderedImages : [];
183
183
  return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
184
184
  values: values,
185
185
  inputs: inputs
@@ -548,8 +548,10 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
548
548
  services = _context2.sent;
549
549
  //Converts the data inside the datasheets object to array
550
550
  setServices(services);
551
- getServices();
551
+ _context2.next = 6;
552
+ return getServices();
552
553
 
554
+ case 6:
553
555
  if (!originProp) {
554
556
  setActiveRetailer(product !== null && product !== void 0 && product.retailers ? product === null || product === void 0 ? void 0 : product.retailers[0] : product === null || product === void 0 ? void 0 : product.retailersAvailable[0]);
555
557
  } // setActiveRetailer(product?.retailers[0]);
@@ -567,7 +569,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
567
569
  });
568
570
  setLoading(false);
569
571
 
570
- case 10:
572
+ case 11:
571
573
  case "end":
572
574
  return _context2.stop();
573
575
  }
@@ -584,7 +586,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
584
586
  var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
585
587
  var _product$article4;
586
588
 
587
- var productInOrder, idArticle, _product$id_order, _servicesResponse$dat, servicesResponse, parsedResponse, retailerResponse, retailers, active;
589
+ var productInOrder, idArticle, retailers, active, _product$id_order, _servicesResponse$dat, servicesResponse, parsedResponse, retailerResponse;
588
590
 
589
591
  return _regenerator.default.wrap(function _callee3$(_context3) {
590
592
  while (1) {
@@ -592,29 +594,32 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
592
594
  case 0:
593
595
  productInOrder = product.id_order || product.orderId;
594
596
  idArticle = (product === null || product === void 0 ? void 0 : product.id_article) || (product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_article);
597
+ retailers = product.retailers || product.retailersAvailable;
598
+ active = null;
595
599
 
596
600
  if (!(isRevision() || productInOrder)) {
597
601
  _context3.next = 12;
598
602
  break;
599
603
  }
600
604
 
601
- _context3.next = 5;
605
+ _context3.next = 7;
602
606
  return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(idArticle, "&orderId=").concat((_product$id_order = product === null || product === void 0 ? void 0 : product.id_order) !== null && _product$id_order !== void 0 ? _product$id_order : product.orderId, "&end=true"));
603
607
 
604
- case 5:
608
+ case 7:
605
609
  servicesResponse = _context3.sent;
606
610
  parsedResponse = JSON.parse(servicesResponse === null || servicesResponse === void 0 ? void 0 : (_servicesResponse$dat = servicesResponse.data) === null || _servicesResponse$dat === void 0 ? void 0 : _servicesResponse$dat.body).data;
607
611
  retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
608
612
  return srv.id_retailer;
609
613
  });
610
- retailers = product.retailers || product.retailersAvailable;
611
614
  active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
612
615
  return retailerResponse.includes(retailer.id);
613
616
  });
614
- !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
615
617
  setServicesData(parsedResponse);
616
618
 
617
619
  case 12:
620
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
621
+
622
+ case 13:
618
623
  case "end":
619
624
  return _context3.stop();
620
625
  }
@@ -157,7 +157,7 @@ var reducerImages = function reducerImages(state, action) {
157
157
  inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
158
158
  return imageIdArray.includes(input.id);
159
159
  });
160
- values = orderedImages.length > 0 ? orderedImages : valuesInitial;
160
+ values = orderedImages.length > 0 ? orderedImages : [];
161
161
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
162
162
  values: values,
163
163
  inputs: inputs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.1.95",
3
+ "version": "21.1.96",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -97,7 +97,7 @@ const reducerImages = (state, action) => {
97
97
  imageIdArray.includes(input.id)
98
98
  );
99
99
 
100
- values = orderedImages.length > 0 ? orderedImages : valuesInitial;
100
+ values = orderedImages.length > 0 ? orderedImages : [];
101
101
  return { ...state, values, inputs };
102
102
  }
103
103
  default:
@@ -263,7 +263,7 @@ export const ProviderProductEdition = ({
263
263
 
264
264
  //Converts the data inside the datasheets object to array
265
265
  setServices(services);
266
- getServices();
266
+ await getServices();
267
267
 
268
268
  if (!originProp) {
269
269
  setActiveRetailer(
@@ -284,6 +284,8 @@ export const ProviderProductEdition = ({
284
284
  const getServices = async () => {
285
285
  const productInOrder = product.id_order || product.orderId;
286
286
  const idArticle = product?.id_article || product?.article?.id_article;
287
+ let retailers = product.retailers || product.retailersAvailable;
288
+ let active = null;
287
289
  if (isRevision() || productInOrder) {
288
290
  const servicesResponse = await axios.get(
289
291
  `${
@@ -294,13 +296,12 @@ export const ProviderProductEdition = ({
294
296
  );
295
297
  const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
296
298
  const retailerResponse = parsedResponse?.map((srv) => srv.id_retailer);
297
- let retailers = product.retailers || product.retailersAvailable;
298
- let active = retailers?.find((retailer) =>
299
+ active = retailers?.find((retailer) =>
299
300
  retailerResponse.includes(retailer.id)
300
301
  );
301
- !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
302
302
  setServicesData(parsedResponse);
303
303
  }
304
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
304
305
  };
305
306
 
306
307
  const isRevision = () => {
@@ -87,7 +87,7 @@ const reducerImages = (state, action) => {
87
87
  imageIdArray.includes(input.id)
88
88
  );
89
89
 
90
- values = orderedImages.length > 0 ? orderedImages : valuesInitial;
90
+ values = orderedImages.length > 0 ? orderedImages : [];
91
91
  return { ...state, values, inputs };
92
92
  }
93
93
  default: