contentoh-components-library 21.6.22 → 21.6.24

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.
@@ -88,7 +88,7 @@ var _AiProductEdition = require("../../../contexts/AiProductEdition");
88
88
  var _jsxRuntime = require("react/jsx-runtime");
89
89
 
90
90
  var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
91
- var _location$state4, _state$product2, _state$product3, _state$product4, _state$product5, _state$product6, _state$product7, _state$product12, _state$product13, _state$product14, _state$active_retaile3, _location$state5, _location$state6, _state$active_retaile4, _state$active_retaile5, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile6, _state$product15, _state$product16, _state$product17, _state$active_percent, _state$active_percent2, _state$active_retaile7, _state$active_retaile8, _state$active_retaile9, _state$product18, _state$descriptions_i, _state$product19, _state$product20, _state$datasheets_inp, _state$datasheets_inp2, _state$datasheets_inp3, _state$product21, _state$images_values12;
91
+ var _location$state4, _state$product2, _state$product3, _state$product4, _state$product5, _state$product6, _state$product7, _state$product14, _state$product15, _state$product16, _state$active_retaile3, _location$state5, _location$state6, _state$active_retaile4, _state$active_retaile5, _state$images_values$2, _state$images_values10, _state$images_values11, _state$active_retaile6, _state$product17, _state$product18, _state$product19, _state$product20, _family$variants, _family$variants2, _state$active_percent, _state$active_percent2, _state$active_retaile7, _state$active_retaile8, _state$active_retaile9, _state$product21, _state$descriptions_i, _state$product22, _state$product23, _state$datasheets_inp, _state$datasheets_inp2, _state$datasheets_inp3, _state$product24, _state$images_values12;
92
92
 
93
93
  var tabsSections = _ref.tabsSections,
94
94
  _ref$productSelected = _ref.productSelected,
@@ -133,39 +133,54 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
133
133
  showLinkVariants = _useState6[0],
134
134
  setShowLinkVariants = _useState6[1];
135
135
 
136
- var _useState7 = (0, _react.useState)(false),
136
+ var _useState7 = (0, _react.useState)(null),
137
137
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
138
- showRejectModal = _useState8[0],
139
- setShowRejectModal = _useState8[1];
138
+ family = _useState8[0],
139
+ setFamily = _useState8[1];
140
140
 
141
- var _useState9 = (0, _react.useState)(0),
141
+ var _useState9 = (0, _react.useState)(false),
142
142
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
143
- headerTop = _useState10[0],
144
- setHeaderTop = _useState10[1];
143
+ showFamily = _useState10[0],
144
+ setShowFamily = _useState10[1];
145
145
 
146
- var _useState11 = (0, _react.useState)({}),
146
+ var _useState11 = (0, _react.useState)(null),
147
147
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
148
- assig = _useState12[0],
149
- setAssig = _useState12[1];
148
+ loadingVariant = _useState12[0],
149
+ setLoadingVariant = _useState12[1];
150
150
 
151
151
  var _useState13 = (0, _react.useState)(false),
152
152
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
153
- imageLayout = _useState14[0],
154
- setImageLayout = _useState14[1];
153
+ showRejectModal = _useState14[0],
154
+ setShowRejectModal = _useState14[1];
155
155
 
156
- var _useState15 = (0, _react.useState)(false),
156
+ var _useState15 = (0, _react.useState)(0),
157
157
  _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
158
- rejectAll = _useState16[0],
159
- setRejectAll = _useState16[1];
158
+ headerTop = _useState16[0],
159
+ setHeaderTop = _useState16[1];
160
160
 
161
- var _useState17 = (0, _react.useState)({
161
+ var _useState17 = (0, _react.useState)({}),
162
+ _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
163
+ assig = _useState18[0],
164
+ setAssig = _useState18[1];
165
+
166
+ var _useState19 = (0, _react.useState)(false),
167
+ _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
168
+ imageLayout = _useState20[0],
169
+ setImageLayout = _useState20[1];
170
+
171
+ var _useState21 = (0, _react.useState)(false),
172
+ _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
173
+ rejectAll = _useState22[0],
174
+ setRejectAll = _useState22[1];
175
+
176
+ var _useState23 = (0, _react.useState)({
162
177
  "Ficha técnica": null,
163
178
  Descripción: null,
164
179
  Imágenes: null
165
180
  }),
166
- _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
167
- origin = _useState18[0],
168
- setOrigin = _useState18[1];
181
+ _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
182
+ origin = _useState24[0],
183
+ setOrigin = _useState24[1];
169
184
 
170
185
  var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
171
186
  _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
@@ -821,6 +836,200 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
821
836
  payload: items
822
837
  });
823
838
  };
