contentoh-components-library 21.1.27 → 21.1.28

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.
@@ -1437,9 +1437,9 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1437
1437
  case 11:
1438
1438
  productTemp = product;
1439
1439
  productTemp.article_status = "".concat(result, "C");
1440
- productTemp.datasheet_status = "".concat(result, "C");
1441
- productTemp.description_status = "".concat(result, "C");
1442
- productTemp.images_status = "".concat(result, "C");
1440
+ productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : "".concat(result, "C");
1441
+ productTemp.description_status = productTemp.description_status === "NA" ? "NA" : "".concat(result, "C");
1442
+ productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "C");
1443
1443
  setProduct(productTemp);
1444
1444
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1445
1445
  setProductEdit({
@@ -1581,12 +1581,68 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
1581
1581
  setActiveRetailer: setActiveRetailer,
1582
1582
  showValidationButtons: isRevision() && getSectionStatus(),
1583
1583
  servicesData: servicesData ? servicesData : null,
1584
- showApproveRejectAll: user.is_retailer === 1 && (product.id_order || product.orderId) && isRevision() && getSectionStatus(),
1584
+ showApproveRejectAll: isRevision() && getSectionStatus(),
1585
1585
  approveAll: function approveAll() {
1586
- return validateAll("A");
1586
+ if (originProp === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
1587
+ setDataGenericModal(function (prev) {
1588
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1589
+ button2: {
1590
+ name: "Continuar",
1591
+ action: function action() {
1592
+ return evaluationToRetailer("A");
1593
+ }
1594
+ }
1595
+ });
1596
+ });
1597
+ setShowGenericModal(true);
1598
+ } else {
1599
+ if (user.is_retailer) {
1600
+ if (product.id_order || product.orderId) {
1601
+ validateAll("A");
1602
+ } else {
1603
+ setDataGenericModal(function (prev) {
1604
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1605
+ button2: {
1606
+ name: "Continuar",
1607
+ action: function action() {
1608
+ return evaluationToRetailer("A");
1609
+ }
1610
+ }
1611
+ });
1612
+ });
1613
+ setShowGenericModal(true);
1614
+ }
1615
+ } else {
1616
+ validateAll("A");
1617
+ }
1618
+ }
1587
1619
  },
1588
1620
  rejectAll: function rejectAll() {
1589
- return validateAll("R");
1621
+ if (originProp === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
1622
+ return;
1623
+ } else {
1624
+ if (user.is_retailer) {
1625
+ if (product.id_order || product.orderId) {
1626
+ validateAll("R");
1627
+ setModalViewError(true);
1628
+ } else {
1629
+ setDataGenericModal(function (prev) {
1630
+ return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1631
+ button2: {
1632
+ name: "Continuar",
1633
+ action: function action() {
1634
+ return evaluationToRetailer("R");
1635
+ }
1636
+ }
1637
+ });
1638
+ });
1639
+ setShowGenericModal(true);
1640
+ }
1641
+ } else {
1642
+ validateAll("R");
1643
+ setModalViewError(true);
1644
+ }
1645
+ }
1590
1646
  },
