contentoh-components-library 21.2.9 → 21.2.10

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.
@@ -1509,7 +1509,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1509
1509
 
1510
1510
  var validateAll = /*#__PURE__*/function () {
1511
1511
  var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(result) {
1512
- var _product$id_order2, evaluationArray, sendAll, conceptArray, dataGeneral, productTemp, retailerStatusCopy;
1512
+ var _product$id_order2, evaluationArray, conceptArray, dataGeneral, evalResponse, userType, productTemp, retailerStatusCopy;
1513
1513
 
1514
1514
  return _regenerator.default.wrap(function _callee13$(_context13) {
1515
1515
  while (1) {
@@ -1518,17 +1518,18 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1518
1518
  _context13.prev = 0;
1519
1519
  setLoading(true);
1520
1520
  evaluationArray = [];
1521
- sendAll = [];
1522
1521
  conceptArray = ["description", "datasheet", "images"];
1523
1522
  dataGeneral = {
1524
1523
  articleId: product.id_article,
1525
1524
  orderId: (_product$id_order2 = product.id_order) !== null && _product$id_order2 !== void 0 ? _product$id_order2 : product.orderId,
1526
- result: result
1525
+ result: result,
1526
+ isAproved: result === "A"
1527
1527
  };
1528
1528
  servicesData === null || servicesData === void 0 ? void 0 : servicesData.forEach(function (ret) {
1529
1529
  var service = ret.service,
1530
1530
  id_retailer = ret.id_retailer;
1531
- var data = (0, _objectSpread3.default)((0, _objectSpread3.default)({}, dataGeneral), {}, {
1531
+ var data = {};
1532
+ data = (0, _objectSpread3.default)((0, _objectSpread3.default)({}, dataGeneral), {}, {
1532
1533
  concept: service,
1533
1534
  retailerId: id_retailer,
1534
1535
  evalStatus: retailerStatus[id_retailer][service]
@@ -1538,26 +1539,27 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1538
1539
  Authorization: token
1539
1540
  }
1540
1541
  }));
1541
- sendAll.push(_axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1542
- headers: {
1543
- Authorization: token
1544
- }
1545
- }));
1546
1542
  });
1547
- _context13.next = 9;
1548
- return Promise.all([].concat(evaluationArray, sendAll));
1543
+ _context13.next = 8;
1544
+ return Promise.all(evaluationArray);
1549
1545
 
1550
- case 9:
1546
+ case 8:
1547
+ evalResponse = _context13.sent;
1548
+ console.log(evalResponse.map(function (_ref15) {
1549
+ var data = _ref15.data;
1550
+ return JSON.parse(data.body);
1551
+ }));
1552
+ userType = user.is_retailer === 1 ? "CA" : "P";
1551
1553
  productTemp = product;
1552
- productTemp.article_status = "".concat(result, "CA");
1553
- productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : "".concat(result, "CA");
1554
- productTemp.description_status = productTemp.description_status === "NA" ? "NA" : "".concat(result, "CA");
1555
- productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "CA");
1554
+ productTemp.article_status = "".concat(result).concat(userType);
1555
+ productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : "".concat(result).concat(userType);
1556
+ productTemp.description_status = productTemp.description_status === "NA" ? "NA" : "".concat(result).concat(userType);
1557
+ productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result).concat(userType);
1556
1558
  retailerStatusCopy = (0, _objectSpread3.default)({}, retailerStatus);
1557
1559
  Object.keys(retailerStatusCopy).forEach(function (key) {
1558
1560
  conceptArray.forEach(function (concept) {
1559
1561
  if (retailerStatusCopy[key][concept]) {
1560
- retailerStatusCopy[key][concept] = "".concat(result, "CA");
1562
+ retailerStatusCopy[key][concept] = "".concat(result).concat(userType);
1561
1563
  }
1562
1564
  });
1563
1565
  });
@@ -1575,24 +1577,24 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1575
1577
  idCategory: productTemp.article.id_category,
1576
1578
  product: productTemp
1577
1579
  }));
1578
- _context13.next = 24;
1580
+ _context13.next = 26;
1579
1581
  return loadData();
1580
1582
 