839
+ /*
840
+ Trae la familia del producto: sus variantes, o sus hermanas si el abierto es
841
+ una de ellas.
842
+ Se pide al abrir la sección y no al montar la pantalla: la mayoría de los
843
+ productos no son familia, y una llamada por ficha para no mostrar nada es
844
+ peso que paga todo el mundo por el caso de unos pocos.
845
+ */
846
+
847
+
848
+ var loadFamily = /*#__PURE__*/function () {
849
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
850
+ var _state$product10, res;
851
+
852
+ return _regenerator.default.wrap(function _callee3$(_context3) {
853
+ while (1) {
854
+ switch (_context3.prev = _context3.next) {
855
+ case 0:
856
+ if (!family) {
857
+ _context3.next = 2;
858
+ break;
859
+ }
860
+
861
+ return _context3.abrupt("return");
862
+
863
+ case 2:
864
+ _context3.prev = 2;
865
+ _context3.next = 5;
866
+ return _axios.default.post("".concat(process.env.REACT_APP_VARIANTS_ENDPOINT, "/family"), {
867
+ articleId: (_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.id_article
868
+ }, {
869
+ headers: {
870
+ Authorization: token
871
+ }
872
+ });
873
+
874
+ case 5:
875
+ res = _context3.sent;
876
+ setFamily((0, _api.readPayload)(res));
877
+ _context3.next = 13;
878
+ break;
879
+
880
+ case 9:
881
+ _context3.prev = 9;
882
+ _context3.t0 = _context3["catch"](2);
883
+ console.error("loadFamily: ", _context3.t0);
884
+ setFamily({
885
+ variants: [],
886
+ parent: null,
887
+ error: true
888
+ });
889
+
890
+ case 13:
891
+ case "end":
892
+ return _context3.stop();
893
+ }
894
+ }
895
+ }, _callee3, null, [[2, 9]]);
896
+ }));
897
+
898
+ return function loadFamily() {
899
+ return _ref7.apply(this, arguments);
900
+ };
901
+ }();
902
+ /*
903
+ Abre otra variante de la familia.
904
+ Esta pantalla no lee el producto de la URL: lo lee de sessionStorage, donde
905
+ lo dejó el listado al hacer clic. Así que navegar a /products/:id sin más
906
+ cambia la barra de direcciones y deja el producto anterior en pantalla.
907
+ Por eso primero se trae el producto por su ID —no por su UPC: hay 12,024 UPC
908
+ repetidos entre artículos activos y 5,579 de esos casos caen dentro de la
909
+ misma compañía, así que el UPC no identifica— y se deja en sessionStorage con
910
+ la misma forma que usa el listado. Después se navega.
911
+ Es un rodeo, y lo es porque el origen del dato está mal puesto. Arreglarlo de
912
+ raíz —que la ficha lea de la URL— toca todas las plataformas y no cabe aquí.
913
+ */
914
+
915
+
916
+ var openVariant = /*#__PURE__*/function () {
917
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(articleId) {
918
+ var res, _readPayload, data, encontrado;
919
+
920
+ return _regenerator.default.wrap(function _callee4$(_context4) {
921
+ while (1) {
922
+ switch (_context4.prev = _context4.next) {
923
+ case 0:
924
+ setLoadingVariant(articleId);
925
+ _context4.prev = 1;
926
+ _context4.next = 4;
927
+ return _axios.default.get("".concat(process.env.REACT_APP_NEW_ARTICLES_ENDPOINT), {
928
+ params: {
929
+ listType: "general",
930
+ filterByArticleId: articleId
931
+ },
932
+ headers: {
933
+ Authorization: token
934
+ }
935
+ });
936
+
937
+ case 4:
938
+ res = _context4.sent;
939
+ // read-articles-v2 responde { count, data: [...] }.
940
+ _readPayload = (0, _api.readPayload)(res), data = _readPayload.data;
941
+ encontrado = (data !== null && data !== void 0 ? data : []).find(function (item) {
942
+ return Number(item.id_article) === Number(articleId);
943
+ });
944
+
945
+ if (encontrado) {
946
+ sessionStorage.setItem("productSelected", JSON.stringify((0, _objectSpread4.default)((0, _objectSpread4.default)({}, encontrado), {}, {
947
+ article: {
948
+ id_article: encontrado.id_article
949
+ }
950
+ })));
951
+ sessionStorage.setItem("productEdit", JSON.stringify({
952
+ ArticleId: encontrado.id_article,
953
+ idCategory: encontrado.id_category,
954
+ product: encontrado
955
+ }));
956
+ }
957
+
958
+ _context4.next = 13;
959
+ break;
960
+
961
+ case 10:
962
+ _context4.prev = 10;
963
+ _context4.t0 = _context4["catch"](1);
964
+ // Si la consulta falla se navega igual: la pantalla mostrará el producto
965
+ // que hubiera en sessionStorage, que es el comportamiento de siempre.
966
+ // Peor sería dejar el clic sin efecto y que pareciera que no responde.
967
+ console.error("openVariant: ", _context4.t0);
968
+
969
+ case 13:
970
+ _context4.prev = 13;
971
+ setLoadingVariant(null);
972
+ window.location.assign("/products/".concat(articleId, "/datasheet"));
973
+ return _context4.finish(13);
974
+
975
+ case 17:
976
+ case "end":
977
+ return _context4.stop();
978
+ }
979
+ }
980
+ }, _callee4, null, [[1, 10, 13, 17]]);
981
+ }));
982
+
983
+ return function openVariant(_x2) {
984
+ return _ref8.apply(this, arguments);
985
+ };
986
+ }();
987
+ /*
988
+ Refresca la ficha después de ligar, sin recargar la página.
989
+ Recargar no servía: el producto de esta pantalla viene del listado —por
990
+ sessionStorage—, así que tras el refresh volvía el mismo objeto de antes y el
991
+ contador seguía mostrando el número viejo. Además una recarga se lleva lo que
992
+ el usuario tenga sin guardar.
993
+ Los dos modos tienen efectos opuestos sobre este producto: ligando hijos GANA
994
+ variantes; ligándose a un padre pasa a SER una, y entonces el botón de ligar
995
+ desaparece porque la jerarquía es de un solo nivel.
996
+ */
997
+
998
+
999
+ var handleOnLinkedVariants = function handleOnLinkedVariants(result) {
1000
+ var _state$product$varian, _state$product11, _result$linked, _result$parentArticle;
1001
+
1002
+ if (!result) return;
1003
+ var updatedProduct = result.mode === "children" ? (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
1004
+ variantsCount: ((_state$product$varian = (_state$product11 = state.product) === null || _state$product11 === void 0 ? void 0 : _state$product11.variantsCount) !== null && _state$product$varian !== void 0 ? _state$product$varian : 0) + ((_result$linked = result.linked) !== null && _result$linked !== void 0 ? _result$linked : []).length
1005
+ }) : (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
1006
+ parentArticleId: (_result$parentArticle = result.parentArticleId) !== null && _result$parentArticle !== void 0 ? _result$parentArticle : null,
1007
+ variantsCount: 0
1008
+ });
1009
+ dispatch({
1010
+ type: "SET_PRODUCT",
1011
+ payload: updatedProduct
1012
+ }); // La lista cacheada quedó vieja: se descarta para que vuelva a pedirse.
1013
+
1014
+ setFamily(null); // Y en sessionStorage, que es de donde sale el producto al recargar. Sin
1015
+ // esto el arreglo dura hasta el siguiente F5 y vuelve el contador viejo,
1016
+ // que es justo el síntoma que se reportó.
1017
+
1018
+ try {
1019
+ sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
1020
+ var productEdit = JSON.parse(sessionStorage.getItem("productEdit"));
1021
+
1022
+ if (productEdit) {
1023
+ sessionStorage.setItem("productEdit", JSON.stringify((0, _objectSpread4.default)((0, _objectSpread4.default)({}, productEdit), {}, {
1024
+ product: updatedProduct
1025
+ })));
1026
+ }
1027
+ } catch (error) {
1028
+ // Un sessionStorage inaccesible no debe tumbar la pantalla: el estado en
1029
+ // memoria ya quedó bien y es lo que el usuario está viendo.
1030
+ console.error("linkVariants/sessionStorage: ", error);
1031
+ }
1032
+ };
824
1033
  /*
825
1034
  Acción "Volver a heredar del producto" de los chips de herencia.
826
1035
  La inicia la variante, no el padre, y descarta un valor capturado a mano: por
@@ -833,24 +1042,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
833
1042
 
834
1043
 
835
1044
  var handleOnRestoreInheritance = /*#__PURE__*/function () {
836
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(attributeId) {
837
- var _state$product10;
1045
+ var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(attributeId) {
1046
+ var _state$product12;
838
1047
 
839
1048
  var res, data;
840
- return _regenerator.default.wrap(function _callee3$(_context3) {
1049
+ return _regenerator.default.wrap(function _callee5$(_context5) {
841
1050
  while (1) {
842
- switch (_context3.prev = _context3.next) {
1051
+ switch (_context5.prev = _context5.next) {
843
1052
  case 0:
844
- if (!(!attributeId || !((_state$product10 = state.product) !== null && _state$product10 !== void 0 && _state$product10.id_article))) {
845
- _context3.next = 2;
1053
+ if (!(!attributeId || !((_state$product12 = state.product) !== null && _state$product12 !== void 0 && _state$product12.id_article))) {
1054
+ _context5.next = 2;
846
1055
  break;
847
1056
  }
848
1057
 
849
- return _context3.abrupt("return");
1058
+ return _context5.abrupt("return");
850
1059
 
851
1060
  case 2:
852
- _context3.prev = 2;
853
- _context3.next = 5;
1061
+ _context5.prev = 2;
1062
+ _context5.next = 5;
854
1063
  return _axios.default.post("".concat(process.env.REACT_APP_VARIANTS_ENDPOINT, "/restore"), {
855
1064
  articleId: state.product.id_article,
856
1065
  attributes: [Number(attributeId)]
@@ -861,7 +1070,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
861
1070
  });
862
1071
 
863
1072
  case 5:
864
- res = _context3.sent;
1073
+ res = _context5.sent;
865
1074
  // El API responde 200 aunque la lambda haya devuelto 400: el resultado
866
1075
  // real viaja en el cuerpo y readPayload lo convierte en excepción.
867
1076
  data = (0, _api.readPayload)(res);
@@ -875,24 +1084,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
875
1084
  };
876
1085
  })
877
1086
  });
878
- _context3.next = 13;
1087
+ _context5.next = 13;
879
1088
  break;
880
1089
 
881
1090
  case 10:
882
- _context3.prev = 10;
883
- _context3.t0 = _context3["catch"](2);
884
- console.error("restoreInheritance: ", _context3.t0);
1091
+ _context5.prev = 10;
1092
+ _context5.t0 = _context5["catch"](2);
1093
+ console.error("restoreInheritance: ", _context5.t0);
885
1094
 
886
1095
  case 13:
887
1096
  case "end":
888
- return _context3.stop();
1097
+ return _context5.stop();
889
1098
  }
890
1099
  }
891
- }, _callee3, null, [[2, 10]]);
1100
+ }, _callee5, null, [[2, 10]]);
892
1101
  }));