1591
1647
  approve: function approve() {
1592
1648
  if (origin[activeTab] === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
@@ -31,70 +31,61 @@ RetailerProductEditionDefault.args = {
31
31
  "Ficha técnica": false,
32
32
  Imágenes: false
33
33
  },
34
- token: "eyJraWQiOiJEV3owZnNieXg2MXNFcVduN3RCXC81bVhod3ZNbFZIOTgwUnZcL3RjT0lKdEk9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiIwYjY2YTRhOS03NzkwLTQwMzQtYTMwYS1jMDA4MDg5NjI4NjciLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9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41
38
  descriptions: 1,
42
39
  images: 1
43
40
  },
44
- orderId: 1213,
45
- status: "AA",
46
- datasheet_status: "AA",
47
- prio: "low",
48
- version: 2,
49
- description_status: "AA",
50
- images_status: "AA",
41
+ orderId: 64,
42
+ status: "AF",
43
+ datasheet_status: "AF",
44
+ prio: "none",
45
+ version: 7,
46
+ description_status: "AF",
47
+ images_status: "AF",
51
48
  article: {
52
- id_article: 17517,
53
- id_category: "691",
54
- name: "Antitranspirante Lady Speed Stick Clinical Complete en Barra para Dama 45 g",
55
- upc: "7509546066172",
56
- timestamp: "2021-10-09T16:33:17.000Z",
57
- id_user: 203,
58
- status: "RECEPTION",
49
+ id_article: 35707,
50
+ id_category: "41",
51
+ name: "chetos",
52
+ upc: "1010101010",
53
+ timestamp: "2022-06-16T18:12:42.000Z",
54
+ id_user: 28,
55
+ status: "NULL",
59
56
  active: 1,
60
- company_id: 226,
61
- company_name: "Prueba Test S.A de C.V.",
62
- country: "null",
63
- id_order: 1213,
64
- id_datasheet_especialist: 334,
65
- id_datasheet_facilitator: 158,
66
- id_description_especialist: 334,
67
- id_description_facilitator: 158,
68
- id_images_especialist: 366,
69
- id_images_facilitator: 14,
70
- id_auditor: 94,
57
+ company_id: 1,
58
+ company_name: "COMPANY DEV",
59
+ country: "México",
60
+ id_order: 64,
61
+ id_datasheet_especialist: 54,
62
+ id_datasheet_facilitator: 52,
63
+ id_description_especialist: 54,
64
+ id_description_facilitator: 52,
65
+ id_images_especialist: 55,
66
+ id_images_facilitator: 53,
67
+ id_auditor: 30,
71
68
  id_recepcionist: null,
72
- category: "SALUD Y BELLEZA|CUIDADO CORPORAL|DESODORANTES CABALLERO Y DAMA",
73
- missingAttributes: 1,
74
- missingDescriptions: 0,
75
- missingImages: -4
69
+ category: "ABARROTES|BOTANAS, GOLOSINAS Y CHOCOLATES|BOTANAS",
70
+ missingAttributes: null,
71
+ missingDescriptions: null,
72
+ missingImages: null
76
73
  },
77
74
  retailers: [{
78
- id: 4,
79
- name: "Walmart Super y Superama",
80
- country: "México",
81
- id_region: 1,
82
- active: 1
83
- }, {
84
- id: 6,
85
- name: "HEB",
75
+ id: 3,
76
+ name: "Sam´s Club",
86
77
  country: "México",
87
78
  id_region: 1,
88
79
  active: 1
89
80
  }, {
90
- id: 29,
91
- name: "Farmacias del Ahorro",
81
+ id: 8,
82
+ name: "Fragua",
92
83
  country: "México",
93
84
  id_region: 1,
94
85
  active: 1
95
86
  }],
96
- country: "null",
97
- upc: "7509546066172"
87
+ country: "México",
88
+ upc: "1010101010"
98
89
  },
99
90
  location: {
100
91
  product: {
@@ -103,36 +94,36 @@ RetailerProductEditionDefault.args = {
103
94
  }
104
95
  },
105
96
  user: {
106
- id_user: 423,
107
- name: "Facilitador Textos",
108
- last_name: " ",
109
- email: "bayadi1538@mnqlm.com",
110
- position: "Tester",
97
+ id_user: 30,
98
+ name: "Admin",
99
+ last_name: "Ulises",
100
+ email: "salmeron.5@hotmail.com",
101
+ position: "Admin",
111
102
  telephone: null,
112
- country: null,
113
- id_company: 254,
114
- id_cognito: "0b66a4a9-7790-4034-a30a-c00808962867",
103
+ country: "México",
104
+ id_company: 2,
105
+ id_cognito: "c94a7305-9365-46ff-a423-4b4bc3b8b180",
115
106
  birth_Date: null,
116
107
  about_me: null,
117
108
  zip_code: null,
118
109
  address: null,
119
110
  job: null,
120
111
  id_stripe: null,
121
- id_role: 4,
112
+ id_role: 6,
122
113
  active: 1,
123
114
  is_retailer: 0,
124
- email_notify: null,
115
+ email_notify: 0,
125
116
  membership: {
126
- id: 750,
127
- start_date: "2022-01-07T21:32:54.000Z",
128
- end_date: "2023-01-07T21:32:54.000Z",
129
- planID: 6,
130
- plan: "prod_KvGd6YSTJyR3AP",
131
- name: "Plan Small",
132
- user_limit: "10",
133
- products_limit: "1000",
134
- type: "Enterprise"
117
+ id: 2,
118
+ start_date: "2021-11-05T02:35:12.000Z",
119
+ end_date: "2022-11-05T02:34:49.000Z",
120
+ planID: 1,
121
+ plan: "prod_KtkvuFFLpOdP6e",
122
+ name: "Plan Free",
123
+ user_limit: "1",
124
+ products_limit: "3",
125
+ type: "PyMES"
135
126
  },
136
- src: "https://content-management-profile-prod.s3.amazonaws.com/id-423/423.png?1656100361978"
127
+ src: "https://content-management-profile.s3.amazonaws.com/id-30/30.png?1656375350443"
137
128
  }
138
129
  };