1581
- case 24:
1582
- _context13.next = 29;
1583
+ case 26:
1584
+ _context13.next = 31;
1583
1585
  break;
1584
1586
 
1585
- case 26:
1586
- _context13.prev = 26;
1587
+ case 28:
1588
+ _context13.prev = 28;
1587
1589
  _context13.t0 = _context13["catch"](0);
1588
1590
  console.log(_context13.t0);
1589
1591
 
1590
- case 29:
1592
+ case 31:
1591
1593
  case "end":
1592
1594
  return _context13.stop();
1593
1595
  }
1594
1596
  }
1595
- }, _callee13, null, [[0, 26]]);
1597
+ }, _callee13, null, [[0, 28]]);
1596
1598
  }));
1597
1599
 
1598
1600
  return function validateAll(_x8) {
@@ -1601,7 +1603,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1601
1603
  }();
1602
1604
 
1603
1605
  var evaluationToRetailer = /*#__PURE__*/function () {
1604
- var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(result) {
1606
+ var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(result) {
1605
1607
  var data, prod, statusComplete;
1606
1608
  return _regenerator.default.wrap(function _callee14$(_context14) {
1607
1609
  while (1) {
@@ -1643,7 +1645,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1643
1645
  }));
1644
1646
 
1645
1647
  return function evaluationToRetailer(_x9) {
1646
- return _ref15.apply(this, arguments);
1648
+ return _ref16.apply(this, arguments);
1647
1649
  };
1648
1650
  }();
1649
1651
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.2.9",
3
+ "version": "21.2.10",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -913,16 +913,17 @@ export const ProviderProductEdition = ({
913
913
  try {
914
914
  setLoading(true);
915
915
  const evaluationArray = [];
916
- const sendAll = [];
917
916
  const conceptArray = ["description", "datasheet", "images"];
918
917
  const dataGeneral = {
919
918
  articleId: product.id_article,
920
919
  orderId: product.id_order ?? product.orderId,
921
920
  result,
921
+ isAproved: result === "A",
922
922
  };
923
923
  servicesData?.forEach((ret) => {
924
924
  const { service, id_retailer } = ret;
925
- const data = {
925
+ let data = {};
926
+ data = {
926
927
  ...dataGeneral,
927
928
  concept: service,
928
929
  retailerId: id_retailer,
@@ -935,31 +936,25 @@ export const ProviderProductEdition = ({
935
936
  },
936
937
  })
937
938
  );
938
- sendAll.push(
939
- axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
940
- headers: {
941
- Authorization: token,
942
- },
943
- })
944
- );
945
939
  });
946
-
947
- await Promise.all([...evaluationArray, ...sendAll]);
940
+ const evalResponse = await Promise.all(evaluationArray);
941
+ console.log(evalResponse.map(({ data }) => JSON.parse(data.body)));
942
+ const userType = user.is_retailer === 1 ? "CA" : "P";
948
943
 
949
944
  const productTemp = product;
950
- productTemp.article_status = `${result}CA`;
945
+ productTemp.article_status = `${result}${userType}`;
951
946
  productTemp.datasheet_status =
952
- productTemp.datasheet_status === "NA" ? "NA" : `${result}CA`;
947
+ productTemp.datasheet_status === "NA" ? "NA" : `${result}${userType}`;
953
948
  productTemp.description_status =
954
- productTemp.description_status === "NA" ? "NA" : `${result}CA`;
949
+ productTemp.description_status === "NA" ? "NA" : `${result}${userType}`;
955
950
  productTemp.images_status =
956
- productTemp.images_status === "NA" ? "NA" : `${result}CA`;
951
+ productTemp.images_status === "NA" ? "NA" : `${result}${userType}`;
957
952
 
958
953
  const retailerStatusCopy = { ...retailerStatus };
959
954
  Object.keys(retailerStatusCopy).forEach((key) => {
960
955
  conceptArray.forEach((concept) => {
961
956
  if (retailerStatusCopy[key][concept]) {
962
- retailerStatusCopy[key][concept] = `${result}CA`;
957
+ retailerStatusCopy[key][concept] = `${result}${userType}`;
963
958
  }
964
959
  });
965
960
  });