893
1102
 
894
- return function handleOnRestoreInheritance(_x2) {
895
- return _ref7.apply(this, arguments);
1103
+ return function handleOnRestoreInheritance(_x3) {
1104
+ return _ref9.apply(this, arguments);
896
1105
  };
897
1106
  }();
898
1107
 
@@ -927,14 +1136,14 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
927
1136
  };
928
1137
 
929
1138
  var sendEvaluation = /*#__PURE__*/function () {
930
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(result) {
931
- var _state$product$id_ord, _state$active_retaile2, _state$product$status, _state$product$status2, _state$product11;
1139
+ var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(result) {
1140
+ var _state$product$id_ord, _state$active_retaile2, _state$product$status, _state$product$status2, _state$product13;
932
1141
 
933
1142
  var concept, articleId, orderId, retailerId, evalStatus, data, _newStatuses$newStatu, _state$services_data, res, newStatuses, serviceStatus, updatedStatusByRetailer, updatedProduct, updatedServicesData;
934
1143
 
935
- return _regenerator.default.wrap(function _callee4$(_context4) {
1144
+ return _regenerator.default.wrap(function _callee6$(_context6) {
936
1145
  while (1) {
937
- switch (_context4.prev = _context4.next) {
1146
+ switch (_context6.prev = _context6.next) {
938
1147
  case 0:
939
1148
  dispatch({
940
1149
  type: "SET_SAVING",
@@ -944,23 +1153,23 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
944
1153
  articleId = state.product.id_article;
945
1154
  orderId = (_state$product$id_ord = state.product.id_order) !== null && _state$product$id_ord !== void 0 ? _state$product$id_ord : state.product.orderId;
946
1155
  retailerId = (_state$active_retaile2 = state.active_retailer) === null || _state$active_retaile2 === void 0 ? void 0 : _state$active_retaile2.id_retailer;
947
- evalStatus = ((_state$product$status = state.product.statusByRetailer) === null || _state$product$status === void 0 ? void 0 : (_state$product$status2 = _state$product$status[retailerId]) === null || _state$product$status2 === void 0 ? void 0 : _state$product$status2[concept]) || state.product["".concat(concept, "_status")] || ((_state$product11 = state.product) === null || _state$product11 === void 0 ? void 0 : _state$product11.version_status);
1156
+ evalStatus = ((_state$product$status = state.product.statusByRetailer) === null || _state$product$status === void 0 ? void 0 : (_state$product$status2 = _state$product$status[retailerId]) === null || _state$product$status2 === void 0 ? void 0 : _state$product$status2[concept]) || state.product["".concat(concept, "_status")] || ((_state$product13 = state.product) === null || _state$product13 === void 0 ? void 0 : _state$product13.version_status);
948
1157
  data = {
949
1158
  articleId: articleId,
950
1159
  orderId: orderId,
951
1160
  concept: concept,
952
1161
  evalStatus: evalStatus
953
1162
  };
954
- _context4.prev = 7;
1163
+ _context6.prev = 7;
955
1164
 
956
1165
  if (!result) {
957
- _context4.next = 22;
1166
+ _context6.next = 22;
958
1167
  break;
959
1168
  }
960
1169
 
961
1170
  data.result = result;
962
1171
  data.retailerId = retailerId;
963
- _context4.next = 13;
1172
+ _context6.next = 13;
964
1173
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
965
1174
  headers: {
966
1175
  Authorization: token
@@ -968,7 +1177,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
968
1177
  });
969
1178
 
970
1179
  case 13:
971
- res = _context4.sent;
1180
+ res = _context6.sent;
972
1181
  newStatuses = JSON.parse(res.data.body);
973
1182
  serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")]; // Actualizar el producto con los nuevos estados
974
1183
 
@@ -1005,13 +1214,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1005
1214
  });
1006
1215
 
1007
1216
  case 22:
1008
- _context4.next = 28;
1217
+ _context6.next = 28;
1009
1218
  break;
1010
1219
 
1011
1220
  case 24:
1012
- _context4.prev = 24;
1013
- _context4.t0 = _context4["catch"](7);
1014
- console.error("Error sending evaluation:", _context4.t0);
1221
+ _context6.prev = 24;
1222
+ _context6.t0 = _context6["catch"](7);
1223
+ console.error("Error sending evaluation:", _context6.t0);
1015
1224
  dispatch({
1016
1225
  type: "SET_MODAL",
1017
1226
  payload: {
@@ -1023,32 +1232,32 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1023
1232
  });
1024
1233
 
1025
1234
  case 28:
1026
- _context4.prev = 28;
1235
+ _context6.prev = 28;
1027
1236
  dispatch({
1028
1237
  type: "SET_SAVING",
1029
1238
  payload: false
1030
1239
  });
1031
- return _context4.finish(28);
1240
+ return _context6.finish(28);
1032
1241
 
1033
1242
  case 31:
1034
1243
  case "end":
1035
- return _context4.stop();
1244
+ return _context6.stop();
1036
1245
  }
1037
1246
  }
1038
- }, _callee4, null, [[7, 24, 28, 31]]);
1247
+ }, _callee6, null, [[7, 24, 28, 31]]);
1039
1248
  }));
1040
1249
 
1041
- return function sendEvaluation(_x3) {
1042
- return _ref8.apply(this, arguments);
1250
+ return function sendEvaluation(_x4) {
1251
+ return _ref10.apply(this, arguments);
1043
1252
  };
1044
1253
  }();
1045
1254
 
1046
1255
  var evaluationToRetailer = /*#__PURE__*/function () {
1047
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(result) {
1256
+ var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(result) {
1048
1257
  var data, statusComplete, updatedProduct;
1049
- return _regenerator.default.wrap(function _callee5$(_context5) {
1258
+ return _regenerator.default.wrap(function _callee7$(_context7) {
1050
1259
  while (1) {
1051
- switch (_context5.prev = _context5.next) {
1260
+ switch (_context7.prev = _context7.next) {
1052
1261
  case 0:
1053
1262
  dispatch({
1054
1263
  type: "SET_SAVING",
@@ -1060,8 +1269,8 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1060
1269
  versionId: state.product.version,
1061
1270
  status: result
1062
1271
  };
1063
- _context5.prev = 2;
1064
- _context5.next = 5;
1272
+ _context7.prev = 2;
1273
+ _context7.next = 5;
1065
1274
  return _axios.default.put("".concat(process.env.REACT_APP_RETAILER_REQUEST), data, {
1066
1275
  headers: {
1067
1276
  Authorization: token
@@ -1091,13 +1300,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1091
1300
  image: _genericModalCheck.default
1092
1301
  }
1093
1302
  });
1094
- _context5.next = 15;
1303
+ _context7.next = 15;
1095
1304
  break;
1096
1305
 
1097
1306
  case 11:
1098
- _context5.prev = 11;
1099
- _context5.t0 = _context5["catch"](2);
1100
- console.error("Error evaluating to retailer:", _context5.t0);
1307
+ _context7.prev = 11;
1308
+ _context7.t0 = _context7["catch"](2);
1309
+ console.error("Error evaluating to retailer:", _context7.t0);
1101
1310
  dispatch({
1102
1311
  type: "SET_MODAL",
1103
1312
  payload: {
@@ -1109,23 +1318,23 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1109
1318
  });
1110
1319
 
1111
1320
  case 15:
1112
- _context5.prev = 15;
1321
+ _context7.prev = 15;
1113
1322
  dispatch({
1114
1323
  type: "SET_SAVING",
1115
1324
  payload: false
1116
1325
  });
1117
- return _context5.finish(15);
1326
+ return _context7.finish(15);
1118
1327
 
1119
1328
  case 18:
1120
1329
  case "end":
1121
- return _context5.stop();
1330
+ return _context7.stop();
1122
1331
  }
1123
1332
  }
1124
- }, _callee5, null, [[2, 11, 15, 18]]);
1333
+ }, _callee7, null, [[2, 11, 15, 18]]);
1125
1334
  }));
1126
1335
 
1127
- return function evaluationToRetailer(_x4) {
1128
- return _ref9.apply(this, arguments);
1336
+ return function evaluationToRetailer(_x5) {
1337
+ return _ref11.apply(this, arguments);
1129
1338
  };
1130
1339
  }();
1131
1340
 
@@ -1256,18 +1465,18 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1256
1465
  };
1257
1466
 
1258
1467
  var handleOnEvaluateAll = /*#__PURE__*/function () {
1259
- var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(result) {
1468
+ var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(result) {
1260
1469
  var _state$product$id_ord2, _state$services_data2, evaluationArray, conceptArray, dataGeneral, isProvider, userType, status, updatedStatusByRetailer, updatedProduct;
1261
1470
 
1262
- return _regenerator.default.wrap(function _callee6$(_context6) {
1471
+ return _regenerator.default.wrap(function _callee8$(_context8) {
1263
1472
  while (1) {
1264
- switch (_context6.prev = _context6.next) {
1473
+ switch (_context8.prev = _context8.next) {
1265
1474
  case 0:
1266
1475
  dispatch({
1267
1476
  type: "SET_SAVING",
1268
1477
  payload: true
1269
1478
  });
1270
- _context6.prev = 1;
1479
+ _context8.prev = 1;
1271
1480
  evaluationArray = [];
1272
1481
  conceptArray = ["description", "datasheet", "images"];
1273
1482
  dataGeneral = {
@@ -1298,7 +1507,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1298
1507
  }));
1299
1508
  }); // Ejecutar todas las evaluaciones
1300
1509
 
1301
- _context6.next = 9;
1510
+ _context8.next = 9;
1302
1511
  return Promise.all(evaluationArray);
1303
1512
 
1304
1513
  case 9:
@@ -1343,13 +1552,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1343
1552
  image: _genericModalCheck.default
1344
1553
  }
1345
1554
  });
1346
- _context6.next = 24;
1555
+ _context8.next = 24;
1347
1556
  break;
1348
1557
 
1349
1558
  case 20:
1350
- _context6.prev = 20;
1351
- _context6.t0 = _context6["catch"](1);
1352
- console.error("Error evaluating all:", _context6.t0);
1559
+ _context8.prev = 20;
1560
+ _context8.t0 = _context8["catch"](1);
1561
+ console.error("Error evaluating all:", _context8.t0);
1353
1562
  dispatch({
1354
1563
  type: "SET_MODAL",
1355
1564
  payload: {
@@ -1361,24 +1570,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1361
1570
  });
1362
1571
 
1363
1572
  case 24:
1364
- _context6.prev = 24;
1573
+ _context8.prev = 24;
1365
1574
  dispatch({
1366
1575
  type: "SET_SAVING",
1367
1576
  payload: false
1368
1577
  });
1369
1578
  setRejectAll(false);
1370
- return _context6.finish(24);
1579
+ return _context8.finish(24);
1371
1580
 
1372
1581
  case 28:
1373
1582
  case "end":
1374
- return _context6.stop();
1583
+ return _context8.stop();
1375
1584
  }
1376
1585
  }
1377
- }, _callee6, null, [[1, 20, 24, 28]]);
1586
+ }, _callee8, null, [[1, 20, 24, 28]]);
1378
1587
  }));