@@ -142,8 +142,6 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
142
142
  productSelected = _ref$productSelected === void 0 ? {} : _ref$productSelected,
143
143
  _ref$user = _ref.user,
144
144
  user = _ref$user === void 0 ? {} : _ref$user,
145
- _ref$location = _ref.location,
146
- location = _ref$location === void 0 ? {} : _ref$location,
147
145
  token = _ref.token;
148
146
 
149
147
  var _useState = (0, _react.useState)("Descripción"),
@@ -378,6 +376,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
378
376
  saving = _useState70[0],
379
377
  setSaving = _useState70[1];
380
378
 
379
+ var isAuditor = user.id_role === 6;
381
380
  (0, _react.useEffect)(function () {
382
381
  checkAll && setSelectedImages(images.values);
383
382
  }, [checkAll]);
@@ -1545,6 +1544,88 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1545
1544
  (0, _react.useEffect)(function () {
1546
1545
  setSaving(loading);
1547
1546
  }, [loading]);
1547
+
1548
+ var validateAll = /*#__PURE__*/function () {
1549
+ var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(result) {
1550
+ var evaluationArray, sendAll, conceptArray, productTemp;
1551
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1552
+ while (1) {
1553
+ switch (_context13.prev = _context13.next) {
1554
+ case 0:
1555
+ _context13.prev = 0;
1556
+ setLoading(true);
1557
+ evaluationArray = [];
1558
+ sendAll = [];
1559
+ conceptArray = ["description", "datasheet", "images"];
1560
+ servicesData === null || servicesData === void 0 ? void 0 : servicesData.forEach(function (ret) {
1561
+ var _product$id_order;
1562
+
1563
+ var data = {
1564
+ articleId: product.article.id_article,
1565
+ orderId: (_product$id_order = product.id_order) !== null && _product$id_order !== void 0 ? _product$id_order : product.orderId,
1566
+ concept: ret.service,
1567
+ result: result,
1568
+ evalStatus: product["".concat(ret.service, "_status")],
1569
+ retailerId: ret.id_retailer
1570
+ };
1571
+ evaluationArray.push(_axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1572
+ headers: {
1573
+ Authorization: token
1574
+ }
1575
+ }));
1576
+ });
1577
+ _context13.next = 8;
1578
+ return Promise.all(evaluationArray);
1579
+
1580
+ case 8:
1581
+ conceptArray === null || conceptArray === void 0 ? void 0 : conceptArray.forEach(function (concept) {
1582
+ var _product$id_order2;
1583
+
1584
+ var data = {
1585
+ articleId: product.article.id_article,
1586
+ orderId: (_product$id_order2 = product.id_order) !== null && _product$id_order2 !== void 0 ? _product$id_order2 : product.orderId,
1587
+ concept: concept,
1588
+ evalStatus: product["".concat(concept, "_status")]
1589
+ };
1590
+ sendAll.push(_axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1591
+ headers: {
1592
+ Authorization: token
1593
+ }
1594
+ }));
1595
+ });
1596
+ _context13.next = 11;
1597
+ return Promise.all(sendAll);
1598
+
1599
+ case 11:
1600
+ productTemp = product;
1601
+ productTemp.status = "".concat(result, "A");
1602
+ productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : "".concat(result, "A");
1603
+ productTemp.description_status = productTemp.description_status === "NA" ? "NA" : "".concat(result, "A");
1604
+ productTemp.images_status = productTemp.images_status === "NA" ? "NA" : "".concat(result, "A");
1605
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1606
+ setProduct(productTemp);
1607
+ loadData();
1608
+ _context13.next = 24;
1609
+ break;
1610
+
1611
+ case 21:
1612
+ _context13.prev = 21;
1613
+ _context13.t0 = _context13["catch"](0);
1614
+ console.log(_context13.t0);
1615
+
1616
+ case 24:
1617
+ case "end":
1618
+ return _context13.stop();
1619
+ }
1620
+ }
1621
+ }, _callee13, null, [[0, 21]]);
1622
+ }));
1623
+
1624
+ return function validateAll(_x7) {
1625
+ return _ref14.apply(this, arguments);
1626
+ };
1627
+ }();
1628
+
1548
1629
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
1549
1630
  headerTop: headerTop,
1550
1631
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
@@ -1609,7 +1690,36 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1609
1690
  }
1610
1691
  })]);
1611
1692
  },
1612
- showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned())
1693
+ showApproveRejectAll: isAuditor && servicesData.every(function (serv) {
1694
+ return ["RA", "AA", "AP", "AC", "AF"].includes(serv.status);
1695
+ }) && approveRejectButtons() && (auditorAssigned() || userAssigned()),
1696
+ showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned()),
1697
+ approveAll: function approveAll() {
1698
+ return validateAll("A");
1699
+ },
1700
+ rejectAll: function rejectAll() {
1701
+ validateAll("R");
1702
+ setMessage("Rechazado");
1703
+ setComponentsArray([/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1704
+ src: _errorModal.default
1705
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1706
+ text: "Agrega tu comentarios para enviar el rechazo",
1707
+ headerType: "input-name-header",
1708
+ color: "white"
1709
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
1710
+ label: "Caja de Comentario",
1711
+ inputType: "textarea",
1712
+ inputId: "modal-commentary-box",
1713
+ index: 0,
1714
+ color: "white"
1715
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1716
+ buttonType: "general-default-button",
1717
+ label: "Enviar comentario",
1718
+ onClick: function onClick(e) {
1719
+ return createComment(e, document.querySelector("#modal-commentary-box .ql-container .ql-editor > p").innerHTML, activeTab);
1720
+ }
1721
+ })]);
1722
+ }
1613
1723
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1614
1724
  tabsSections: tabsSections,
1615
1725
  status: retailerStatus,
@@ -1713,20 +1823,20 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
1713
1823
  reviewed: crossComment
1714
1824
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1715
1825
  buttonType: "circular-button accept-button",
1716
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
1717
- return _regenerator.default.wrap(function _callee13$(_context13) {
1826
+ onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
1827
+ return _regenerator.default.wrap(function _callee14$(_context14) {
1718
1828
  while (1) {
1719
- switch (_context13.prev = _context13.next) {
1829
+ switch (_context14.prev = _context14.next) {
1720
1830
  case 0:
1721
1831
  setCrossComment(true);
1722
1832
  commentRevised();
1723
1833
 
1724
1834
  case 2:
1725
1835
  case "end":
1726
- return _context13.stop();
1836
+ return _context14.stop();
1727
1837
  }
1728
1838
  }
1729
- }, _callee13);
1839
+ }, _callee14);
1730
1840
  }))
1731
1841
  })]