1379
1588
 
1380
- return function handleOnEvaluateAll(_x5) {
1381
- return _ref10.apply(this, arguments);
1589
+ return function handleOnEvaluateAll(_x6) {
1590
+ return _ref12.apply(this, arguments);
1382
1591
  };
1383
1592
  }();
1384
1593
 
@@ -1427,17 +1636,15 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1427
1636
  setShowVersionSelector: setShowVersionSelector,
1428
1637
  jwt: token
1429
1638
  }), showLinkVariants && /*#__PURE__*/(0, _jsxRuntime.jsx)(_LinkVariantsModal.LinkVariantsModal, {
1430
- articleId: (_state$product12 = state.product) === null || _state$product12 === void 0 ? void 0 : _state$product12.id_article,
1431
- articleName: (_state$product13 = state.product) === null || _state$product13 === void 0 ? void 0 : _state$product13.name,
1432
- articleUpc: (_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.upc,
1639
+ articleId: (_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.id_article,
1640
+ articleName: (_state$product15 = state.product) === null || _state$product15 === void 0 ? void 0 : _state$product15.name,
1641
+ articleUpc: (_state$product16 = state.product) === null || _state$product16 === void 0 ? void 0 : _state$product16.upc,
1433
1642
  activeRetailerId: (_state$active_retaile3 = state.active_retailer) === null || _state$active_retaile3 === void 0 ? void 0 : _state$active_retaile3.id_retailer,
1434
1643
  token: token,
1435
1644
  onClose: function onClose() {
1436
1645
  return setShowLinkVariants(false);
1437
1646
  },
1438
- onLinked: function onLinked() {
1439
- return window.location.reload();
1440
- }
1647
+ onLinked: handleOnLinkedVariants
1441
1648
  }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductImageModal.ProductImageModal, {
1442
1649
  images: state.images_values,
1443
1650
  setShowModal: setShowModal,
@@ -1498,21 +1705,21 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1498
1705
  type: "pink",
1499
1706
  label: "Aceptar",
1500
1707
  size: 12,
1501
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
1708
+ onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
1502
1709
  var elements, isMessageEmpty, container, existingAlert, alert, fullMessage;
1503
- return _regenerator.default.wrap(function _callee7$(_context7) {
1710
+ return _regenerator.default.wrap(function _callee9$(_context9) {
1504
1711
  while (1) {
1505
- switch (_context7.prev = _context7.next) {
1712
+ switch (_context9.prev = _context9.next) {
1506
1713
  case 0:
1507
1714
  elements = document.querySelectorAll("#modal-message-box .ql-container .ql-editor > p");
1508
1715
 
1509
1716
  if (!(!elements || elements.length === 0)) {
1510
- _context7.next = 4;
1717
+ _context9.next = 4;
1511
1718
  break;
1512
1719
  }
1513
1720
 
1514
1721
  console.error("Elemento no encontrado");
1515
- return _context7.abrupt("return");
1722
+ return _context9.abrupt("return");
1516
1723
 
1517
1724
  case 4:
1518
1725
  isMessageEmpty = Array.from(elements).every(function (el) {
@@ -1521,7 +1728,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1521
1728
  });
1522
1729
 
1523
1730
  if (!isMessageEmpty) {
1524
- _context7.next = 10;
1731
+ _context9.next = 10;
1525
1732
  break;
1526
1733
  }
1527
1734
 
@@ -1536,13 +1743,13 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1536
1743
  container.appendChild(alert);
1537
1744
  }
1538
1745
 
1539
- return _context7.abrupt("return");
1746
+ return _context9.abrupt("return");
1540
1747
 
1541
1748
  case 10:
1542
1749
  fullMessage = Array.from(elements).map(function (element) {
1543
1750
  return element.innerHTML;
1544
1751
  }).join("").replace(/<br\s*\/?>/gi, "\n");
1545
- _context7.next = 13;
1752
+ _context9.next = 13;
1546
1753
  return createComment(fullMessage, token);
1547
1754
 
1548
1755
  case 13:
@@ -1551,10 +1758,10 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1551
1758
 
1552
1759
  case 15:
1553
1760
  case "end":
1554
- return _context7.stop();
1761
+ return _context9.stop();
1555
1762
  }
1556
1763
  }
1557
- }, _callee7);
1764
+ }, _callee9);
1558
1765
  }))
1559
1766
  }, "btn-Aceptar")]