1732
1842
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.1.27",
3
+ "version": "21.1.28",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -891,9 +891,12 @@ export const ProviderProductEdition = ({
891
891
  await Promise.all(sendAll);
892
892
  const productTemp = product;
893
893
  productTemp.article_status = `${result}C`;
894
- productTemp.datasheet_status = `${result}C`;
895
- productTemp.description_status = `${result}C`;
896
- productTemp.images_status = `${result}C`;
894
+ productTemp.datasheet_status =
895
+ productTemp.datasheet_status === "NA" ? "NA" : `${result}C`;
896
+ productTemp.description_status =
897
+ productTemp.description_status === "NA" ? "NA" : `${result}C`;
898
+ productTemp.images_status =
899
+ productTemp.images_status === "NA" ? "NA" : `${result}C`;
897
900
  setProduct(productTemp);
898
901
  sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
899
902
  setProductEdit({
@@ -1003,14 +1006,68 @@ export const ProviderProductEdition = ({
1003
1006
  setActiveRetailer={setActiveRetailer}
1004
1007
  showValidationButtons={isRevision() && getSectionStatus()}
1005
1008
  servicesData={servicesData ? servicesData : null}
1006
- showApproveRejectAll={
1007
- user.is_retailer === 1 &&
1008
- (product.id_order || product.orderId) &&
1009
- isRevision() &&
1010
- getSectionStatus()
1011
- }
1012
- approveAll={() => validateAll("A")}
1013
- rejectAll={() => validateAll("R")}
1009
+ showApproveRejectAll={isRevision() && getSectionStatus()}
1010
+ approveAll={() => {
1011
+ if (
1012
+ originProp === "RequestWithoutContentoh" &&
1013
+ !user.is_retailer &&
1014
+ (!product.id_order || !product.orderId)
1015
+ ) {
1016
+ setDataGenericModal((prev) => ({
1017
+ ...prev,
1018
+ button2: {
1019
+ name: "Continuar",
1020
+ action: () => evaluationToRetailer("A"),
1021
+ },
1022
+ }));
1023
+ setShowGenericModal(true);
1024
+ } else {
1025
+ if (user.is_retailer) {
1026
+ if (product.id_order || product.orderId) {
1027
+ validateAll("A");
1028
+ } else {
1029
+ setDataGenericModal((prev) => ({
1030
+ ...prev,
1031
+ button2: {
1032
+ name: "Continuar",
1033
+ action: () => evaluationToRetailer("A"),
1034
+ },
1035
+ }));
1036
+ setShowGenericModal(true);
1037
+ }
1038
+ } else {
1039
+ validateAll("A");
1040
+ }
1041
+ }
1042
+ }}
1043
+ rejectAll={() => {
1044
+ if (
1045
+ originProp === "RequestWithoutContentoh" &&
1046
+ !user.is_retailer &&
1047
+ (!product.id_order || !product.orderId)
1048
+ ) {
1049
+ return;
1050
+ } else {
1051
+ if (user.is_retailer) {
1052
+ if (product.id_order || product.orderId) {
1053
+ validateAll("R");
1054
+ setModalViewError(true);
1055
+ } else {
1056
+ setDataGenericModal((prev) => ({
1057
+ ...prev,
1058
+ button2: {
1059
+ name: "Continuar",
1060
+ action: () => evaluationToRetailer("R"),
1061
+ },
1062
+ }));
1063
+ setShowGenericModal(true);
1064
+ }
1065
+ } else {
1066
+ validateAll("R");
1067
+ setModalViewError(true);
1068
+ }
1069
+ }
1070
+ }}
1014
1071
  approve={() => {
1015
1072
  if (
1016
1073
  origin[activeTab] === "RequestWithoutContentoh" &&
@@ -16,110 +16,99 @@ RetailerProductEditionDefault.args = {
16
16
  Imágenes: false,
17
17
  },
18
18
  token:
19
- "eyJraWQiOiJEV3owZnNieXg2MXNFcVduN3RCXC81bVhod3ZNbFZIOTgwUnZcL3RjT0lKdEk9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiIwYjY2YTRhOS03NzkwLTQwMzQtYTMwYS1jMDA4MDg5NjI4NjciLCJjb2duaXRvOmdyb3VwcyI6WyJjb2xhYm9yYWRvcmVzX2NvbnRlbnRvaCJdLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfbFN6UVo0WjdSIiwiY29nbml0bzp1c2VybmFtZSI6IjBiNjZhNGE5LTc3OTAtNDAzNC1hMzBhLWMwMDgwODk2Mjg2NyIsImF1ZCI6IjUyZDlza2tkY2c4cWpwODhvb2sxdXNlNm1rIiwiZXZlbnRfaWQiOiJkMjc2ZGUwMy01YmM3LTRkZjEtYTk4MC1jYmYwYjkyOGU3MDEiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTY1NjEwMDM2MSwibmFtZSI6IkNvbGFib3JhZG9yIiwicGhvbmVfbnVtYmVyIjoiKzUyMTExMSIsImV4cCI6MTY1NjEwMzk2MSwiaWF0IjoxNjU2MTAwMzYxLCJlbWFpbCI6ImJheWFkaTE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ZC1hODNmLTJlOWE0N2E2ZTQzYSIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNjU2Mzc1MzQ5LCJuYW1lIjoiQ29sYWJvcmFkb3IiLCJwaG9uZV9udW1iZXIiOiIrNTIxMTExIiwiZXhwIjoxNjU2Mzc4OTQ5LCJpYXQiOjE2NTYzNzUzNDksImVtYWlsIjoic2FsbWVyb24uNUBob3RtYWlsLmNvbSJ9.AXD7CR-3bJz6vIdBBNB_3xLfaTvlFjHi-cwKdN5qCUSY4msnf1a1RhMEThL3wt7fXi15dy5Fy5b_7zgkWc_NY35Otu1ifQNmSxemncx5qFsNsBH6OvIaZrhiw7XXkfQF20w22f4o8VFW1u0cWudFBYYm6tXlKVEetw-NEu94Mnip0BtQQUU6rFjz5hQM0gWYsvOMmSX3JKQWl4thirzTOqJxrKebFeWnUMs5D3hlFpKeBSKodgB6lLw2522SJmxWXmGCaDOVSMUP9LqB9PsboSOBfSeQpkbIZqd9iNWbrFCusGhnoRrQABucqFwlQ6KPHYTPaOOux-X3pf6i5woX4g",
23
20
  productSelected: {
24
21
  services: {
25
22
  datasheets: 1,
26
23
  descriptions: 1,
27
24
  images: 1,
28
25
  },
29
- orderId: 1213,
30
- status: "AA",
31
- datasheet_status: "AA",
32
- prio: "low",
33
- version: 2,
34
- description_status: "AA",
35
- images_status: "AA",
26
+ orderId: 64,
27
+ status: "AF",
28
+ datasheet_status: "AF",
29
+ prio: "none",
30
+ version: 7,
31
+ description_status: "AF",
32
+ images_status: "AF",
36
33
  article: {
37
- id_article: 17517,
38
- id_category: "691",
39
- name: "Antitranspirante Lady Speed Stick Clinical Complete en Barra para Dama 45 g",
40
- upc: "7509546066172",
41
- timestamp: "2021-10-09T16:33:17.000Z",
42
- id_user: 203,
43
- status: "RECEPTION",
34
+ id_article: 35707,
35
+ id_category: "41",
36
+ name: "chetos",
37
+ upc: "1010101010",
38
+ timestamp: "2022-06-16T18:12:42.000Z",
39
+ id_user: 28,
40
+ status: "NULL",
44
41
  active: 1,
45
- company_id: 226,
46
- company_name: "Prueba Test S.A de C.V.",
47
- country: "null",
48
- id_order: 1213,
49
- id_datasheet_especialist: 334,
50
- id_datasheet_facilitator: 158,
51
- id_description_especialist: 334,
52
- id_description_facilitator: 158,
53
- id_images_especialist: 366,
54
- id_images_facilitator: 14,
55
- id_auditor: 94,
42
+ company_id: 1,
43
+ company_name: "COMPANY DEV",
44
+ country: "México",
45
+ id_order: 64,
46
+ id_datasheet_especialist: 54,
47
+ id_datasheet_facilitator: 52,
48
+ id_description_especialist: 54,
49
+ id_description_facilitator: 52,
50
+ id_images_especialist: 55,
51
+ id_images_facilitator: 53,
52
+ id_auditor: 30,
56
53
  id_recepcionist: null,
57
- category:
58
- "SALUD Y BELLEZA|CUIDADO CORPORAL|DESODORANTES CABALLERO Y DAMA",
59
- missingAttributes: 1,
60
- missingDescriptions: 0,
61
- missingImages: -4,
54
+ category: "ABARROTES|BOTANAS, GOLOSINAS Y CHOCOLATES|BOTANAS",
55
+ missingAttributes: null,
56
+ missingDescriptions: null,
57
+ missingImages: null,
62
58
  },
63
59
  retailers: [
64
60
  {
65
- id: 4,
66
- name: "Walmart Super y Superama",
61
+ id: 3,
62
+ name: "Sam´s Club",
67
63
  country: "México",
68
64
  id_region: 1,
69
65
  active: 1,
70
66
  },
71
67
  {
72
- id: 6,
73
- name: "HEB",
74
- country: "México",
75
- id_region: 1,
76
- active: 1,
77
- },
78
- {
79
- id: 29,
80
- name: "Farmacias del Ahorro",
68
+ id: 8,
69
+ name: "Fragua",
81
70
  country: "México",
82
71
  id_region: 1,
83
72
  active: 1,
84
73
  },
85
74
  ],
86
- country: "null",
87
- upc: "7509546066172",
75
+ country: "México",
76
+ upc: "1010101010",
88
77
  },
89
78
  location: {
90
79
  product: { articleId: 109485, versionId: 3 },
91
80
  },
92
81
  user: {
93
- id_user: 423,
94
- name: "Facilitador Textos",
95
- last_name: " ",
96
- email: "bayadi1538@mnqlm.com",
97
- position: "Tester",
82
+ id_user: 30,
83
+ name: "Admin",
84
+ last_name: "Ulises",
85
+ email: "salmeron.5@hotmail.com",
86
+ position: "Admin",
98
87
  telephone: null,
99
- country: null,
100
- id_company: 254,
101
- id_cognito: "0b66a4a9-7790-4034-a30a-c00808962867",
88
+ country: "México",
89
+ id_company: 2,
90
+ id_cognito: "c94a7305-9365-46ff-a423-4b4bc3b8b180",
102
91
  birth_Date: null,
103
92
  about_me: null,
104
93
  zip_code: null,
105
94
  address: null,
106
95
  job: null,
107
96
  id_stripe: null,
108
- id_role: 4,
97
+ id_role: 6,
109
98
  active: 1,
110
99
  is_retailer: 0,
111
- email_notify: null,
100
+ email_notify: 0,
112
101
  membership: {
113
- id: 750,
114
- start_date: "2022-01-07T21:32:54.000Z",
115
- end_date: "2023-01-07T21:32:54.000Z",
116
- planID: 6,
117
- plan: "prod_KvGd6YSTJyR3AP",
118
- name: "Plan Small",
119
- user_limit: "10",
120
- products_limit: "1000",
121
- type: "Enterprise",
102
+ id: 2,
103
+ start_date: "2021-11-05T02:35:12.000Z",
104
+ end_date: "2022-11-05T02:34:49.000Z",
105
+ planID: 1,
106
+ plan: "prod_KtkvuFFLpOdP6e",
107
+ name: "Plan Free",
108
+ user_limit: "1",
109
+ products_limit: "3",
110
+ type: "PyMES",
122
111
  },
123
- src: "https://content-management-profile-prod.s3.amazonaws.com/id-423/423.png?1656100361978",
112
+ src: "https://content-management-profile.s3.amazonaws.com/id-30/30.png?1656375350443",
124
113
  },
125
114
  };
@@ -77,7 +77,6 @@ export const RetailerProductEdition = ({
77
77
  tabsSections,
78
78
  productSelected = {},
79
79
  user = {},
80
- location = {},
81
80
  token,
82
81
  }) => {
83
82
  const [activeTab, setActiveTab] = useState("Descripción");
@@ -165,6 +164,7 @@ export const RetailerProductEdition = ({
165
164
  const [socketType, setSocketType] = useState(null);
166
165
  const [servicesStatus, setServicesStatus] = useState([]);
167
166
  const [saving, setSaving] = useState(loading);
167
+ const isAuditor = user.id_role === 6;
168
168
 
169
169
  useEffect(() => {
170
170
  checkAll && setSelectedImages(images.values);
@@ -1081,6 +1081,66 @@ export const RetailerProductEdition = ({
1081
1081
  setSaving(loading);
1082
1082
  }, [loading]);
1083
1083
 
1084
+ const validateAll = async (result) => {
1085
+ try {
1086
+ setLoading(true);
1087
+ const evaluationArray = [];
1088
+ const sendAll = [];
1089
+ const conceptArray = ["description", "datasheet", "images"];
1090
+
1091
+ servicesData?.forEach((ret) => {
1092
+ let data = {
1093
+ articleId: product.article.id_article,
1094
+ orderId: product.id_order ?? product.orderId,
1095
+ concept: ret.service,
1096
+ result: result,
1097
+ evalStatus: product[`${ret.service}_status`],
1098
+ retailerId: ret.id_retailer,
1099
+ };
1100
+ evaluationArray.push(
1101
+ axios.put(`${process.env.REACT_APP_EVALUATION_ENDPOINT}`, data, {
1102
+ headers: {
1103
+ Authorization: token,
1104
+ },
1105
+ })
1106
+ );
1107
+ });
1108
+
1109
+ await Promise.all(evaluationArray);
1110
+
1111
+ conceptArray?.forEach((concept) => {
1112
+ let data = {
1113
+ articleId: product.article.id_article,
1114
+ orderId: product.id_order ?? product.orderId,
1115
+ concept,
1116
+ evalStatus: product[`${concept}_status`],
1117
+ };
1118
+ sendAll.push(
1119
+ axios.put(`${process.env.REACT_APP_SEND_EVAL}`, data, {
1120
+ headers: {
1121
+ Authorization: token,
1122
+ },
1123
+ })
1124
+ );
1125
+ });
1126
+ await Promise.all(sendAll);
1127
+ const productTemp = product;
1128
+ productTemp.status = `${result}A`;
1129
+ productTemp.datasheet_status =
1130
+ productTemp.datasheet_status === "NA" ? "NA" : `${result}A`;
1131
+ productTemp.description_status =
1132
+ productTemp.description_status === "NA" ? "NA" : `${result}A`;
1133
+ productTemp.images_status =
1134
+ productTemp.images_status === "NA" ? "NA" : `${result}A`;
1135
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1136
+ setProduct(productTemp);
1137
+
1138
+ loadData();
1139
+ } catch (error) {
1140
+ console.log(error);
1141
+ }
1142
+ };
1143
+
1084
1144
  return (
1085
1145
  <Container headerTop={headerTop}>
1086
1146
  <HeaderTop setHeaderTop={setHeaderTop} />
@@ -1150,9 +1210,50 @@ export const RetailerProductEdition = ({
1150
1210
  />,
1151
1211
  ]);
1152
1212
  }}
1213
+ showApproveRejectAll={
1214
+ isAuditor &&
1215
+ servicesData.every((serv) =>
1216
+ ["RA", "AA", "AP", "AC", "AF"].includes(serv.status)
1217
+ ) &&
1218
+ approveRejectButtons() &&
1219
+ (auditorAssigned() || userAssigned())
1220
+ }
1153
1221
  showValidationButtons={
1154
1222
  approveRejectButtons() && (auditorAssigned() || userAssigned())
1155
1223
  }
1224
+ approveAll={() => validateAll("A")}
1225
+ rejectAll={() => {
1226
+ validateAll("R");
1227
+ setMessage("Rechazado");
1228
+ setComponentsArray([
1229
+ <img src={errorModal} />,
1230
+ <ScreenHeader
1231
+ text={"Agrega tu comentarios para enviar el rechazo"}
1232
+ headerType={"input-name-header"}
1233
+ color={"white"}
1234
+ />,
1235
+ <TagAndInput
1236
+ label={"Caja de Comentario"}
1237
+ inputType={"textarea"}
1238
+ inputId={"modal-commentary-box"}
1239
+ index={0}
1240
+ color={"white"}
1241
+ />,
1242
+ <Button
1243
+ buttonType={"general-default-button"}
1244
+ label={"Enviar comentario"}
1245
+ onClick={(e) =>
1246
+ createComment(
1247
+ e,
1248
+ document.querySelector(
1249
+ "#modal-commentary-box .ql-container .ql-editor > p"
1250
+ ).innerHTML,
1251
+ activeTab
1252
+ )
1253
+ }
1254
+ />,
1255
+ ]);
1256
+ }}
1156
1257
  />
1157
1258
  <FullTabsMenu
1158
1259
  tabsSections={tabsSections}