1560
1767
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
@@ -1581,7 +1788,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1581
1788
  activeImage: (_state$images_values10 = state.images_values) !== null && _state$images_values10 !== void 0 && _state$images_values10.values ? (_state$images_values11 = state.images_values) === null || _state$images_values11 === void 0 ? void 0 : _state$images_values11.values[state.current_image] : {},
1582
1789
  assignationsImages: assig,
1583
1790
  retailerSelected: (_state$active_retaile6 = state.active_retailer) === null || _state$active_retaile6 === void 0 ? void 0 : _state$active_retaile6.id_retailer,
1584
- imagesStatus: ((_state$product15 = state.product) === null || _state$product15 === void 0 ? void 0 : _state$product15.images_status) || "-",
1791
+ imagesStatus: ((_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : _state$product17.images_status) || "-",
1585
1792
  isRetailer: isRetailer,
1586
1793
  setShowVersionSelector: setShowVersionSelector,
1587
1794
  version: state.product.version,
@@ -1594,7 +1801,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1594
1801
  className: "product-information",
1595
1802
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1596
1803
  className: "product-information",
1597
- children: [!((_state$product16 = state.product) !== null && _state$product16 !== void 0 && _state$product16.parentArticleId) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1804
+ children: [!((_state$product18 = state.product) !== null && _state$product18 !== void 0 && _state$product18.parentArticleId) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1598
1805
  className: "variants-actions",
1599
1806
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
1600
1807
  type: "button",
@@ -1603,9 +1810,85 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1603
1810
  return setShowLinkVariants(true);
1604
1811
  },
1605
1812
  children: "Ligar productos"
1606
- }), ((_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : _state$product17.variantsCount) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
1813
+ }), ((_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.variantsCount) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
1814
+ type: "button",
1815
+ className: "variants-count",
1816
+ "aria-expanded": showFamily,
1817
+ onClick: function onClick() {
1818
+ setShowFamily(function (abierto) {
1819
+ return !abierto;
1820
+ });
1821
+ loadFamily();
1822
+ },
1823
+ children: [state.product.variantsCount, " variante", state.product.variantsCount === 1 ? "" : "s", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1824
+ "aria-hidden": "true",
1825
+ children: showFamily ? " ▴" : " ▾"
1826
+ })]
1827
+ })]
1828
+ }), ((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.parentArticleId) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1829
+ className: "variants-actions",
1830
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
1831
+ type: "button",
1607
1832
  className: "variants-count",
1608
- children: [state.product.variantsCount, " variante", state.product.variantsCount === 1 ? "" : "s"]
1833
+ "aria-expanded": showFamily,
1834
+ onClick: function onClick() {
1835
+ setShowFamily(function (abierto) {
1836
+ return !abierto;
1837
+ });
1838
+ loadFamily();
1839
+ },
1840
+ children: ["Variante de otro producto", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1841
+ "aria-hidden": "true",
1842
+ children: showFamily ? " ▴" : " ▾"
1843
+ })]
1844
+ })
1845
+ }), showFamily && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1846
+ className: "variants-family",
1847
+ children: [!family && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1848
+ className: "loading",
1849
+ children: "Cargando familia\u2026"
1850
+ }), (family === null || family === void 0 ? void 0 : family.error) && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1851
+ className: "loading",
1852
+ children: "No se pudo cargar la familia de este producto."
1853
+ }), (family === null || family === void 0 ? void 0 : family.parent) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
1854
+ type: "button",
1855
+ className: "family-row parent",
1856
+ disabled: loadingVariant !== null,
1857
+ onClick: function onClick() {
1858
+ return openVariant(family.parent.articleId);
1859
+ },
1860
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1861
+ className: "role",
1862
+ children: loadingVariant === family.parent.articleId ? "Abriendo…" : "Producto padre"
1863
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1864
+ className: "name",
1865
+ children: family.parent.name
1866
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1867
+ className: "upc",
1868
+ children: family.parent.upc
1869
+ })]
1870
+ }), family === null || family === void 0 ? void 0 : (_family$variants = family.variants) === null || _family$variants === void 0 ? void 0 : _family$variants.map(function (variant) {
1871
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
1872
+ type: "button",
1873
+ className: "family-row".concat(variant.isCurrent ? " current" : ""),
1874
+ disabled: variant.isCurrent || loadingVariant !== null,
1875
+ onClick: function onClick() {
1876
+ return openVariant(variant.articleId);
1877
+ },
1878
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1879
+ className: "role",
1880
+ children: loadingVariant === variant.articleId ? "Abriendo…" : variant.isCurrent ? "Estás aquí" : "Variante"
1881
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1882
+ className: "name",
1883
+ children: variant.name
1884
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
1885
+ className: "upc",
1886
+ children: variant.upc
1887
+ })]
1888
+ }, variant.articleId);
1889
+ }), family && !family.error && !((_family$variants2 = family.variants) !== null && _family$variants2 !== void 0 && _family$variants2.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
1890
+ className: "loading",
1891
+ children: "Este producto no tiene variantes."
1609
1892
  })]
1610
1893
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader, {
1611
1894
  headerData: state.product,
@@ -1657,11 +1940,11 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1657
1940
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1658
1941
  className: "services-information-container " + (imageLayout && state.active_tab === "Imágenes" ? "image-services" : ""),
1659
1942
  children: state.saving ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1660
- children: [state.active_tab === "Descripción" && (((_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.description_status) !== "NS" ? (_state$descriptions_i = state.descriptions_inputs) !== null && _state$descriptions_i !== void 0 && _state$descriptions_i[0] ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1943
+ children: [state.active_tab === "Descripción" && (((_state$product21 = state.product) === null || _state$product21 === void 0 ? void 0 : _state$product21.description_status) !== "NS" ? (_state$descriptions_i = state.descriptions_inputs) !== null && _state$descriptions_i !== void 0 && _state$descriptions_i[0] ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1661
1944
  activeSection: state.active_tab,
1662
1945
  inputGroup: state.descriptions_inputs[0],
1663
1946
  updatedDescriptions: state.updated_descriptions_inputs,
1664
- articleId: (_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.id_article,
1947
+ articleId: (_state$product22 = state.product) === null || _state$product22 === void 0 ? void 0 : _state$product22.id_article,
1665
1948
  version: state.product.version,
1666
1949
  isShowbox: false,
1667
1950
  dinamicHeight: true,
@@ -1673,7 +1956,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1673
1956
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1674
1957
  text: "No cuentas con este servicio",
1675
1958
  headerType: "input-name-header"
1676
- })), state.active_tab === "Ficha técnica" && (((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.datasheet_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1959
+ })), state.active_tab === "Ficha técnica" && (((_state$product23 = state.product) === null || _state$product23 === void 0 ? void 0 : _state$product23.datasheet_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1677
1960
  children: ((_state$datasheets_inp = state.datasheets_inputs) === null || _state$datasheets_inp === void 0 ? void 0 : (_state$datasheets_inp2 = _state$datasheets_inp[0]) === null || _state$datasheets_inp2 === void 0 ? void 0 : (_state$datasheets_inp3 = _state$datasheets_inp2.data) === null || _state$datasheets_inp3 === void 0 ? void 0 : _state$datasheets_inp3.length) > 0 ? state.datasheets_inputs[0].data.map(function (dataGroup, index) {
1678
1961
  var _state$datasheets_inp4, _state$services, _state$services$datas, _state$services$datas2;
1679
1962
 
@@ -1703,7 +1986,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
1703
1986
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1704
1987
  text: "No cuentas con este servicio",
1705
1988
  headerType: "input-name-header"
1706
- })), state.active_tab === "Imágenes" && (((_state$product21 = state.product) === null || _state$product21 === void 0 ? void 0 : _state$product21.images_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1989
+ })), state.active_tab === "Imágenes" && (((_state$product24 = state.product) === null || _state$product24 === void 0 ? void 0 : _state$product24.images_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1707
1990
  children: [!imageLayout && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {
1708
1991
  checkAll: state.all_image_checked // Determina si el checkbox "Seleccionar todo" está marcado
1709
1992
  ,