contentoh-components-library 21.5.98 → 21.5.99

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.
Files changed (63) hide show
  1. package/dist/components/atoms/GeneralButton/styles.js +1 -1
  2. package/dist/components/atoms/GeneralInput/index.js +54 -249
  3. package/dist/components/atoms/GeneralInput/styles.js +3 -7
  4. package/dist/components/atoms/InputFormatter/index.js +68 -223
  5. package/dist/components/atoms/InputFormatter/styles.js +4 -20
  6. package/dist/components/molecules/StatusAsignationInfo/index.js +1 -11
  7. package/dist/components/molecules/TabsMenu/index.js +1 -13
  8. package/dist/components/molecules/TagAndInput/index.js +24 -364
  9. package/dist/components/molecules/TagAndInput/styles.js +2 -2
  10. package/dist/components/organisms/FullProductNameHeader/index.js +22 -6
  11. package/dist/components/organisms/InputGroup/index.js +18 -22
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +337 -150
  13. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
  14. package/dist/components/pages/ProviderProductEdition/index.js +377 -413
  15. package/dist/components/pages/ProviderProductEdition/utils.js +0 -1
  16. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +211 -125
  17. package/dist/components/pages/RetailerProductEdition/index.js +2236 -1738
  18. package/dist/components/pages/RetailerProductEdition/styles.js +2 -4
  19. package/dist/components/pages/RetailerProductEdition/utils.js +2 -251
  20. package/package.json +2 -4
  21. package/src/components/atoms/GeneralButton/styles.js +0 -4
  22. package/src/components/atoms/GeneralInput/index.js +60 -241
  23. package/src/components/atoms/GeneralInput/styles.js +0 -81
  24. package/src/components/atoms/InputFormatter/index.js +51 -200
  25. package/src/components/atoms/InputFormatter/styles.js +0 -284
  26. package/src/components/molecules/StatusAsignationInfo/index.js +1 -9
  27. package/src/components/molecules/TabsMenu/index.js +0 -12
  28. package/src/components/molecules/TagAndInput/index.js +21 -294
  29. package/src/components/molecules/TagAndInput/styles.js +17 -59
  30. package/src/components/organisms/FullProductNameHeader/index.js +28 -4
  31. package/src/components/organisms/FullTabsMenu/index.js +1 -1
  32. package/src/components/organisms/InputGroup/index.js +4 -12
  33. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +202 -174
  34. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
  35. package/src/components/pages/ProviderProductEdition/index.js +418 -486
  36. package/src/components/pages/ProviderProductEdition/utils.js +2 -2
  37. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +243 -136
  38. package/src/components/pages/RetailerProductEdition/index.js +1717 -1563
  39. package/src/components/pages/RetailerProductEdition/styles.js +2 -67
  40. package/src/components/pages/RetailerProductEdition/utils.js +0 -240
  41. package/src/ai/utils/compare-strings.js +0 -45
  42. package/src/assets/images/Icons/arrow.png +0 -0
  43. package/src/assets/images/Icons/cancel.png +0 -0
  44. package/src/assets/images/Icons/ia-icon.png +0 -0
  45. package/src/assets/images/Icons/loading.svg +0 -5
  46. package/src/assets/images/Icons/reload.png +0 -0
  47. package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +0 -10
  48. package/src/components/atoms/RetailerSelector/index.js +0 -3
  49. package/src/components/atoms/RetailerSelector/styles.js +0 -0
  50. package/src/components/organisms/ChangeStatusModal/index.jsx +0 -488
  51. package/src/components/organisms/ChangeStatusModal/styles.js +0 -333
  52. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +0 -575
  53. package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +0 -62
  54. package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +0 -344
  55. package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +0 -155
  56. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +0 -114
  57. package/src/components/pages/RetailerProductEdition/context/reducers/system.js +0 -60
  58. package/src/components/pages/RetailerProductEdition/index_old.js +0 -1979
  59. package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +0 -101
  60. package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +0 -115
  61. package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +0 -174
  62. package/src/contexts/AiProductEdition.jsx +0 -347
  63. package/src/global-files/statusDictionary.js +0 -103
@@ -9,247 +9,457 @@ exports.RetailerProductEdition = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
13
-
14
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
15
13
 
16
- var _objectSpread5 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
17
15
 
18
16
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
19
17
 
20
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
18
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
21
19
 
22
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
20
+ var _styles = require("./styles");
21
+
22
+ var _HeaderTop = require("../../molecules/HeaderTop");
23
+
24
+ var _ImagePreviewer = require("../../organisms/ImagePreviewer");
25
+
26
+ var _ImageDataTable = require("../../organisms/ImageDataTable");
27
+
28
+ var _FullProductNameHeader = require("../../organisms/FullProductNameHeader");
29
+
30
+ var _FullTabsMenu = require("../../organisms/FullTabsMenu");
31
+
32
+ var _InputGroup = require("../../organisms/InputGroup");
23
33
 
24
34
  var _react = require("react");
25
35
 
26
- var _axios = _interopRequireDefault(require("axios"));
36
+ var _GalleryElement = require("../../molecules/GalleryElement");
37
+
38
+ var _fileSaver = require("file-saver");
39
+
40
+ var _Commentary = require("../../atoms/Commentary");
41
+
42
+ var _data2 = require("../../../global-files/data");
43
+
44
+ var _GalleryHeader = require("../../molecules/GalleryHeader");
45
+
46
+ var _ProductImageModal = require("../../organisms/ProductImageModal");
27
47
 
28
48
  var _reactDropzone = require("react-dropzone");
29
49
 
30
- var _fileSaver = require("file-saver");
50
+ var _axios = _interopRequireDefault(require("axios"));
31
51
 
32
- var _providerProductEdition = require("./context/provider-product-edition.context");
52
+ var _uuid = require("uuid");
33
53
 
34
- var _utils = require("./utils");
54
+ var _awsSdk = _interopRequireDefault(require("aws-sdk"));
35
55
 
36
- var _data = require("../../../global-files/data");
56
+ var _attributesSent = _interopRequireDefault(require("../../../assets/images/modalsSVGs/attributesSent.svg"));
37
57
 
38
- var _customHooks = require("../../../global-files/customHooks");
58
+ var _descriptionSent = _interopRequireDefault(require("../../../assets/images/modalsSVGs/descriptionSent.svg"));
59
+
60
+ var _uploadingImages = _interopRequireDefault(require("../../../assets/images/modalsSVGs/uploadingImages.svg"));
61
+
62
+ var _index = require("../../molecules/TagAndInput/index");
39
63
 
40
64
  var _GeneralButton = require("../../atoms/GeneralButton");
41
65
 
42
66
  var _GenericModal = require("../../atoms/GenericModal");
43
67
 
68
+ var _ScreenHeader = require("../../atoms/ScreenHeader");
69
+
44
70
  var _Loading = require("../../atoms/Loading");
45
71
 
46
- var _ScreenHeader = require("../../atoms/ScreenHeader");
72
+ var _genericModalCheck = _interopRequireDefault(require("../../../assets/images/genericModal/genericModalCheck.svg"));
73
+
74
+ var _VersionSelector = require("../../organisms/VersionSelector");
75
+
76
+ var _customHooks = require("../../../global-files/customHooks");
77
+
78
+ var _utils = require("./utils");
79
+
80
+ var _Modal = require("../../organisms/Modal");
47
81
 
48
82
  var _ButtonV = require("../../atoms/ButtonV2");
49
83
 
50
- var _GalleryElement = require("../../molecules/GalleryElement");
84
+ var _generateThumnail = _interopRequireDefault(require("./generateThumnail"));
51
85
 
52
- var _GalleryHeader = require("../../molecules/GalleryHeader");
86
+ var _jsxRuntime = require("react/jsx-runtime");
53
87
 
54
- var _HeaderTop = require("../../molecules/HeaderTop");
88
+ var reducerImages = function reducerImages(state, action) {
89
+ var _action$init, _action$init$inputsBy;
55
90
 
56
- var _index = require("../../molecules/TagAndInput/index");
91
+ var values = state.values,
92
+ attrForImgs = state.attrForImgs,
93
+ inputsByRetailer = state.inputsByRetailer;
57
94
 
58
- var _FullProductNameHeader = require("../../organisms/FullProductNameHeader");
95
+ switch (action.action) {
96
+ case "init":
97
+ var newInputsByRetailer = {};
98
+ action === null || action === void 0 ? void 0 : (_action$init = action.init) === null || _action$init === void 0 ? void 0 : (_action$init$inputsBy = _action$init.inputsByRetailer) === null || _action$init$inputsBy === void 0 ? void 0 : _action$init$inputsBy.forEach(function (inputs) {
99
+ inputs === null || inputs === void 0 ? void 0 : inputs.forEach(function (input) {
100
+ if (!newInputsByRetailer["".concat(input.id_retailer)]) newInputsByRetailer["".concat(input.id_retailer)] = [];
101
+ newInputsByRetailer["".concat(input.id_retailer)].push(input);
102
+ });
103
+ });
104
+ inputsByRetailer = newInputsByRetailer;
105
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, action.init), {}, {
106
+ inputsByRetailer: inputsByRetailer,
107
+ valuesInitial: action.init.values,
108
+ inputsInitial: action.init.inputs
109
+ });
59
110
 
60
- var _FullTabsMenu = require("../../organisms/FullTabsMenu");
111
+ case "addImg":
112
+ values = [].concat((0, _toConsumableArray2.default)(values), [action.img]);
113
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
114
+ values: values
115
+ });
61
116
 
62
- var _ImageDataTable = require("../../organisms/ImageDataTable");
117
+ case "changeImageInfo":
118
+ values[action.index][action.attribute] = action.value;
119
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
120
+ values: values
121
+ });
63
122
 
64
- var _ImagePreviewer = require("../../organisms/ImagePreviewer");
123
+ case "changeShotType":
124
+ values[action.index][action.attribute] = action.value;
125
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
126
+ values: values
127
+ });
65
128
 
66
- var _InputGroup = require("../../organisms/InputGroup");
129
+ case "changeAttrValue":
130
+ var index = attrForImgs.general.findIndex(function (f) {
131
+ return f.id === action.id;
132
+ });
67
133
 
68
- var _ProductImageModal = require("../../organisms/ProductImageModal");
134
+ if (index !== -1) {
135
+ attrForImgs.general[index].value = action.value;
136
+ }
69
137
 
70
- var _VersionSelector = require("../../organisms/VersionSelector");
138
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
139
+ attrForImgs: attrForImgs,
140
+ values: values
141
+ });
71
142
 
72
- var _Modal = require("../../organisms/Modal");
143
+ case "deleteImage":
144
+ values = values.filter(function (value) {
145
+ return action.selectedImages.indexOf(value) === -1;
146
+ });
147
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
148
+ values: values
149
+ });
73
150
 
74
- var _genericModalCheck = _interopRequireDefault(require("../../../assets/images/genericModal/genericModalCheck.svg"));
151
+ case "orderImages":
152
+ {
153
+ var _inputsByRetailer = state.inputsByRetailer,
154
+ valuesInitial = state.valuesInitial,
155
+ inputsInitial = state.inputsInitial,
156
+ inputs = state.inputs;
75
157
 
76
- var _errorModal = _interopRequireDefault(require("../../../assets/images/genericModal/errorModal.svg"));
158
+ try {
159
+ var _inputsByRetailer$act;
77
160
 
78
- var _genericModalWarning = _interopRequireDefault(require("../../../assets/images/genericModal/genericModalWarning.svg"));
161
+ var orderedImages = [];
162
+ var imageIdArray = [];
79
163
 
80
- var _attributesSent = _interopRequireDefault(require("../../../assets/images/modalsSVGs/attributesSent.svg"));
164
+ if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) {
165
+ _inputsByRetailer[action.retailerId] = [];
166
+ }
81
167
 
82
- var _descriptionSent = _interopRequireDefault(require("../../../assets/images/modalsSVGs/descriptionSent.svg"));
168
+ action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
169
+ imageIdArray.push(input.id_image);
170
+ valuesInitial.forEach( /*#__PURE__*/function () {
171
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(value) {
172
+ return _regenerator.default.wrap(function _callee2$(_context2) {
173
+ while (1) {
174
+ switch (_context2.prev = _context2.next) {
175
+ case 0:
176
+ if (value.ext == "mp4") {
177
+ convertirVideoABase64("https://" + process.env.REACT_APP_IMAGES_BUCKET + ".s3.amazonaws.com/" + value.srcDB).then( /*#__PURE__*/function () {
178
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(base64) {
179
+ var videoSrc;
180
+ return _regenerator.default.wrap(function _callee$(_context) {
181
+ while (1) {
182
+ switch (_context.prev = _context.next) {
183
+ case 0:
184
+ videoSrc = "data:video/mp4;base64," + base64.split(",")[1]; // Añade el tipo MIME adecuado
185
+
186
+ _context.next = 3;
187
+ return (0, _generateThumnail.default)(videoSrc, 2);
188
+
189
+ case 3:
190
+ value.src = _context.sent;
191
+
192
+ case 4:
193
+ case "end":
194
+ return _context.stop();
195
+ }
196
+ }
197
+ }, _callee);
198
+ }));
199
+
200
+ return function (_x2) {
201
+ return _ref2.apply(this, arguments);
202
+ };
203
+ }()).catch(function (error) {
204
+ console.error("Error:", error);
205
+ });
206
+ }
207
+
208
+ if (value.image_id === input.id_image) orderedImages.push(value);
209
+
210
+ case 2:
211
+ case "end":
212
+ return _context2.stop();
213
+ }
214
+ }
215
+ }, _callee2);
216
+ }));
83
217
 
84
- var _uploadingImages = _interopRequireDefault(require("../../../assets/images/modalsSVGs/uploadingImages.svg"));
218
+ return function (_x) {
219
+ return _ref.apply(this, arguments);
220
+ };
221
+ }());
222
+ }));
223
+ inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
224
+ return imageIdArray.includes(input.id);
225
+ });
226
+ values = orderedImages.length > 0 ? orderedImages : [];
227
+ } catch (error) {
228
+ console.log(error);
229
+ }
85
230
 
86
- var _styles = require("./styles");
231
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
232
+ values: values,
233
+ inputs: inputs
234
+ });
235
+ }
87
236
 
88
- var _Commentary = require("../../atoms/Commentary");
237
+ default:
238
+ return state;
239
+ }
240
+ };
241
+
242
+ var S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
243
+ var REGION = "us-east-1";
89
244
 
90
- var _AiProductEdition = require("../../../contexts/AiProductEdition");
245
+ function convertirVideoABase64(url) {
246
+ return new Promise(function (resolve, reject) {
247
+ var xhr = new XMLHttpRequest();
248
+ xhr.open("GET", url, true);
249
+ xhr.responseType = "blob";
91
250
 
92
- var _ChangeStatusModal = _interopRequireDefault(require("../../organisms/ChangeStatusModal"));
251
+ xhr.onload = function () {
252
+ if (xhr.status === 200) {
253
+ var blob = xhr.response;
254
+ var reader = new FileReader();
93
255
 
94
- var _material = require("@mui/material");
256
+ reader.onloadend = function () {
257
+ resolve(reader.result);
258
+ };
95
259
 
96
- var _jsxRuntime = require("react/jsx-runtime");
260
+ reader.readAsDataURL(blob);
261
+ } else {
262
+ reject(new Error("Error al cargar el video"));
263
+ }
264
+ };
97
265
 
98
- var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
99
- var _location$state, _location$state2, _state$active_retaile4, _state$active_retaile5, _state$images_values$2, _state$images_values10, _state$images_values11, _state$product8, _state$active_retaile6, _state$active_retaile7, _state$active_retaile8, _state$active_retaile9, _state$product9, _state$product10, _state$product11, _state$datasheets_inp, _state$datasheets_inp2, _state$product12, _state$images_values12, _state$comment;
100
-
101
- var tabsSections = _ref.tabsSections,
102
- _ref$productSelected = _ref.productSelected,
103
- productSelected = _ref$productSelected === void 0 ? {} : _ref$productSelected,
104
- _ref$user = _ref.user,
105
- user = _ref$user === void 0 ? {} : _ref$user,
106
- token = _ref.token,
107
- location = _ref.location;
108
-
109
- var _useProviderProductEd = (0, _providerProductEdition.useProviderProductEdition)(),
110
- state = _useProviderProductEd.state,
111
- dispatch = _useProviderProductEd.dispatch,
112
- saveDatasheets = _useProviderProductEd.saveDatasheets,
113
- saveDescriptions = _useProviderProductEd.saveDescriptions,
114
- updateImages = _useProviderProductEd.updateImages,
115
- saveImageAttrs = _useProviderProductEd.saveImageAttrs,
116
- deleteImages = _useProviderProductEd.deleteImages,
117
- handleOnDownloadImages = _useProviderProductEd.handleOnDownloadImages,
118
- createComment = _useProviderProductEd.createComment;
266
+ xhr.onerror = function () {
267
+ reject(new Error("Error de red al cargar el video"));
268
+ };
119
269
 
120
- var isRetailer = user === null || user === void 0 ? void 0 : user.is_retailer;
270
+ xhr.send();
271
+ });
272
+ }
273
+
274
+ function obtenerDuracionVideoBase64(base64Data) {
275
+ return new Promise(function (resolve, reject) {
276
+ var video = document.createElement("video");
277
+ video.src = base64Data;
278
+ video.addEventListener("loadedmetadata", function () {
279
+ resolve(video.duration);
280
+ });
281
+ video.addEventListener("error", reject);
282
+ });
283
+ }
121
284
 
122
- var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
123
- _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
124
- showVersionSelector = _useCloseModal2[0],
125
- setShowVersionSelector = _useCloseModal2[1];
285
+ _awsSdk.default.config.update({
286
+ accessKeyId: process.env.REACT_APP_KUTS3,
287
+ secretAccessKey: process.env.REACT_APP_AKUTS3
288
+ });
289
+
290
+ var myBucket = new _awsSdk.default.S3({
291
+ params: {
292
+ Bucket: S3_BUCKET
293
+ },
294
+ region: REGION
295
+ });
296
+
297
+ var RetailerProductEdition = function RetailerProductEdition(_ref3) {
298
+ var _product$retailers, _location$state, _location$state2, _product$services2, _datasheets$, _datasheets$$data, _product$article22;
126
299
 
127
- var _useState = (0, _react.useState)(null),
300
+ var tabsSections = _ref3.tabsSections,
301
+ _ref3$productSelected = _ref3.productSelected,
302
+ productSelected = _ref3$productSelected === void 0 ? {} : _ref3$productSelected,
303
+ _ref3$user = _ref3.user,
304
+ user = _ref3$user === void 0 ? {} : _ref3$user,
305
+ token = _ref3.token,
306
+ location = _ref3.location;
307
+
308
+ var _useState = (0, _react.useState)("Descripción"),
128
309
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
129
- auditableVersion = _useState2[0],
130
- setAuditableVersion = _useState2[1];
310
+ activeTab = _useState2[0],
311
+ setActiveTab = _useState2[1];
131
312
 
132
- var _useState3 = (0, _react.useState)(0),
313
+ var _useState3 = (0, _react.useState)(),
133
314
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
134
- headerTop = _useState4[0],
135
- setHeaderTop = _useState4[1];
315
+ activeImage = _useState4[0],
316
+ setActiveImage = _useState4[1];
136
317
 
137
318
  var _useState5 = (0, _react.useState)(false),
138
319
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
139
- shotThd = _useState6[0],
140
- setShotThd = _useState6[1];
320
+ imageLayout = _useState6[0],
321
+ setImageLayout = _useState6[1];
141
322
 
142
- var _useState7 = (0, _react.useState)(),
323
+ var _useState7 = (0, _react.useState)(0),
143
324
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
144
- observation = _useState8[0],
145
- setObservation = _useState8[1];
325
+ headerTop = _useState8[0],
326
+ setHeaderTop = _useState8[1];
146
327
 
147
- var _useState9 = (0, _react.useState)(false),
328
+ var _useState9 = (0, _react.useState)([]),
148
329
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
149
- showRejectModal = _useState10[0],
150
- setShowRejectModal = _useState10[1];
330
+ descriptions = _useState10[0],
331
+ setDescriptions = _useState10[1];
151
332
 
152
- var _useState11 = (0, _react.useState)(false),
333
+ var _useState11 = (0, _react.useState)([]),
153
334
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
154
- isObservationVisible = _useState12[0],
155
- setObservationVisible = _useState12[1];
335
+ datasheets = _useState12[0],
336
+ setDatasheets = _useState12[1];
337
+
338
+ var _useReducer = (0, _react.useReducer)(reducerImages, {}),
339
+ _useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
340
+ images = _useReducer2[0],
341
+ setImages = _useReducer2[1];
156
342
 
157
343
  var _useState13 = (0, _react.useState)(false),
158
344
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
159
- imageLayout = _useState14[0],
160
- setImageLayout = _useState14[1];
345
+ showModal = _useState14[0],
346
+ setShowModal = _useState14[1];
161
347
 
162
348
  var _useState15 = (0, _react.useState)(false),
163
349
  _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
164
- crossComment = _useState16[0],
165
- setCrossComment = _useState16[1];
166
-
167
- var _useState17 = (0, _react.useState)([]),
168
- _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
169
- statusArray = _useState18[0],
170
- setStatusArray = _useState18[1];
171
-
172
- var _useState19 = (0, _react.useState)(false),
173
- _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
174
- rejectAll = _useState20[0],
175
- setRejectAll = _useState20[1];
176
-
177
- var _useState21 = (0, _react.useState)([]),
178
- _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
179
- auditServices = _useState22[0],
180
- setAuditServices = _useState22[1];
181
-
182
- var _useState23 = (0, _react.useState)([]),
183
- _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
184
- auditDatasheets = _useState24[0],
185
- setAuditDatasheets = _useState24[1];
186
-
187
- var _useState25 = (0, _react.useState)([]),
188
- _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
189
- auditDescriptions = _useState26[0],
190
- setAuditDescriptions = _useState26[1];
191
-
192
- var _useState27 = (0, _react.useState)(false),
193
- _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
194
- showModal = _useState28[0],
195
- setShowModal = _useState28[1];
196
-
197
- var _useState29 = (0, _react.useState)(false),
198
- _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
199
- compare = _useState30[0],
200
- setCompare = _useState30[1];
350
+ showRejectModal = _useState16[0],
351
+ setShowRejectModal = _useState16[1];
201
352
 
202
353
  var _useDropzone = (0, _reactDropzone.useDropzone)({
203
- accept: "image/*",
354
+ accept: "image/*, video/mp4",
204
355
  noKeyboard: true,
205
356
  multiple: true,
206
357
  noClick: true,
207
358
  onDrop: function onDrop(acceptedFiles) {
359
+ var newImages = [];
208
360
  acceptedFiles.map(function (file) {
209
361
  var reader = new FileReader();
210
362
  reader.fileName = file.name;
211
363
 
212
364
  reader.onload = /*#__PURE__*/function () {
213
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
214
- var fileName, fileExtension, fileDataURL, img;
215
- return _regenerator.default.wrap(function _callee$(_context) {
365
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(e) {
366
+ var ext, img;
367
+ return _regenerator.default.wrap(function _callee4$(_context4) {
216
368
  while (1) {
217
- switch (_context.prev = _context.next) {
369
+ switch (_context4.prev = _context4.next) {
218
370
  case 0:
219
- fileName = e.target.fileName;
220
- fileExtension = fileName.split(".").pop();
221
- fileDataURL = e.target.result;
371
+ ext = e.srcElement.fileName.split(".");
222
372
  img = new Image();
223
- img.src = fileDataURL;
224
-
225
- img.onload = function () {
226
- var width = img.width;
227
- var height = img.height;
228
- var newImg = {
229
- src: fileDataURL,
230
- name: fileName,
231
- ext: fileExtension,
232
- width: width,
233
- height: height,
234
- isApproved: true // VALIDAR QUE SOLO SEA PARA RADIOSHACK
235
-
236
- };
237
- dispatch({
238
- type: "ADD_IMAGE_VALUE",
239
- payload: newImg
373
+
374
+ if (ext[ext.length - 1] == "mp4") {
375
+ obtenerDuracionVideoBase64(e.target.result).then( /*#__PURE__*/function () {
376
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(duracion) {
377
+ return _regenerator.default.wrap(function _callee3$(_context3) {
378
+ while (1) {
379
+ switch (_context3.prev = _context3.next) {
380
+ case 0:
381
+ if (!(duracion > 15 && duracion < 600)) {
382
+ _context3.next = 7;
383
+ break;
384
+ }
385
+
386
+ _context3.next = 3;
387
+ return (0, _generateThumnail.default)(e.target.result, 2);
388
+
389
+ case 3:
390
+ img.src = _context3.sent;
391
+ setTimeout(function () {
392
+ var width = img.width;
393
+ var height = img.height;
394
+ var newImg = {
395
+ action: "addImg",
396
+ img: {
397
+ src: img.src,
398
+ //e.target.result,
399
+ name: e.target.fileName,
400
+ ext: ext[ext.length - 1],
401
+ width: width,
402
+ height: height,
403
+ video_src: ext[ext.length - 1] == "mp4" ? e.target.result : ""
404
+ }
405
+ };
406
+ setImages(newImg);
407
+ }, 500);
408
+ _context3.next = 8;
409
+ break;
410
+
411
+ case 7:
412
+ setModalAlert({
413
+ show: true,
414
+ title: "Hubo un error al subir el video",
415
+ message: "Los videos deben durar entre 15 segundos y 10 minutos"
416
+ });
417
+
418
+ case 8:
419
+ case "end":
420
+ return _context3.stop();
421
+ }
422
+ }
423
+ }, _callee3);
424
+ }));
425
+
426
+ return function (_x4) {
427
+ return _ref5.apply(this, arguments);
428
+ };
429
+ }()).catch(function (error) {
430
+ console.error("Error al obtener la duración del video:", error);
240
431
  });
241
- };
432
+ } else {
433
+ img.src = e.target.result;
434
+ setTimeout(function () {
435
+ var width = img.width;
436
+ var height = img.height;
437
+ var newImg = {
438
+ action: "addImg",
439
+ img: {
440
+ src: img.src,
441
+ //e.target.result,
442
+ name: e.target.fileName,
443
+ ext: ext[ext.length - 1],
444
+ width: width,
445
+ height: height,
446
+ video_src: ext[ext.length - 1] == "mp4" ? e.target.result : ""
447
+ }
448
+ };
449
+ setImages(newImg);
450
+ }, 500);
451
+ }
242
452
 
243
- case 6:
453
+ case 3:
244
454
  case "end":
245
- return _context.stop();
455
+ return _context4.stop();
246
456
  }
247
457
  }
248
- }, _callee);
458
+ }, _callee4);
249
459
  }));
250
460
 
251
- return function (_x) {
252
- return _ref2.apply(this, arguments);
461
+ return function (_x3) {
462
+ return _ref4.apply(this, arguments);
253
463
  };
254
464
  }();
255
465
 
@@ -263,200 +473,315 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
263
473
  }
264
474
  }),
265
475
  getRootProps = _useDropzone.getRootProps,
266
- getInputProps = _useDropzone.getInputProps,
267
- isDragActive = _useDropzone.isDragActive,
268
- open = _useDropzone.open;
476
+ getInputProps = _useDropzone.getInputProps;
269
477
 
270
- var _useState31 = (0, _react.useState)(false),
271
- _useState32 = (0, _slicedToArray2.default)(_useState31, 2),
272
- openChangeStatusModal = _useState32[0],
273
- setOpenChangeStatusModal = _useState32[1];
478
+ var _useState17 = (0, _react.useState)([]),
479
+ _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
480
+ updatedDatasheets = _useState18[0],
481
+ setUpdatedDatasheets = _useState18[1];
274
482
 
275
- var thumbs = function thumbs() {
276
- var _state$images_values, _state$images_values$, _state$images_values4, _state$images_values5, _state$images_values6, _state$images_values7, _state$images_values8, _state$images_values9;
483
+ var _useState19 = (0, _react.useState)([]),
484
+ _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
485
+ updatedDescriptions = _useState20[0],
486
+ setUpdatedDescriptions = _useState20[1];
277
487
 
278
- var imageInputs = (_state$images_values = state.images_values) === null || _state$images_values === void 0 ? void 0 : (_state$images_values$ = _state$images_values.inputs) === null || _state$images_values$ === void 0 ? void 0 : _state$images_values$.map(function (e) {
279
- var _state$images_values2, _state$images_values3;
488
+ var _useState21 = (0, _react.useState)(false),
489
+ _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
490
+ imagesUploaded = _useState22[0],
491
+ setImagesUploaded = _useState22[1];
280
492
 
281
- return {
282
- value: e === null || e === void 0 ? void 0 : e.id,
283
- name: e === null || e === void 0 ? void 0 : e.name,
284
- required: e === null || e === void 0 ? void 0 : e.required,
285
- active: (_state$images_values2 = state.images_values) === null || _state$images_values2 === void 0 ? void 0 : (_state$images_values3 = _state$images_values2.values) === null || _state$images_values3 === void 0 ? void 0 : _state$images_values3.some(function (value) {
286
- return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
287
- })
288
- };
289
- });
290
- var imageType = (_state$images_values4 = state.images_values) === null || _state$images_values4 === void 0 ? void 0 : (_state$images_values5 = _state$images_values4.imageType) === null || _state$images_values5 === void 0 ? void 0 : _state$images_values5.map(function (e) {
291
- return {
292
- value: e === null || e === void 0 ? void 0 : e.id,
293
- name: e === null || e === void 0 ? void 0 : e.name
294
- };
295
- });
296
- var imagePackagingType = (_state$images_values6 = state.images_values) === null || _state$images_values6 === void 0 ? void 0 : (_state$images_values7 = _state$images_values6.imagePackagingType) === null || _state$images_values7 === void 0 ? void 0 : _state$images_values7.map(function (e) {
297
- return {
298
- value: e === null || e === void 0 ? void 0 : e.id,
299
- name: e === null || e === void 0 ? void 0 : e.name
300
- };
301
- });
302
- return (_state$images_values8 = state.images_values) === null || _state$images_values8 === void 0 ? void 0 : (_state$images_values9 = _state$images_values8.values) === null || _state$images_values9 === void 0 ? void 0 : _state$images_values9.map(function (image, index) {
303
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryElement.GalleryElement, {
304
- id: "gallery-element-" + index,
305
- index: index + "-" + image.name,
306
- image: image,
307
- number: index,
308
- gridLayout: imageLayout,
309
- imageType: imageType,
310
- imagePackagingType: imagePackagingType,
311
- imageInputs: imageInputs,
312
- selectedImages: state.selected_images,
313
- setCheckAll: handleOnSetCheckAll,
314
- changeImage: function changeImage(item) {
315
- dispatch({
316
- type: "UPDATE_IMAGE_VALUE",
317
- payload: item
318
- });
319
- },
320
- setSelectedImages: function setSelectedImages(item) {
321
- return dispatch({
322
- type: "SET_SELECTED_IMAGE",
323
- payload: item
324
- });
325
- },
326
- updateApprovedInputsImages: function updateApprovedInputsImages(item) {
327
- return console.log("updateApprovedInputsImages", item);
328
- }
329
- }, index);
330
- });
331
- };
493
+ var _useState23 = (0, _react.useState)(),
494
+ _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
495
+ dataImages = _useState24[0],
496
+ setDataImages = _useState24[1];
332
497
 
333
- var initializeProduct = /*#__PURE__*/function () {
334
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
335
- var product, productNormalized, users, id_article, response, parseData;
336
- return _regenerator.default.wrap(function _callee2$(_context2) {
337
- while (1) {
338
- switch (_context2.prev = _context2.next) {
339
- case 0:
340
- _context2.prev = 0;
341
- product = productSelected ? productSelected : JSON.parse(sessionStorage.getItem("productSelected"));
342
- productNormalized = (0, _utils.normalizeProduct)(product);
343
- console.log({
344
- productNormalized: productNormalized
345
- });
346
- dispatch({
347
- type: "SET_PRODUCT",
348
- payload: productNormalized
349
- });
350
- dispatch({
351
- type: "SET_ACTIVE_RETAILER",
352
- payload: productNormalized.categoryRetailerInOrder[0]
353
- });
354
- setShotThd([58, 59, 60, 61].includes(productNormalized.categoryRetailerInOrder[0].id_retailer)); // Configurar statusArray según el rol del usuario
498
+ var _useState25 = (0, _react.useState)(new Array(product === null || product === void 0 ? void 0 : (_product$retailers = product.retailers) === null || _product$retailers === void 0 ? void 0 : _product$retailers.length).fill({
499
+ percentage: 0
500
+ })),
501
+ _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
502
+ percentages = _useState26[0],
503
+ setPercentages = _useState26[1]; // const [percentages, setPercentages] = useState([{ retailers: {} }]);
355
504
 
356
- setStatusArray((0, _utils.getStatusArrayByRole)(user.id_role)); // Cargar usuarios y asignaciones
357
505
 
358
- _context2.next = 10;
359
- return (0, _data.fetchUsers)(token);
506
+ var _useState27 = (0, _react.useState)(0),
507
+ _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
508
+ activePercentage = _useState28[0],
509
+ setActivePercentage = _useState28[1];
360
510
 
361
- case 10:
362
- users = _context2.sent;
511
+ var _useState29 = (0, _react.useState)({}),
512
+ _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
513
+ activeRetailer = _useState30[0],
514
+ setActiveRetailer = _useState30[1];
363
515
 
364
- if (users.length > 0) {
365
- dispatch({
366
- type: "SET_COLLABORATOR_ASSIGNATIONS",
367
- payload: (0, _utils.buildCollaboratorAssignations)(productNormalized, users)
368
- });
369
- }
516
+ var _useState31 = (0, _react.useState)([]),
517
+ _useState32 = (0, _slicedToArray2.default)(_useState31, 2),
518
+ services = _useState32[0],
519
+ setServices = _useState32[1];
520
+
521
+ var _useState33 = (0, _react.useState)([]),
522
+ _useState34 = (0, _slicedToArray2.default)(_useState33, 2),
523
+ servicesData = _useState34[0],
524
+ setServicesData = _useState34[1];
525
+
526
+ var _useState35 = (0, _react.useState)(""),
527
+ _useState36 = (0, _slicedToArray2.default)(_useState35, 2),
528
+ message = _useState36[0],
529
+ setMessage = _useState36[1];
530
+
531
+ var _useState37 = (0, _react.useState)(JSON.parse(sessionStorage.getItem("productSelected")) ? JSON.parse(sessionStorage.getItem("productSelected")) : productSelected),
532
+ _useState38 = (0, _slicedToArray2.default)(_useState37, 2),
533
+ product = _useState38[0],
534
+ setProduct = _useState38[1];
535
+
536
+ var _useState39 = (0, _react.useState)(null),
537
+ _useState40 = (0, _slicedToArray2.default)(_useState39, 2),
538
+ icon = _useState40[0],
539
+ setIcon = _useState40[1];
540
+
541
+ var _useState41 = (0, _react.useState)(product === null || product === void 0 ? void 0 : product.version),
542
+ _useState42 = (0, _slicedToArray2.default)(_useState41, 2),
543
+ version = _useState42[0],
544
+ setVersion = _useState42[1];
545
+
546
+ var _useState43 = (0, _react.useState)({}),
547
+ _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
548
+ comments = _useState44[0],
549
+ setComments = _useState44[1];
550
+
551
+ var _useState45 = (0, _react.useState)(""),
552
+ _useState46 = (0, _slicedToArray2.default)(_useState45, 2),
553
+ comment = _useState46[0],
554
+ setComment = _useState46[1];
555
+
556
+ var _useState47 = (0, _react.useState)({
557
+ "Ficha técnica": 0,
558
+ Descripción: 0,
559
+ Imágenes: 0
560
+ }),
561
+ _useState48 = (0, _slicedToArray2.default)(_useState47, 2),
562
+ requiredNull = _useState48[0],
563
+ setRequiredNull = _useState48[1];
564
+
565
+ var _useState49 = (0, _react.useState)(false),
566
+ _useState50 = (0, _slicedToArray2.default)(_useState49, 2),
567
+ crossComment = _useState50[0],
568
+ setCrossComment = _useState50[1];
569
+
570
+ var _useState51 = (0, _react.useState)([]),
571
+ _useState52 = (0, _slicedToArray2.default)(_useState51, 2),
572
+ userGroups = _useState52[0],
573
+ setUserGroups = _useState52[1];
574
+
575
+ var _useState53 = (0, _react.useState)({}),
576
+ _useState54 = (0, _slicedToArray2.default)(_useState53, 2),
577
+ assig = _useState54[0],
578
+ setAssig = _useState54[1];
579
+
580
+ var _useState55 = (0, _react.useState)([]),
581
+ _useState56 = (0, _slicedToArray2.default)(_useState55, 2),
582
+ selectedImages = _useState56[0],
583
+ setSelectedImages = _useState56[1];
584
+
585
+ var _useState57 = (0, _react.useState)([]),
586
+ _useState58 = (0, _slicedToArray2.default)(_useState57, 2),
587
+ componentsArray = _useState58[0],
588
+ setComponentsArray = _useState58[1];
589
+
590
+ var _useState59 = (0, _react.useState)(false),
591
+ _useState60 = (0, _slicedToArray2.default)(_useState59, 2),
592
+ checkAll = _useState60[0],
593
+ setCheckAll = _useState60[1];
370
594
 
371
- id_article = productNormalized.id_article;
595
+ var isRetailer = user === null || user === void 0 ? void 0 : user.is_retailer;
372
596
 
373
- if (!id_article) {
374
- _context2.next = 16;
375
- break;
376
- }
597
+ var _useState61 = (0, _react.useState)(true),
598
+ _useState62 = (0, _slicedToArray2.default)(_useState61, 2),
599
+ loading = _useState62[0],
600
+ setLoading = _useState62[1];
377
601
 
378
- _context2.next = 16;
379
- return (0, _utils.getAuditVersion)(id_article, setAuditableVersion, token);
602
+ var _useState63 = (0, _react.useState)("-"),
603
+ _useState64 = (0, _slicedToArray2.default)(_useState63, 2),
604
+ retailerStatus = _useState64[0],
605
+ setRetailerStatus = _useState64[1];
380
606
 
381
- case 16:
382
- if (!(id_article && productNormalized.id_order)) {
383
- _context2.next = 22;
384
- break;
385
- }
607
+ var _useState65 = (0, _react.useState)([]),
608
+ _useState66 = (0, _slicedToArray2.default)(_useState65, 2),
609
+ statusArray = _useState66[0],
610
+ setStatusArray = _useState66[1];
386
611
 
387
- _context2.next = 19;
388
- return _axios.default.get(process.env.REACT_APP_READ_OBSERVATION, {
389
- params: {
390
- articleId: id_article,
391
- orderId: productNormalized.id_order
392
- },
393
- headers: {
394
- Authorization: sessionStorage.getItem("jwt")
395
- }
396
- });
612
+ var _useState67 = (0, _react.useState)(null),
613
+ _useState68 = (0, _slicedToArray2.default)(_useState67, 2),
614
+ socketType = _useState68[0],
615
+ setSocketType = _useState68[1];
397
616
 
398
- case 19:
399
- response = _context2.sent;
400
- parseData = JSON.parse(response.data.body).data[0];
401
- setObservation(parseData.observations);
617
+ var _useState69 = (0, _react.useState)(loading),
618
+ _useState70 = (0, _slicedToArray2.default)(_useState69, 2),
619
+ saving = _useState70[0],
620
+ setSaving = _useState70[1];
402
621
 
403
- case 22:
404
- _context2.next = 27;
405
- break;
622
+ var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
623
+ _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
624
+ showVersionSelector = _useCloseModal2[0],
625
+ setShowVersionSelector = _useCloseModal2[1];
406
626
 
407
- case 24:
408
- _context2.prev = 24;
409
- _context2.t0 = _context2["catch"](0);
410
- console.log("Error setting product data: ", _context2.t0);
627
+ var shotThd = [58, 59, 60, 61].includes(activeRetailer.id);
628
+
629
+ var _useState71 = (0, _react.useState)(null),
630
+ _useState72 = (0, _slicedToArray2.default)(_useState71, 2),
631
+ auditableVersion = _useState72[0],
632
+ setAuditableVersion = _useState72[1];
633
+
634
+ var _useState73 = (0, _react.useState)([]),
635
+ _useState74 = (0, _slicedToArray2.default)(_useState73, 2),
636
+ auditServices = _useState74[0],
637
+ setAuditServices = _useState74[1];
638
+
639
+ var _useState75 = (0, _react.useState)([]),
640
+ _useState76 = (0, _slicedToArray2.default)(_useState75, 2),
641
+ auditDatasheets = _useState76[0],
642
+ setAuditDatasheets = _useState76[1];
643
+
644
+ var _useState77 = (0, _react.useState)([]),
645
+ _useState78 = (0, _slicedToArray2.default)(_useState77, 2),
646
+ auditDescriptions = _useState78[0],
647
+ setAuditDescriptions = _useState78[1];
648
+
649
+ var _useState79 = (0, _react.useState)([]),
650
+ _useState80 = (0, _slicedToArray2.default)(_useState79, 2),
651
+ auditImages = _useState80[0],
652
+ setAuditImages = _useState80[1];
653
+
654
+ var _useState81 = (0, _react.useState)(false),
655
+ _useState82 = (0, _slicedToArray2.default)(_useState81, 2),
656
+ compare = _useState82[0],
657
+ setCompare = _useState82[1];
658
+
659
+ var _useState83 = (0, _react.useState)(),
660
+ _useState84 = (0, _slicedToArray2.default)(_useState83, 2),
661
+ observation = _useState84[0],
662
+ setObservation = _useState84[1];
663
+
664
+ var _useState85 = (0, _react.useState)(false),
665
+ _useState86 = (0, _slicedToArray2.default)(_useState85, 2),
666
+ valRejAll = _useState86[0],
667
+ setValRejAll = _useState86[1];
668
+
669
+ var _useState87 = (0, _react.useState)({
670
+ show: false,
671
+ title: "",
672
+ message: "",
673
+ errorInputMessage: false
674
+ }),
675
+ _useState88 = (0, _slicedToArray2.default)(_useState87, 2),
676
+ modalAlert = _useState88[0],
677
+ setModalAlert = _useState88[1];
678
+
679
+ var _useState89 = (0, _react.useState)([]),
680
+ _useState90 = (0, _slicedToArray2.default)(_useState89, 2),
681
+ desc = _useState90[0],
682
+ setDesc = _useState90[1];
683
+
684
+ var _useState91 = (0, _react.useState)([]),
685
+ _useState92 = (0, _slicedToArray2.default)(_useState91, 2),
686
+ fich = _useState92[0],
687
+ setFich = _useState92[1];
688
+
689
+ var _useState93 = (0, _react.useState)([]),
690
+ _useState94 = (0, _slicedToArray2.default)(_useState93, 2),
691
+ imag = _useState94[0],
692
+ setImag = _useState94[1];
693
+
694
+ var _useState95 = (0, _react.useState)(false),
695
+ _useState96 = (0, _slicedToArray2.default)(_useState95, 2),
696
+ isObservationVisible = _useState96[0],
697
+ setObservationVisible = _useState96[1];
698
+
699
+ var toggleObservation = function toggleObservation() {
700
+ setObservationVisible(!isObservationVisible);
701
+ }; // const handleClickOutside = (event) => {
702
+ // if (
703
+ // isObservationVisible &&
704
+ // !event.target.closest(".Observation") &&
705
+ // !event.target.closest(".Container")
706
+ // ) {
707
+ // hideObservation();
708
+ // }
709
+ // };
710
+ // useEffect(() => {
711
+ // document.addEventListener("click", handleClickOutside);
712
+ // return () => {
713
+ // document.removeEventListener("click", handleClickOutside);
714
+ // };
715
+ // }, [isObservationVisible]);
716
+
717
+
718
+ var hideObservation = function hideObservation() {
719
+ setObservationVisible(false);
720
+ };
411
721
 
412
- case 27:
413
- case "end":
414
- return _context2.stop();
415
- }
416
- }
417
- }, _callee2, null, [[0, 24]]);
418
- }));
722
+ var handleCommentSubmit = function handleCommentSubmit(e) {
723
+ e.preventDefault();
724
+ var commentText = document.querySelector("#commentary-box .ql-container .ql-editor > p").innerHTML;
725
+ createComment(e, commentText, activeTab);
726
+ };
419
727
 
420
- return function initializeProduct() {
421
- return _ref3.apply(this, arguments);
422
- };
423
- }(); // Setter del producto y carga inicial (optimizado para evitar cascada)
728
+ (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
729
+ var _ref7, id_article;
424
730
 
731
+ return _regenerator.default.wrap(function _callee5$(_context5) {
732
+ while (1) {
733
+ switch (_context5.prev = _context5.next) {
734
+ case 0:
735
+ _ref7 = (product === null || product === void 0 ? void 0 : product.article) || {}, id_article = _ref7.id_article;
425
736
 
426
- (0, _react.useEffect)(function () {
427
- initializeProduct();
428
- }, []);
737
+ if (!id_article) {
738
+ _context5.next = 4;
739
+ break;
740
+ }
741
+
742
+ _context5.next = 4;
743
+ return (0, _utils.getAuditVersion)(id_article, setAuditableVersion, token);
744
+
745
+ case 4:
746
+ case "end":
747
+ return _context5.stop();
748
+ }
749
+ }
750
+ }, _callee5);
751
+ })), []);
429
752
 
430
753
  var loadAuditableData = /*#__PURE__*/function () {
431
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
432
- var _state$product, _state$product2, _state$product3;
754
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
755
+ var _product$article, _product$article2, _product$article3, _auditServices;
433
756
 
434
- var auditServices;
435
- return _regenerator.default.wrap(function _callee3$(_context3) {
757
+ return _regenerator.default.wrap(function _callee6$(_context6) {
436
758
  while (1) {
437
- switch (_context3.prev = _context3.next) {
759
+ switch (_context6.prev = _context6.next) {
438
760
  case 0:
439
- _context3.next = 2;
440
- return (0, _data.getRetailerServices)((_state$product = state.product) === null || _state$product === void 0 ? void 0 : _state$product.id_article, (_state$product2 = state.product) === null || _state$product2 === void 0 ? void 0 : _state$product2.categoryName, parseInt((_state$product3 = state.product) === null || _state$product3 === void 0 ? void 0 : _state$product3.id_category), auditableVersion.version, token);
761
+ if (!auditableVersion) {
762
+ _context6.next = 7;
763
+ break;
764
+ }
441
765
 
442
- case 2:
443
- auditServices = _context3.sent;
444
- (0, _utils.getInputsData)(auditServices, {
445
- id: state.active_retailer.id_retailer
446
- }, setAuditDatasheets, setAuditDescriptions);
447
- setAuditServices(auditServices);
448
- setAuditImages(auditServices[2]);
766
+ _context6.next = 3;
767
+ return (0, _data2.getRetailerServices)(product === null || product === void 0 ? void 0 : (_product$article = product.article) === null || _product$article === void 0 ? void 0 : _product$article.id_article, product === null || product === void 0 ? void 0 : (_product$article2 = product.article) === null || _product$article2 === void 0 ? void 0 : _product$article2.category, parseInt(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_category), auditableVersion.version, token);
449
768
 
450
- case 6:
769
+ case 3:
770
+ _auditServices = _context6.sent;
771
+ (0, _utils.getInputsData)(_auditServices, activeRetailer, setAuditDatasheets, setAuditDescriptions);
772
+ setAuditServices(_auditServices);
773
+ setAuditImages(_auditServices[2]);
774
+
775
+ case 7:
451
776
  case "end":
452
- return _context3.stop();
777
+ return _context6.stop();
453
778
  }
454
779
  }
455
- }, _callee3);
780
+ }, _callee6);
456
781
  }));
457
782
 
458
783
  return function loadAuditableData() {
459
- return _ref4.apply(this, arguments);
784
+ return _ref8.apply(this, arguments);
460
785
  };
461
786
  }();
462
787
 
@@ -465,926 +790,1225 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
465
790
  loadAuditableData();
466
791
  }
467
792
  }, [auditableVersion]);
793
+ (0, _react.useEffect)(function () {
794
+ checkAll && setSelectedImages(images.values);
795
+ }, [checkAll]);
468
796
 
469
797
  var loadData = /*#__PURE__*/function () {
470
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
471
- var enableLoading,
472
- versionSelected,
473
- _JSON$parse$0$relatio,
474
- _JSON$parse,
475
- _JSON$parse$,
476
- _percentagesRes$,
477
- _state$product4,
478
- id_article,
479
- version,
480
- id_order,
481
- _state$active_retaile,
482
- category,
483
- id_category,
484
- id_retailer,
485
- data,
486
- headers,
487
- _yield$Promise$all,
488
- _yield$Promise$all2,
489
- services,
490
- percentagesRes,
491
- servicesDataRes,
492
- commentsResponse,
493
- percentages,
494
- commentsMap,
495
- orderMap,
496
- orderedValues,
497
- retailerDatasheets,
498
- datasheetsActiveRetailer,
499
- descriptionsActiveRetailer,
500
- filteredValues,
501
- _args4 = arguments;
502
-
503
- return _regenerator.default.wrap(function _callee4$(_context4) {
798
+ var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
799
+ var _ref10, _product$statusByReta, _product$statusByReta2, _product$statusByReta3, _ref11, _product$article$cate, _product$article5, _product$article5$cat, _product$article6, _product$article6$cat, _categoryRetailer$, _categoryRetailer$2, _product$article7, _product$article8, _activeRetailerId, _product$article9, _services$, _services$$values, _product$article10, ids, uniqueIds, activeRetailerId, _product$article4, _product$article4$cat, firstValid, categoryRetailer, categoryName, categoryId, category_name, category_id, retailer_id, _services, generalServices, data, headers;
800
+
801
+ return _regenerator.default.wrap(function _callee7$(_context7) {
504
802
  while (1) {
505
- switch (_context4.prev = _context4.next) {
803
+ switch (_context7.prev = _context7.next) {
506
804
  case 0:
507
- enableLoading = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : true;
508
- versionSelected = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : null;
509
- _context4.prev = 2;
510
- if (enableLoading) dispatch({
511
- type: "SET_LOADING",
512
- payload: true
513
- });
514
- _state$product4 = state.product, id_article = _state$product4.id_article, version = _state$product4.version, id_order = _state$product4.id_order;
515
- _state$active_retaile = state.active_retailer, category = _state$active_retaile.category, id_category = _state$active_retaile.id_category, id_retailer = _state$active_retaile.id_retailer; // Payloads y headers
805
+ _context7.prev = 0;
806
+ setLoading(true);
807
+ ids = (_ref10 = (_product$statusByReta = product === null || product === void 0 ? void 0 : (_product$statusByReta2 = product.statusByRetailer) === null || _product$statusByReta2 === void 0 ? void 0 : _product$statusByReta2.map(function (item) {
808
+ return item.retailer_id;
809
+ })) !== null && _product$statusByReta !== void 0 ? _product$statusByReta : product === null || product === void 0 ? void 0 : (_product$statusByReta3 = product.statusByRetailer) === null || _product$statusByReta3 === void 0 ? void 0 : _product$statusByReta3.map(function (item) {
810
+ return item.id_retailer;
811
+ })) !== null && _ref10 !== void 0 ? _ref10 : [];
812
+ uniqueIds = (0, _toConsumableArray2.default)(new Set(ids));
813
+ activeRetailerId = activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id;
814
+
815
+ if (!activeRetailerId) {
816
+ firstValid = product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : (_product$article4$cat = _product$article4.categoryRetailer) === null || _product$article4$cat === void 0 ? void 0 : _product$article4$cat.find(function (item) {
817
+ return uniqueIds.includes(item.id_retailer || item.retailer_id);
818
+ });
819
+
820
+ if (firstValid) {
821
+ activeRetailerId = firstValid.id_retailer || firstValid.retailer_id;
822
+ }
823
+ }
824
+
825
+ categoryRetailer = (_ref11 = (_product$article$cate = product === null || product === void 0 ? void 0 : (_product$article5 = product.article) === null || _product$article5 === void 0 ? void 0 : (_product$article5$cat = _product$article5.categoryRetailer) === null || _product$article5$cat === void 0 ? void 0 : _product$article5$cat.filter(function (item) {
826
+ return uniqueIds.includes(item.id_retailer) && item.id_retailer === activeRetailerId;
827
+ })) !== null && _product$article$cate !== void 0 ? _product$article$cate : product === null || product === void 0 ? void 0 : (_product$article6 = product.article) === null || _product$article6 === void 0 ? void 0 : (_product$article6$cat = _product$article6.categoryRetailer) === null || _product$article6$cat === void 0 ? void 0 : _product$article6$cat.filter(function (item) {
828
+ return uniqueIds.includes(item.retailer_id) && item.retailer_id === activeRetailerId;
829
+ })) !== null && _ref11 !== void 0 ? _ref11 : [];
830
+ categoryName = (_categoryRetailer$ = categoryRetailer[0]) === null || _categoryRetailer$ === void 0 ? void 0 : _categoryRetailer$.category_name;
831
+ categoryId = (_categoryRetailer$2 = categoryRetailer[0]) === null || _categoryRetailer$2 === void 0 ? void 0 : _categoryRetailer$2.id_category;
832
+ category_name = categoryName !== null && categoryName !== void 0 ? categoryName : (product === null || product === void 0 ? void 0 : (_product$article7 = product.article) === null || _product$article7 === void 0 ? void 0 : _product$article7.company_name) || (product === null || product === void 0 ? void 0 : product.categoryName);
833
+ category_id = categoryId !== null && categoryId !== void 0 ? categoryId : parseInt((product === null || product === void 0 ? void 0 : (_product$article8 = product.article) === null || _product$article8 === void 0 ? void 0 : _product$article8.id_category) || (product === null || product === void 0 ? void 0 : product.id_category));
834
+ retailer_id = (_activeRetailerId = activeRetailerId) !== null && _activeRetailerId !== void 0 ? _activeRetailerId : categoryRetailer === null || categoryRetailer === void 0 ? void 0 : categoryRetailer.id_retailer;
835
+ _context7.next = 14;
836
+ return (0, _data2.getRetailerServices)((product === null || product === void 0 ? void 0 : product.id_article) || (product === null || product === void 0 ? void 0 : (_product$article9 = product.article) === null || _product$article9 === void 0 ? void 0 : _product$article9.id_article), category_name, category_id, version, token, retailer_id);
516
837
 
838
+ case 14:
839
+ _services = _context7.sent;
840
+
841
+ if (auditableVersion && retailer_id) {
842
+ loadAuditableData();
843
+ }
844
+
845
+ setServices(_services);
846
+ _context7.next = 19;
847
+ return getServices();
848
+
849
+ case 19:
850
+ generalServices = _context7.sent;
851
+ setImages({
852
+ action: "init",
853
+ init: _services[2]
854
+ });
855
+ if (((_services$ = _services[2]) === null || _services$ === void 0 ? void 0 : (_services$$values = _services$.values) === null || _services$$values === void 0 ? void 0 : _services$$values.length) > 0) setActiveImage(0);
517
856
  data = [{
518
- id_article: id_article,
519
- version: versionSelected ? versionSelected : version,
857
+ id_article: product === null || product === void 0 ? void 0 : (_product$article10 = product.article) === null || _product$article10 === void 0 ? void 0 : _product$article10.id_article,
520
858
  relations: [{
521
- id_retailer: id_retailer,
522
- id_category: id_category
523
- }]
859
+ id_retailer: retailer_id,
860
+ id_category: category_id
861
+ }],
862
+ version: product.version
524
863
  }];
525
864
  headers = {
526
865
  Authorization: token
527
866
  };
528
- _context4.next = 10;
529
- return Promise.all([(0, _data.getRetailerServices)(id_article, category, id_category, versionSelected !== null && versionSelected !== void 0 ? versionSelected : version, token, id_retailer), (0, _data.getPercentage)({
867
+ (0, _data2.getPercentage)({
530
868
  data: data,
531
869
  headers: headers
532
- }), (0, _data.getServicesData)({
533
- articleId: id_article,
534
- orderId: id_order,
535
- end: true,
536
- token: token
537
- }), // Obtener comentarios en paralelo
538
- Promise.all([_axios.default.get(process.env.REACT_APP_COMMENTS_ENDPOINT, {
539
- params: {
540
- articleId: id_article,
541
- concept: "description",
542
- orderIdColab: id_order,
543
- version: versionSelected !== null && versionSelected !== void 0 ? versionSelected : version
544
- }
545
- }), _axios.default.get(process.env.REACT_APP_COMMENTS_ENDPOINT, {
546
- params: {
547
- articleId: id_article,
548
- concept: "datasheet",
549
- orderIdColab: id_order,
550
- version: versionSelected !== null && versionSelected !== void 0 ? versionSelected : version
551
- }
552
- }), _axios.default.get(process.env.REACT_APP_COMMENTS_ENDPOINT, {
553
- params: {
554
- articleId: id_article,
555
- concept: "images",
556
- orderIdColab: id_order,
557
- version: versionSelected !== null && versionSelected !== void 0 ? versionSelected : version
558
- }
559
- })])]);
560
-
561
- case 10:
562
- _yield$Promise$all = _context4.sent;
563
- _yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 4);
564
- services = _yield$Promise$all2[0];
565
- percentagesRes = _yield$Promise$all2[1];
566
- servicesDataRes = _yield$Promise$all2[2];
567
- commentsResponse = _yield$Promise$all2[3];
568
- dispatch({
569
- type: "SET_RETAILER_STATUS",
570
- payload: servicesDataRes.map(function (service) {
571
- return {
572
- retailer_id: service === null || service === void 0 ? void 0 : service.id_retailer,
573
- service: service === null || service === void 0 ? void 0 : service.service,
574
- status: service === null || service === void 0 ? void 0 : service.status,
575
- task_user_group_id: service === null || service === void 0 ? void 0 : service.task_user_group_id
576
- };
577
- })
578
- }); // Extraer relaciones del response
579
-
580
- percentages = (_JSON$parse$0$relatio = (_JSON$parse = JSON.parse(percentagesRes === null || percentagesRes === void 0 ? void 0 : (_percentagesRes$ = percentagesRes[0]) === null || _percentagesRes$ === void 0 ? void 0 : _percentagesRes$.body)) === null || _JSON$parse === void 0 ? void 0 : (_JSON$parse$ = _JSON$parse[0]) === null || _JSON$parse$ === void 0 ? void 0 : _JSON$parse$.relations) !== null && _JSON$parse$0$relatio !== void 0 ? _JSON$parse$0$relatio : []; // Procesar comentarios
870
+ }).then(function (res) {
871
+ var _res$;
581
872
 
582
- commentsMap = {};
583
- commentsResponse.forEach(function (commentRes) {
584
- var _commentRes$data;
585
-
586
- var commentData = JSON.parse(commentRes === null || commentRes === void 0 ? void 0 : (_commentRes$data = commentRes.data) === null || _commentRes$data === void 0 ? void 0 : _commentRes$data.body).data[0];
587
-
588
- if (commentData) {
589
- var tab = (0, _utils.translateConcept)(commentData.concept);
590
- commentsMap[tab] = commentData;
591
- }
592
- });
593
- dispatch({
594
- type: "SET_COMMENTS",
595
- payload: commentsMap
596
- }); // Ordenamiento de imágenes
597
-
598
- orderMap = services[2].inputsByRetailer.flat().reduce(function (acc, item) {
599
- acc[item.id_image] = item.order;
600
- return acc;
601
- }, {});
602
- orderedValues = (0, _toConsumableArray2.default)(services[2].values).sort(function (a, b) {
603
- var _orderMap$a$image_id, _orderMap$b$image_id;
604
-
605
- var orderA = (_orderMap$a$image_id = orderMap[a.image_id]) !== null && _orderMap$a$image_id !== void 0 ? _orderMap$a$image_id : Number.MAX_SAFE_INTEGER;
606
- var orderB = (_orderMap$b$image_id = orderMap[b.image_id]) !== null && _orderMap$b$image_id !== void 0 ? _orderMap$b$image_id : Number.MAX_SAFE_INTEGER;
607
- return orderA - orderB;
608
- }); // Procesamiento de inputs del retailer activo (evita cascada con state.services)
609
-
610
- retailerDatasheets = services[0][id_retailer];
611
- datasheetsActiveRetailer = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, retailerDatasheets), {}, {
612
- data: Object.values(retailerDatasheets.data)
613
- });
614
- descriptionsActiveRetailer = services[1].filter(function (item) {
615
- return item.id === id_retailer;
616
- });
617
- filteredValues = services[2].values.filter(function (value) {
618
- return services[2].inputsByRetailer.some(function (retailerInput) {
619
- return retailerInput.some(function (input) {
620
- return input.id_retailer === id_retailer && input.id_image === value.image_id;
621
- });
622
- });
623
- }); // Dispatch consolidado
624
-
625
- dispatch({
626
- type: "SET_SERVICES",
627
- payload: {
628
- datasheets: services[0],
629
- descriptions: services[1],
630
- images: (0, _objectSpread5.default)((0, _objectSpread5.default)({}, services[2]), {}, {
631
- values: orderedValues
632
- })
633
- }
634
- });
635
- dispatch({
636
- type: "SET_PERCENTAGES",
637
- payload: percentages
873
+ setPercentages(JSON.parse(res === null || res === void 0 ? void 0 : (_res$ = res[0]) === null || _res$ === void 0 ? void 0 : _res$.body));
638
874
  });
639
- dispatch({
640
- type: "SET_ACTIVE_PERCENTAGES",
641
- payload: percentages.find(function (_ref6) {
642
- var rId = _ref6.id_retailer;
643
- return rId === id_retailer;
644
- })
875
+ setImages({
876
+ action: "orderImages",
877
+ retailerId: activeRetailer.id
645
878
  });
646
- dispatch({
647
- type: "SET_SERVICES_DATA",
648
- payload: servicesDataRes
649
- }); // Setear inputs del retailer activo directamente (evita cascada)
650
-
651
- dispatch({
652
- type: "SET_DATASHEETS_INPUTS",
653
- payload: [datasheetsActiveRetailer, services[0].inputs]
654
- });
655
- dispatch({
656
- type: "SET_DESCRIPTIONS_INPUTS",
657
- payload: descriptionsActiveRetailer
658
- });
659
- dispatch({
660
- type: "SET_IMAGES_VALUES",
661
- payload: (0, _objectSpread5.default)((0, _objectSpread5.default)({}, services[2]), {}, {
662
- values: filteredValues
663
- })
664
- }); // Calcular campos requeridos sin valor
665
-
666
- dispatch({
667
- type: "SET_MISSING_REQUIRED_FIELDS",
668
- payload: (0, _utils.calculateRequiredNull)(services, servicesDataRes, id_retailer)
669
- }); // Auditable
670
-
671
- if (auditableVersion && id_retailer) {
672
- loadAuditableData();
673
- }
674
-
675
- _context4.next = 42;
879
+ setLoading(false);
880
+ _context7.next = 33;
676
881
  break;
677
882
 
678
- case 38:
679
- _context4.prev = 38;
680
- _context4.t0 = _context4["catch"](2);
681
- console.log("Error loading data: ", _context4.t0);
682
- dispatch({
683
- type: "SET_ERRORS",
684
- payload: [_context4.t0.message]
685
- });
686
-
687
- case 42:
688
- _context4.prev = 42;
689
- dispatch({
690
- type: "SET_LOADING",
691
- payload: false
692
- });
693
- return _context4.finish(42);
883
+ case 29:
884
+ _context7.prev = 29;
885
+ _context7.t0 = _context7["catch"](0);
886
+ setLoading(false);
887
+ console.log(_context7.t0);
694
888
 
695
- case 45:
889
+ case 33:
696
890
  case "end":
697
- return _context4.stop();
891
+ return _context7.stop();
698
892
  }
699
893
  }
700
- }, _callee4, null, [[2, 38, 42, 45]]);
894
+ }, _callee7, null, [[0, 29]]);
701
895
  }));
702
896
 
703
897
  return function loadData() {
704
- return _ref5.apply(this, arguments);
898
+ return _ref9.apply(this, arguments);
705
899
  };
706
900
  }();
707
901
 
708
902
  (0, _react.useEffect)(function () {
709
- if (state.active_retailer) {
710
- loadData();
711
- }
712
- }, [state.active_retailer]);
903
+ setLoading(true);
904
+ loadData();
905
+ }, [activeRetailer]);
713
906
 
714
- var handleOnChangeCurrentImage = function handleOnChangeCurrentImage(index) {
715
- if (typeof index === "number") {
716
- dispatch({
717
- type: "SET_CURRENT_IMAGE",
718
- payload: index
719
- });
720
- } else if ((0, _typeof2.default)(index) === "object") {
721
- dispatch({
722
- type: "CHANGE_ATTR_VALUE",
723
- payload: index
724
- });
725
- }
726
- };
727
-
728
- var handleOnShowModalGallery = function handleOnShowModalGallery() {
729
- dispatch({
730
- type: "SET_ACTIVE_TAB",
731
- payload: "Imágenes"
732
- });
733
- setShowModal(true);
734
- };
907
+ var getServices = /*#__PURE__*/function () {
908
+ var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
909
+ var _product$article11, _product$article12, _servicesResponse$dat;
735
910
 
736
- var handleOnChangeActiveRetailer = function handleOnChangeActiveRetailer(retailer) {
737
- dispatch({
738
- type: "SET_ACTIVE_RETAILER",
739
- payload: retailer
740
- });
741
- };
911
+ var servicesResponse, parsedResponse, retailers, retailerResponse, active;
912
+ return _regenerator.default.wrap(function _callee8$(_context8) {
913
+ while (1) {
914
+ switch (_context8.prev = _context8.next) {
915
+ case 0:
916
+ _context8.next = 2;
917
+ return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article11 = product.article) === null || _product$article11 === void 0 ? void 0 : _product$article11.id_article, "&orderId=").concat((product === null || product === void 0 ? void 0 : (_product$article12 = product.article) === null || _product$article12 === void 0 ? void 0 : _product$article12.id_order) || product.orderId, "&end=true"));
742
918
 
743
- var handleOnChangeActiveTab = function handleOnChangeActiveTab(tab) {
744
- dispatch({
745
- type: "SET_ACTIVE_TAB",
746
- payload: tab
747
- });
748
- };
919
+ case 2:
920
+ servicesResponse = _context8.sent;
921
+ 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;
922
+ retailers = product.retailers || product.retailersAvailable;
923
+ retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
924
+ return srv.id_retailer;
925
+ });
926
+ active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
927
+ return retailerResponse.includes(retailer.id);
928
+ });
929
+ !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
930
+ setServicesData(parsedResponse);
749
931
 
750
- var handleOnToggleImageLayout = function handleOnToggleImageLayout() {
751
- setImageLayout(!imageLayout);
752
- };
932
+ case 9:
933
+ case "end":
934
+ return _context8.stop();
935
+ }
936
+ }
937
+ }, _callee8);
938
+ }));
753
939
 
754
- var handleOnToggleObservation = function handleOnToggleObservation() {
755
- setObservationVisible(!isObservationVisible);
756
- };
940
+ return function getServices() {
941
+ return _ref12.apply(this, arguments);
942
+ };
943
+ }();
757
944
 
758
- var handleOnHideObservation = function handleOnHideObservation() {
759
- setObservationVisible(false);
945
+ var translateConcept = function translateConcept(concept) {
946
+ var translation = {
947
+ datasheet: "Ficha técnica",
948
+ description: "Descripción",
949
+ images: "Imágenes"
950
+ };
951
+ return translation[concept];
760
952
  };
761
953
 
762
- var isAuditorAssigned = function isAuditorAssigned() {
763
- var _state$product5;
954
+ var getComments = /*#__PURE__*/function () {
955
+ var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
956
+ var _product$article13, _product$article14, _product$article15;
764
957
 
765
- return ((_state$product5 = state.product) === null || _state$product5 === void 0 ? void 0 : _state$product5.id_auditor) === (user === null || user === void 0 ? void 0 : user.id_user);
766
- };
958
+ var tab,
959
+ commentsResponse,
960
+ comments,
961
+ _args9 = arguments;
962
+ return _regenerator.default.wrap(function _callee9$(_context9) {
963
+ while (1) {
964
+ switch (_context9.prev = _context9.next) {
965
+ case 0:
966
+ tab = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : "Descripción";
967
+ _context9.next = 3;
968
+ return Promise.all([_axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article13 = product.article) === null || _product$article13 === void 0 ? void 0 : _product$article13.id_article, "&concept=description&orderIdColab=").concat(product === null || product === void 0 ? void 0 : product.orderId, "&version=").concat(version)), _axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article14 = product.article) === null || _product$article14 === void 0 ? void 0 : _product$article14.id_article, "&concept=datasheet&orderIdColab=").concat(product === null || product === void 0 ? void 0 : product.orderId, "&version=").concat(version)), _axios.default.get("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article15 = product.article) === null || _product$article15 === void 0 ? void 0 : _product$article15.id_article, "&concept=images&orderIdColab=").concat(product === null || product === void 0 ? void 0 : product.orderId, "&version=").concat(version))]);
767
969
 
768
- var isUserAssignedToService = function isUserAssignedToService(tab, rol) {
769
- var _state$product6;
970
+ case 3:
971
+ commentsResponse = _context9.sent;
972
+ comments = {};
973
+ commentsResponse.forEach(function (comment) {
974
+ var _comment$data, _JSON$parse, _JSON$parse$data$, _comment$data2, _comment$data3;
770
975
 
771
- var concept = (0, _utils.getConceptByTab)(state.active_tab);
772
- var allowedRoles = [1, 4, 5, 6, 7, 8];
773
- var validUser = allowedRoles.includes(user === null || user === void 0 ? void 0 : user.id_role); // Determinar rol por defecto si no se pasa
976
+ return JSON.parse(comment === null || comment === void 0 ? void 0 : (_comment$data = comment.data) === null || _comment$data === void 0 ? void 0 : _comment$data.body).data[0] && (comments[translateConcept((_JSON$parse = JSON.parse(comment === null || comment === void 0 ? void 0 : (_comment$data2 = comment.data) === null || _comment$data2 === void 0 ? void 0 : _comment$data2.body)) === null || _JSON$parse === void 0 ? void 0 : (_JSON$parse$data$ = _JSON$parse.data[0]) === null || _JSON$parse$data$ === void 0 ? void 0 : _JSON$parse$data$.concept)] = JSON.parse(comment === null || comment === void 0 ? void 0 : (_comment$data3 = comment.data) === null || _comment$data3 === void 0 ? void 0 : _comment$data3.body).data[0]);
977
+ });
978
+ setComment(comments[tab]);
979
+ setComments(comments);
774
980
 
775
- if (!rol) {
776
- if (user.id_role === 4 || user.id_role === 5) {
777
- rol = "facilitator";
778
- } else if (user.id_role === 7 || user.id_role === 8) {
779
- rol = "especialist";
780
- }
781
- }
981
+ case 8:
982
+ case "end":
983
+ return _context9.stop();
984
+ }
985
+ }
986
+ }, _callee9);
987
+ }));
782
988
 
783
- var isAdmin = user.id_role === 1;
784
- var idUserAssigned = (_state$product6 = state.product) === null || _state$product6 === void 0 ? void 0 : _state$product6["id_".concat(concept, "_").concat(rol)];
785
- var isAssigned = idUserAssigned === user.id_user;
786
- return isAdmin || isAssigned && validUser;
787
- };
989
+ return function getComments() {
990
+ return _ref13.apply(this, arguments);
991
+ };
992
+ }();
788
993
 
789
- var canShowSingleEvaluationButtons = function canShowSingleEvaluationButtons(action) {
790
- var _state$services_data, _state$services_data$, _state$services_data$2;
994
+ (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
995
+ var arr;
996
+ return _regenerator.default.wrap(function _callee10$(_context10) {
997
+ while (1) {
998
+ switch (_context10.prev = _context10.next) {
999
+ case 0:
1000
+ setLoading(true); // loadData();
1001
+
1002
+ getComments();
1003
+ _context10.t0 = setUserGroups;
1004
+ _context10.next = 5;
1005
+ return (0, _data2.fetchUsers)(token);
1006
+
1007
+ case 5:
1008
+ _context10.t1 = _context10.sent;
1009
+ (0, _context10.t0)(_context10.t1);
1010
+ arr = [];
1011
+ _context10.t2 = user.id_role;
1012
+ _context10.next = _context10.t2 === 7 ? 11 : _context10.t2 === 8 ? 11 : _context10.t2 === 4 ? 13 : _context10.t2 === 5 ? 13 : _context10.t2 === 6 ? 15 : 17;
1013
+ break;
1014
+
1015
+ case 11:
1016
+ arr = ["PA", "AS", "CA", "RC", "RA", "RP", "RCA"];
1017
+ return _context10.abrupt("break", 19);
1018
+
1019
+ case 13:
1020
+ arr = ["RC", "AC", "AA", "AP", "ACA"];
1021
+ return _context10.abrupt("break", 19);
1022
+
1023
+ case 15:
1024
+ arr = ["RP", "RCA", "AC", "RA"];
1025
+ return _context10.abrupt("break", 19);
1026
+
1027
+ case 17:
1028
+ arr = [];
1029
+ return _context10.abrupt("break", 19);
1030
+
1031
+ case 19:
1032
+ setStatusArray(arr);
1033
+ setLoading(false);
1034
+
1035
+ case 21:
1036
+ case "end":
1037
+ return _context10.stop();
1038
+ }
1039
+ }
1040
+ }, _callee10);
1041
+ })), [product, version]);
791
1042
 
792
- var concept = (0, _utils.getConceptByTab)(action || state.active_tab);
793
- var retailerStatus = (_state$services_data = state.services_data) === null || _state$services_data === void 0 ? void 0 : (_state$services_data$ = _state$services_data.find(function (srv) {
794
- var _state$active_retaile2;
1043
+ var loadAssignations = function loadAssignations(currentProduct) {
1044
+ var _currentProduct$artic, _currentProduct$artic2, _currentProduct$artic3, _currentProduct$artic4, _currentProduct$artic5, _currentProduct$artic6;
795
1045
 
796
- return srv.id_retailer === ((_state$active_retaile2 = state.active_retailer) === null || _state$active_retaile2 === void 0 ? void 0 : _state$active_retaile2.id_retailer) && srv.service === concept;
797
- })) === null || _state$services_data$ === void 0 ? void 0 : (_state$services_data$2 = _state$services_data$.status) === null || _state$services_data$2 === void 0 ? void 0 : _state$services_data$2.replace(/.*\//, "");
798
- var adminFacilitatorCanEvaluate = retailerStatus === "IE" && [1, 4, 5].includes(user.id_role);
799
- var adminAuditorCanEvaluate = ["AC", "RP", "RCA", "SAC"].includes(retailerStatus) && [1, 6].includes(user.id_role);
800
- return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
1046
+ setAssig({
1047
+ Descripción: {
1048
+ assignations: [{
1049
+ collaboratorType: "especialist",
1050
+ id: currentProduct === null || currentProduct === void 0 ? void 0 : (_currentProduct$artic = currentProduct.article) === null || _currentProduct$artic === void 0 ? void 0 : _currentProduct$artic.id_description_especialist
1051
+ }, {
1052
+ collaboratorType: "facilitator",
1053
+ id: currentProduct === null || currentProduct === void 0 ? void 0 : (_currentProduct$artic2 = currentProduct.article) === null || _currentProduct$artic2 === void 0 ? void 0 : _currentProduct$artic2.id_description_facilitator
1054
+ }],
1055
+ collaborators: {
1056
+ especialist: userGroups[0] || [],
1057
+ facilitator: userGroups[2] || []
1058
+ }
1059
+ },
1060
+ "Ficha técnica": {
1061
+ assignations: [{
1062
+ collaboratorType: "especialist",
1063
+ id: currentProduct === null || currentProduct === void 0 ? void 0 : (_currentProduct$artic3 = currentProduct.article) === null || _currentProduct$artic3 === void 0 ? void 0 : _currentProduct$artic3.id_datasheet_especialist
1064
+ }, {
1065
+ collaboratorType: "facilitator",
1066
+ id: currentProduct === null || currentProduct === void 0 ? void 0 : (_currentProduct$artic4 = currentProduct.article) === null || _currentProduct$artic4 === void 0 ? void 0 : _currentProduct$artic4.id_datasheet_facilitator
1067
+ }],
1068
+ collaborators: {
1069
+ especialist: userGroups[0] || [],
1070
+ facilitator: userGroups[2] || []
1071
+ }
1072
+ },
1073
+ Imágenes: {
1074
+ assignations: [{
1075
+ collaboratorType: "especialist",
1076
+ id: currentProduct === null || currentProduct === void 0 ? void 0 : (_currentProduct$artic5 = currentProduct.article) === null || _currentProduct$artic5 === void 0 ? void 0 : _currentProduct$artic5.id_images_especialist
1077
+ }, {
1078
+ collaboratorType: "facilitator",
1079
+ id: currentProduct === null || currentProduct === void 0 ? void 0 : (_currentProduct$artic6 = currentProduct.article) === null || _currentProduct$artic6 === void 0 ? void 0 : _currentProduct$artic6.id_images_facilitator
1080
+ }],
1081
+ collaborators: {
1082
+ especialist: userGroups[1] || [],
1083
+ facilitator: userGroups[3] || []
1084
+ }
1085
+ }
1086
+ });
801
1087
  };
802
1088
 
803
- var canShowBulkEvaluationButtons = function canShowBulkEvaluationButtons() {
804
- var concepts = (0, _utils.getConceptsByRole)(user.id_role);
805
- var services = state.services_data.filter(function (_ref7) {
806
- var service = _ref7.service;
807
- return concepts.includes(service);
1089
+ (0, _react.useEffect)(function () {
1090
+ loadAssignations(product);
1091
+ }, [userGroups]);
1092
+ (0, _react.useEffect)(function () {
1093
+ var _percentages$, _percentages$$relatio, _percentages$$relatio2;
1094
+
1095
+ var retailerPercentages = percentages === null || percentages === void 0 ? void 0 : (_percentages$ = percentages[0]) === null || _percentages$ === void 0 ? void 0 : (_percentages$$relatio = _percentages$.relations) === null || _percentages$$relatio === void 0 ? void 0 : (_percentages$$relatio2 = _percentages$$relatio[0]) === null || _percentages$$relatio2 === void 0 ? void 0 : _percentages$$relatio2.percentagesGeneral;
1096
+ var requiredPercentage = retailerPercentages === null || retailerPercentages === void 0 ? void 0 : retailerPercentages.required;
1097
+ setActivePercentage(requiredPercentage); // const retailers = product?.retailersAvailable || product?.retailers;
1098
+ // if (
1099
+ // Object.keys(percentages[product.article.id_article] ?? {})?.length > 0
1100
+ // ) {
1101
+ // retailers?.forEach((retailer, index) => {
1102
+ // retailer["percentage"] = Number(
1103
+ // percentages[product.article.id_article][retailer.id]
1104
+ // ?.percentageRequired
1105
+ // );
1106
+ // });
1107
+ // }
1108
+ // setActivePercentage(retailers[0]?.percentage);
1109
+ }, [percentages]);
1110
+ (0, _react.useEffect)(function () {
1111
+ (0, _utils.getInputsData)(services, activeRetailer, setDatasheets, setDescriptions);
1112
+ auditableVersion && loadAuditableData();
1113
+ setActivePercentage(Math.round(activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.percentage, 0));
1114
+ (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && setImages({
1115
+ action: "orderImages",
1116
+ retailerId: activeRetailer.id
808
1117
  });
809
- var adminFacilitatorCanEvaluate = services.every(function (srv) {
810
- var _srv$status;
811
-
812
- return (srv === null || srv === void 0 ? void 0 : (_srv$status = srv.status) === null || _srv$status === void 0 ? void 0 : _srv$status.replace(/.*\//, "")) === "IE";
813
- }) && [1, 4, 5].includes(user.id_role);
814
- var adminAuditorCanEvaluate = state.services_data.every(function (srv) {
815
- var _srv$status2;
1118
+ }, [activeRetailer, services]);
816
1119
 
817
- return ["AC", "RP", "RCA"].includes(srv === null || srv === void 0 ? void 0 : (_srv$status2 = srv.status) === null || _srv$status2 === void 0 ? void 0 : _srv$status2.replace(/.*\//, ""));
818
- }) && [1, 6].includes(user.id_role);
819
- return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
820
- };
1120
+ var thumbs = function thumbs() {
1121
+ var _images$imageType, _images$imagePackagin, _images$imageShotType, _images$values;
821
1122
 
822
- var getStatusByCurrentServiceAndRetailer = function getStatusByCurrentServiceAndRetailer() {
823
- var _statusByRetailer$fil;
824
-
825
- var statusByRetailer = state.product.statusByRetailer;
826
- if (!statusByRetailer) return "-";
827
- var currentService = (0, _utils.getConceptByTab)(state.active_tab);
828
- var currentRetailer = state.active_retailer.id_retailer;
829
- var currentStatus = ((_statusByRetailer$fil = statusByRetailer.filter(function (item) {
830
- return item.retailer_id === currentRetailer && item.service === currentService;
831
- })[0]) === null || _statusByRetailer$fil === void 0 ? void 0 : _statusByRetailer$fil.status) || "-";
832
- return currentStatus;
1123
+ var imageInputs = socketType === null || socketType === void 0 ? void 0 : socketType.slice();
1124
+ var imageType = images === null || images === void 0 ? void 0 : (_images$imageType = images.imageType) === null || _images$imageType === void 0 ? void 0 : _images$imageType.map(function (e) {
1125
+ return {
1126
+ value: e === null || e === void 0 ? void 0 : e.id,
1127
+ name: e === null || e === void 0 ? void 0 : e.name
1128
+ };
1129
+ });
1130
+ var imagePackagingType = images === null || images === void 0 ? void 0 : (_images$imagePackagin = images.imagePackagingType) === null || _images$imagePackagin === void 0 ? void 0 : _images$imagePackagin.map(function (e) {
1131
+ return {
1132
+ value: e === null || e === void 0 ? void 0 : e.id,
1133
+ name: e === null || e === void 0 ? void 0 : e.name
1134
+ };
1135
+ });
1136
+ var imageShotType = images === null || images === void 0 ? void 0 : (_images$imageShotType = images.imageShotType) === null || _images$imageShotType === void 0 ? void 0 : _images$imageShotType.map(function (e) {
1137
+ return {
1138
+ value: e === null || e === void 0 ? void 0 : e.id,
1139
+ name: e === null || e === void 0 ? void 0 : e.type_shot
1140
+ };
1141
+ });
1142
+ return images === null || images === void 0 ? void 0 : (_images$values = images.values) === null || _images$values === void 0 ? void 0 : _images$values.map(function (image, index) {
1143
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryElement.GalleryElement, {
1144
+ setCheckAll: setCheckAll,
1145
+ image: image,
1146
+ gridLayout: imageLayout,
1147
+ id: "gallery-element-" + index,
1148
+ index: index + "-" + image.name + "-" + compare,
1149
+ number: index,
1150
+ imageType: imageType,
1151
+ imagePackagingType: imagePackagingType,
1152
+ imageInputs: imageInputs,
1153
+ imageShotType: imageShotType,
1154
+ setSocketType: setSocketType,
1155
+ changeImage: setImages,
1156
+ selectedImages: selectedImages,
1157
+ setSelectedImages: setSelectedImages,
1158
+ auditImages: auditImages,
1159
+ compare: compare
1160
+ }, index + "-" + image.name);
1161
+ });
833
1162
  };
834
1163
 
835
- var handleOnClickSaveImages = function handleOnClickSaveImages() {
836
- var _state$product7, _state$product7$servi;
1164
+ var saveDescriptions = /*#__PURE__*/function () {
1165
+ var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
1166
+ var dataClean, _product$article16, productTemp, articleId, dataObject, res, _JSON$parse2, newStatus, newArticleStatus;
837
1167
 
838
- if (((_state$product7 = state.product) === null || _state$product7 === void 0 ? void 0 : (_state$product7$servi = _state$product7.services) === null || _state$product7$servi === void 0 ? void 0 : _state$product7$servi.images) === 1) {
839
- saveImageAttrs(token);
840
- }
841
- };
842
-
843
- var handleOnClickSave = /*#__PURE__*/function () {
844
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
845
- return _regenerator.default.wrap(function _callee5$(_context5) {
1168
+ return _regenerator.default.wrap(function _callee11$(_context11) {
846
1169
  while (1) {
847
- switch (_context5.prev = _context5.next) {
1170
+ switch (_context11.prev = _context11.next) {
848
1171
  case 0:
849
- if (!state.saving) {
850
- _context5.next = 2;
1172
+ dataClean = updatedDescriptions.filter(function (f) {
1173
+ return f.value !== "";
1174
+ });
1175
+
1176
+ if (!(dataClean.length > 0)) {
1177
+ _context11.next = 29;
851
1178
  break;
852
1179
  }
853
1180
 
854
- return _context5.abrupt("return");
1181
+ setLoading(true);
1182
+ productTemp = product;
1183
+ articleId = product === null || product === void 0 ? void 0 : (_product$article16 = product.article) === null || _product$article16 === void 0 ? void 0 : _product$article16.id_article;
1184
+ dataObject = {
1185
+ articleId: articleId,
1186
+ articleData: dataClean
1187
+ };
1188
+ if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1189
+ _context11.prev = 7;
1190
+ _context11.next = 10;
1191
+ return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
1192
+ headers: {
1193
+ Authorization: token
1194
+ }
1195
+ });
1196
+
1197
+ case 10:
1198
+ res = _context11.sent;
855
1199
 
856
- case 2:
857
- _context5.t0 = state.active_tab;
858
- _context5.next = _context5.t0 === "Descripción" ? 5 : _context5.t0 === "Ficha técnica" ? 8 : _context5.t0 === "Imágenes" ? 11 : 14;
1200
+ if (!(res.data.statusCode === 200)) {
1201
+ _context11.next = 21;
1202
+ break;
1203
+ }
1204
+
1205
+ _JSON$parse2 = JSON.parse(res.data.body), newStatus = _JSON$parse2.newStatus, newArticleStatus = _JSON$parse2.newArticleStatus;
1206
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
1207
+ if (newStatus) productTemp.description_status = newStatus;
1208
+ setProduct(productTemp);
1209
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1210
+ setUpdatedDescriptions([]);
1211
+ setMessage("Descripciones guardadas con éxito");
1212
+ _context11.next = 21;
1213
+ return loadData();
1214
+
1215
+ case 21:
1216
+ _context11.next = 26;
859
1217
  break;
860
1218
 
861
- case 5:
862
- _context5.next = 7;
863
- return saveDescriptions(token);
1219
+ case 23:
1220
+ _context11.prev = 23;
1221
+ _context11.t0 = _context11["catch"](7);
1222
+ console.log(_context11.t0);
864
1223
 
865
- case 7:
866
- return _context5.abrupt("break", 15);
1224
+ case 26:
1225
+ _context11.prev = 26;
1226
+ setLoading(false);
1227
+ return _context11.finish(26);
867
1228
 
868
- case 8:
869
- _context5.next = 10;
870
- return saveDatasheets(token);
1229
+ case 29:
1230
+ case "end":
1231
+ return _context11.stop();
1232
+ }
1233
+ }
1234
+ }, _callee11, null, [[7, 23, 26, 29]]);
1235
+ }));
1236
+
1237
+ return function saveDescriptions() {
1238
+ return _ref15.apply(this, arguments);
1239
+ };
1240
+ }();
1241
+
1242
+ var saveDatasheets = /*#__PURE__*/function () {
1243
+ var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
1244
+ var dataClean, _product$article17, productTemp, articleId, dataObject, res, _JSON$parse3, newStatus, newArticleStatus;
1245
+
1246
+ return _regenerator.default.wrap(function _callee12$(_context12) {
1247
+ while (1) {
1248
+ switch (_context12.prev = _context12.next) {
1249
+ case 0:
1250
+ dataClean = updatedDatasheets.filter(function (f) {
1251
+ return f.value !== "";
1252
+ });
1253
+
1254
+ if (!(dataClean.length > 0)) {
1255
+ _context12.next = 29;
1256
+ break;
1257
+ }
1258
+
1259
+ setLoading(true);
1260
+ productTemp = product;
1261
+ articleId = product === null || product === void 0 ? void 0 : (_product$article17 = product.article) === null || _product$article17 === void 0 ? void 0 : _product$article17.id_article;
1262
+ dataObject = {
1263
+ articleId: articleId,
1264
+ articleData: dataClean
1265
+ };
1266
+ if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1267
+ _context12.prev = 7;
1268
+ _context12.next = 10;
1269
+ return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
1270
+ headers: {
1271
+ Authorization: token
1272
+ }
1273
+ });
871
1274
 
872
1275
  case 10:
873
- return _context5.abrupt("break", 15);
1276
+ res = _context12.sent;
874
1277
 
875
- case 11:
876
- _context5.next = 13;
877
- return updateImages(token);
1278
+ if (!(res.data.statusCode === 200)) {
1279
+ _context12.next = 21;
1280
+ break;
1281
+ }
878
1282
 
879
- case 13:
880
- return _context5.abrupt("break", 15);
1283
+ _JSON$parse3 = JSON.parse(res.data.body), newStatus = _JSON$parse3.newStatus, newArticleStatus = _JSON$parse3.newArticleStatus;
1284
+ if (newArticleStatus) productTemp.status = newArticleStatus[articleId];
1285
+ if (newStatus) productTemp.datasheet_status = newStatus;
1286
+ setProduct(productTemp);
1287
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1288
+ setUpdatedDatasheets([]);
1289
+ setMessage("Fichas técnicas guardadas");
1290
+ _context12.next = 21;
1291
+ return loadData();
1292
+
1293
+ case 21:
1294
+ _context12.next = 26;
1295
+ break;
881
1296
 
882
- case 14:
883
- return _context5.abrupt("break", 15);
1297
+ case 23:
1298
+ _context12.prev = 23;
1299
+ _context12.t0 = _context12["catch"](7);
1300
+ console.log(_context12.t0);
884
1301
 
885
- case 15:
886
- _context5.next = 17;
887
- return loadData(false);
1302
+ case 26:
1303
+ _context12.prev = 26;
1304
+ setLoading(false);
1305
+ return _context12.finish(26);
888
1306
 
889
- case 17:
1307
+ case 29:
890
1308
  case "end":
891
- return _context5.stop();
1309
+ return _context12.stop();
892
1310
  }
893
1311
  }
894
- }, _callee5);
1312
+ }, _callee12, null, [[7, 23, 26, 29]]);
895
1313
  }));
896
1314
 
897
- return function handleOnClickSave() {
898
- return _ref8.apply(this, arguments);
1315
+ return function saveDatasheets() {
1316
+ return _ref16.apply(this, arguments);
899
1317
  };
900
1318
  }();
901
1319
 
902
- var handleOnSetUpdatedDescriptions = function handleOnSetUpdatedDescriptions(items) {
903
- dispatch({
904
- type: "SET_UPDATED_DESCRIPTIONS_INPUTS",
905
- payload: items
906
- });
907
- };
1320
+ (0, _react.useEffect)(function () {
1321
+ var _images$inputs;
908
1322
 
909
- var handleOnSetUpdatedDatasheets = function handleOnSetUpdatedDatasheets(items) {
910
- dispatch({
911
- type: "SET_UPDATED_DATASHEETS_INPUTS",
912
- payload: items
1323
+ var imageInputs = images === null || images === void 0 ? void 0 : (_images$inputs = images.inputs) === null || _images$inputs === void 0 ? void 0 : _images$inputs.map(function (e) {
1324
+ var _images$values2;
1325
+
1326
+ return {
1327
+ value: e === null || e === void 0 ? void 0 : e.id,
1328
+ name: e === null || e === void 0 ? void 0 : e.name,
1329
+ required: e === null || e === void 0 ? void 0 : e.required,
1330
+ active: images === null || images === void 0 ? void 0 : (_images$values2 = images.values) === null || _images$values2 === void 0 ? void 0 : _images$values2.some(function (value) {
1331
+ return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
1332
+ })
1333
+ };
913
1334
  });
914
- };
1335
+ setSocketType(imageInputs);
1336
+ }, [images]);
1337
+ var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
1338
+ var _images$values3, _images$attrForImgs, _product$article18, _data$articleData, _data$articleData2, _data$updateImages;
1339
+
1340
+ var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
1341
+
1342
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1343
+ while (1) {
1344
+ switch (_context13.prev = _context13.next) {
1345
+ case 0:
1346
+ imagesList = images === null || images === void 0 ? void 0 : (_images$values3 = images.values) === null || _images$values3 === void 0 ? void 0 : _images$values3.slice();
1347
+ imagesListTemp = imagesList === null || imagesList === void 0 ? void 0 : imagesList.reduce(function (acc, image) {
1348
+ acc[image === null || image === void 0 ? void 0 : image.image_id] = ++acc[image === null || image === void 0 ? void 0 : image.image_id] || 0;
1349
+ return acc;
1350
+ }, {});
1351
+ duplicated = imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (image) {
1352
+ return imagesListTemp[image === null || image === void 0 ? void 0 : image.image_id];
1353
+ });
1354
+ attrForImgs = Object.values((_images$attrForImgs = images === null || images === void 0 ? void 0 : images.attrForImgs) !== null && _images$attrForImgs !== void 0 ? _images$attrForImgs : {}).pop();
1355
+ data = {
1356
+ articleId: product === null || product === void 0 ? void 0 : (_product$article18 = product.article) === null || _product$article18 === void 0 ? void 0 : _product$article18.id_article,
1357
+ attrReqImgs: attrForImgs === null || attrForImgs === void 0 ? void 0 : attrForImgs.map(function (e) {
1358
+ var _e$value;
1359
+
1360
+ return {
1361
+ attrId: e.id,
1362
+ value: (_e$value = e.value) !== null && _e$value !== void 0 ? _e$value : "-"
1363
+ };
1364
+ }),
1365
+ articleData: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
1366
+ return !e.id;
1367
+ }),
1368
+ updateImages: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
1369
+ return e.id;
1370
+ })
1371
+ };
1372
+ if (product !== null && product !== void 0 && product.orderId) data["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1373
+ valid = (data === null || data === void 0 ? void 0 : (_data$articleData = data.articleData) === null || _data$articleData === void 0 ? void 0 : _data$articleData.length) === 0 ? true : data === null || data === void 0 ? void 0 : (_data$articleData2 = data.articleData) === null || _data$articleData2 === void 0 ? void 0 : _data$articleData2.every(function (e, i) {
1374
+ // if (e?.image_id && e?.packing_type && e?.image_type) {
1375
+ if (e !== null && e !== void 0 && e.image_id) {
1376
+ return true;
1377
+ }
915
1378
 
916
- var handleOnAskToDeleteImages = function handleOnAskToDeleteImages() {
917
- if (state.selected_images.length === 0) {
918
- dispatch({
919
- type: "SET_MODAL",
920
- payload: {
921
- show: true,
922
- title: "Eliminar imágenes",
923
- message: "No has seleccionado ninguna imagen para eliminar.",
924
- image: _genericModalWarning.default
925
- }
926
- });
927
- return;
928
- }
1379
+ return false;
1380
+ });
1381
+
1382
+ if (valid && (data === null || data === void 0 ? void 0 : (_data$updateImages = data.updateImages) === null || _data$updateImages === void 0 ? void 0 : _data$updateImages.length) > 0 && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0) {
1383
+ valid = data === null || data === void 0 ? void 0 : (_data$updateImages2 = data.updateImages) === null || _data$updateImages2 === void 0 ? void 0 : _data$updateImages2.every(function (e, i) {
1384
+ // if (e?.image_id && e?.packing_type && e?.image_type) {
1385
+ if (e !== null && e !== void 0 && e.image_id) {
1386
+ return true;
1387
+ }
1388
+
1389
+ return false;
1390
+ });
1391
+ }
1392
+
1393
+ if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
1394
+ _context13.next = 33;
1395
+ break;
1396
+ }
929
1397
 
930
- dispatch({
931
- type: "SET_MODAL",
932
- payload: {
933
- show: true,
934
- title: "Eliminar imágenes",
935
- message: "¿Estás seguro de que deseas eliminar las imágenes seleccionadas?",
936
- image: _genericModalWarning.default,
937
- buttons: [{
938
- text: "Cancelar",
939
- buttonType: "general-white-button",
940
- action: function action() {
941
- return dispatch({
942
- type: "SET_MODAL",
943
- payload: {
944
- show: false
1398
+ setLoading(true);
1399
+ _context13.prev = 10;
1400
+ data === null || data === void 0 ? void 0 : (_data$articleData3 = data.articleData) === null || _data$articleData3 === void 0 ? void 0 : _data$articleData3.forEach(function (e) {
1401
+ e.uuid = (0, _uuid.v4)();
1402
+ });
1403
+ setDataImages(data);
1404
+
1405
+ if (!((data === null || data === void 0 ? void 0 : (_data$articleData4 = data.articleData) === null || _data$articleData4 === void 0 ? void 0 : _data$articleData4.length) > 0)) {
1406
+ _context13.next = 22;
1407
+ break;
1408
+ }
1409
+
1410
+ setImagesUploaded(false);
1411
+ promiseArray = [];
1412
+ data === null || data === void 0 ? void 0 : (_data$articleData5 = data.articleData) === null || _data$articleData5 === void 0 ? void 0 : _data$articleData5.forEach(function (e) {
1413
+ var file;
1414
+
1415
+ if (e.ext == "mp4") {
1416
+ file = Buffer.from(e.video_src.replace(/^data:video\/\w+;base64,/, ""), "base64");
1417
+ e.video_src = "";
1418
+ } else {
1419
+ file = Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
945
1420
  }
1421
+
1422
+ var params = {
1423
+ ACL: "public-read",
1424
+ Body: file,
1425
+ Bucket: S3_BUCKET,
1426
+ Key: "id-".concat(data.articleId, "/").concat(version, "/").concat(e === null || e === void 0 ? void 0 : e.image_id, "-").concat(e === null || e === void 0 ? void 0 : e.uuid, ".").concat(e === null || e === void 0 ? void 0 : e.ext)
1427
+ };
1428
+ promiseArray.push(myBucket.putObject(params).promise());
946
1429
  });
947
- }
948
- }, {
949
- text: "Eliminar",
950
- buttonType: "general-button-default",
951
- action: function action() {
952
- dispatch({
953
- type: "SET_MODAL",
954
- payload: {
955
- show: false
1430
+ _context13.next = 19;
1431
+ return Promise.all(promiseArray);
1432
+
1433
+ case 19:
1434
+ setImagesUploaded(true);
1435
+ _context13.next = 23;
1436
+ break;
1437
+
1438
+ case 22:
1439
+ setImagesUploaded(true);
1440
+
1441
+ case 23:
1442
+ _context13.next = 28;
1443
+ break;
1444
+
1445
+ case 25:
1446
+ _context13.prev = 25;
1447
+ _context13.t0 = _context13["catch"](10);
1448
+ console.log(_context13.t0); // setMainLoading(false);
1449
+
1450
+ case 28:
1451
+ _context13.prev = 28;
1452
+ setLoading(false);
1453
+ return _context13.finish(28);
1454
+
1455
+ case 31:
1456
+ _context13.next = 34;
1457
+ break;
1458
+
1459
+ case 33:
1460
+ // setMainLoading(false);
1461
+ setMessage("Completa los campos que solicita cada una de la imágenes o hay imágenes con el mismo tipo de toma.\nRecuerda hay campos obligatorios y no podras avanzar si no estan completos.");
1462
+
1463
+ case 34:
1464
+ case "end":
1465
+ return _context13.stop();
1466
+ }
1467
+ }
1468
+ }, _callee13, null, [[10, 25, 28, 31]]);
1469
+ })), [images, imagesUploaded]);
1470
+ (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
1471
+ var res, _product$article19, productTemp, _JSON$parse4, newStatus, newArticleStatus;
1472
+
1473
+ return _regenerator.default.wrap(function _callee14$(_context14) {
1474
+ while (1) {
1475
+ switch (_context14.prev = _context14.next) {
1476
+ case 0:
1477
+ if (!imagesUploaded) {
1478
+ _context14.next = 14;
1479
+ break;
1480
+ }
1481
+
1482
+ dataImages.articleData = dataImages === null || dataImages === void 0 ? void 0 : dataImages.articleData.map(function (e) {
1483
+ delete e.src;
1484
+ e.imageID = e.image_id; // e.packingType = e.packing_type;
1485
+ // e.imageType = e.image_type;
1486
+
1487
+ if (product !== null && product !== void 0 && product.orderId) e["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1488
+ return e;
1489
+ });
1490
+ _context14.prev = 2;
1491
+ _context14.next = 5;
1492
+ return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), dataImages, {
1493
+ headers: {
1494
+ Authorization: token
956
1495
  }
957
1496
  });
958
- deleteImages(token);
959
- }
960
- }]
1497
+
1498
+ case 5:
1499
+ res = _context14.sent;
1500
+
1501
+ if (res.data.statusCode === 200) {
1502
+ productTemp = product;
1503
+ _JSON$parse4 = JSON.parse(res.data.body), newStatus = _JSON$parse4.newStatus, newArticleStatus = _JSON$parse4.newArticleStatus;
1504
+ if (newArticleStatus) productTemp.status = newArticleStatus[product === null || product === void 0 ? void 0 : (_product$article19 = product.article) === null || _product$article19 === void 0 ? void 0 : _product$article19.id_article];
1505
+ if (newStatus) productTemp.images_status = newStatus;
1506
+ setProduct(productTemp);
1507
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1508
+ setImages({});
1509
+ setMessage("Imágenes guardadas con éxito");
1510
+ sessionStorage.removeItem("imagesList");
1511
+ }
1512
+
1513
+ _context14.next = 9;
1514
+ return loadData();
1515
+
1516
+ case 9:
1517
+ _context14.next = 14;
1518
+ break;
1519
+
1520
+ case 11:
1521
+ _context14.prev = 11;
1522
+ _context14.t0 = _context14["catch"](2);
1523
+ console.log(_context14.t0);
1524
+
1525
+ case 14:
1526
+ case "end":
1527
+ return _context14.stop();
1528
+ }
961
1529
  }
1530
+ }, _callee14, null, [[2, 11]]);
1531
+ })), [dataImages, imagesUploaded]);
1532
+
1533
+ var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
1534
+ var _srv$find, _srv$find$status, _product$;
1535
+
1536
+ var srv = servicesData.filter(function (serv) {
1537
+ return serv.service === getConcept(tab);
962
1538
  });
1539
+ var srvActive = (_srv$find = srv.find(function (serv) {
1540
+ return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
1541
+ })) === null || _srv$find === void 0 ? void 0 : (_srv$find$status = _srv$find.status) === null || _srv$find$status === void 0 ? void 0 : _srv$find$status.replace(/.*\//, "");
1542
+ var currStatus = (_product$ = product["".concat(getConcept(tab), "_status")]) === null || _product$ === void 0 ? void 0 : _product$.replace(/.*\//, "");
1543
+ var unvalidated = ["IE", "CA"].includes(currStatus);
1544
+ var auditorUnvalidated = !["RA", "AA", "ACA", "AP"].includes(currStatus);
1545
+
1546
+ switch (userId) {
1547
+ case 7:
1548
+ case 8:
1549
+ return statusArray.includes(srvActive) && statusArray.includes(product === null || product === void 0 ? void 0 : product.status) || srv.filter(function (serv) {
1550
+ var _serv$status;
1551
+
1552
+ return statusArray.includes((_serv$status = serv.status) === null || _serv$status === void 0 ? void 0 : _serv$status.replace(/.*\//, ""));
1553
+ }).length === srv.length;
1554
+
1555
+ case 4:
1556
+ case 5:
1557
+ return unvalidated && ["CA", "IE"].includes(product.status) && // "RC", "AC", "AA", "AP", "ACA"
1558
+ srv.filter(function (serv) {
1559
+ return statusArray.includes(serv.status);
1560
+ }).length === srv.length;
1561
+
1562
+ case 6:
1563
+ return statusArray.includes(product.status) && // RP, RCA, AC, RA true
1564
+ srv.every(function (serv) {
1565
+ return ["RA", "AA", "AP", "ACA"].includes(serv.status);
1566
+ }) && auditorUnvalidated;
1567
+
1568
+ default:
1569
+ break;
1570
+ }
963
1571
  };
964
1572
 
965
- var handleOnApproveSingleService = /*#__PURE__*/function () {
966
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
967
- return _regenerator.default.wrap(function _callee6$(_context6) {
968
- while (1) {
969
- switch (_context6.prev = _context6.next) {
970
- case 0:
971
- _context6.next = 2;
972
- return sendSingleEvaluation("A");
1573
+ var getConcept = function getConcept(tab) {
1574
+ switch (tab) {
1575
+ case "Descripción":
1576
+ return "description";
973
1577
 
974
- case 2:
975
- case "end":
976
- return _context6.stop();
977
- }
978
- }
979
- }, _callee6);
980
- }));
1578
+ case "Ficha técnica":
1579
+ return "datasheet";
981
1580
 
982
- return function handleOnApproveSingleService() {
983
- return _ref9.apply(this, arguments);
984
- };
985
- }();
1581
+ case "Imágenes":
1582
+ return "images";
1583
+ }
1584
+ };
1585
+
1586
+ var approveRejectButtons = function approveRejectButtons(action) {
1587
+ var _servicesData$find, _servicesData$find$st;
986
1588
 
987
- var handleOnRejectSingleService = function handleOnRejectSingleService() {
988
- setShowRejectModal(true);
1589
+ var concept = getConcept(action || activeTab);
1590
+ var retailerStatus = (_servicesData$find = servicesData.find(function (srv) {
1591
+ return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
1592
+ })) === null || _servicesData$find === void 0 ? void 0 : (_servicesData$find$st = _servicesData$find.status) === null || _servicesData$find$st === void 0 ? void 0 : _servicesData$find$st.replace(/.*\//, ""); //sessionStorage product
1593
+
1594
+ var adminFacilitatorCanEvaluate = retailerStatus === "IE" && [1, 4, 5].includes(user.id_role);
1595
+ var adminAuditorCanEvaluate = ["AC", "RP", "RCA", "SAC"].includes(retailerStatus) && [1, 6].includes(user.id_role);
1596
+ return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
989
1597
  };
990
1598
 
991
- var sendSingleEvaluation = /*#__PURE__*/function () {
992
- var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(result) {
993
- var _state$product$id_ord, _state$active_retaile3;
1599
+ var approveRejectAllButtons = function approveRejectAllButtons() {
1600
+ var concepts = [];
994
1601
 
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;
1602
+ switch (user.id_role) {
1603
+ case 4:
1604
+ concepts = ["description", "datasheet"];
1605
+ break;
996
1606
 
997
- return _regenerator.default.wrap(function _callee7$(_context7) {
998
- while (1) {
999
- switch (_context7.prev = _context7.next) {
1000
- case 0:
1001
- if (!state.saving) {
1002
- _context7.next = 2;
1003
- break;
1004
- }
1607
+ case 5:
1608
+ concepts = ["images"];
1609
+ break;
1005
1610
 
1006
- return _context7.abrupt("return");
1611
+ default:
1612
+ concepts = ["description", "datasheet", "images"];
1613
+ break;
1614
+ }
1007
1615
 
1008
- case 2:
1009
- dispatch({
1010
- type: "SET_SAVING",
1011
- payload: true
1012
- });
1013
- concept = (0, _utils.getConceptByTab)(state.active_tab);
1014
- articleId = state.product.id_article;
1015
- orderId = (_state$product$id_ord = state.product.id_order) !== null && _state$product$id_ord !== void 0 ? _state$product$id_ord : state.product.orderId;
1016
- sectionStatusKey = "".concat(concept, "_status");
1017
- evalStatus = state.product[sectionStatusKey];
1018
- retailerId = (_state$active_retaile3 = state.active_retailer) === null || _state$active_retaile3 === void 0 ? void 0 : _state$active_retaile3.id_retailer;
1616
+ var services = servicesData.filter(function (_ref19) {
1617
+ var service = _ref19.service;
1618
+ return concepts.includes(service);
1619
+ });
1620
+ var adminFacilitatorCanEvaluate = services.every(function (srv) {
1621
+ var _srv$status;
1622
+
1623
+ return (srv === null || srv === void 0 ? void 0 : (_srv$status = srv.status) === null || _srv$status === void 0 ? void 0 : _srv$status.replace(/.*\//, "")) === "IE";
1624
+ }) && [1, 4, 5].includes(user.id_role); //sessionStorage product
1625
+
1626
+ var adminAuditorCanEvaluate = servicesData.every(function (srv) {
1627
+ var _srv$status2;
1628
+
1629
+ return ["AC", "RP", "RCA"].includes(srv === null || srv === void 0 ? void 0 : (_srv$status2 = srv.status) === null || _srv$status2 === void 0 ? void 0 : _srv$status2.replace(/.*\//, ""));
1630
+ }) && [1, 6].includes(user.id_role);
1631
+ return adminFacilitatorCanEvaluate || adminAuditorCanEvaluate;
1632
+ };
1633
+
1634
+ var getSectionIcon = function getSectionIcon() {
1635
+ switch (activeTab) {
1636
+ case "Ficha técnica":
1637
+ setIcon(_attributesSent.default);
1638
+ break;
1639
+
1640
+ case "Descripción":
1641
+ setIcon(_descriptionSent.default);
1642
+ break;
1643
+
1644
+ case "Imágenes":
1645
+ setIcon(_uploadingImages.default);
1646
+ break;
1647
+
1648
+ default:
1649
+ break;
1650
+ }
1651
+ };
1652
+
1653
+ var sendToFacilitator = /*#__PURE__*/function () {
1654
+ var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(result) {
1655
+ var concept, productTemp, evalStatus, articleId, orderId, data, res, _message, specialistDone, _JSON$parse5, newStatus, newOrderStatus, newArticleStatus, messageToChat, _data;
1656
+
1657
+ return _regenerator.default.wrap(function _callee15$(_context15) {
1658
+ while (1) {
1659
+ switch (_context15.prev = _context15.next) {
1660
+ case 0:
1661
+ if (!loading) setLoading(true);
1662
+ _context15.prev = 1;
1663
+ concept = getConcept(activeTab);
1664
+ productTemp = (0, _objectSpread2.default)({}, product);
1665
+ evalStatus = retailerStatus;
1666
+ articleId = product.article.id_article;
1667
+ orderId = product.orderId;
1019
1668
  data = {
1020
1669
  articleId: articleId,
1021
1670
  orderId: orderId,
1022
1671
  concept: concept,
1023
1672
  evalStatus: evalStatus,
1024
- retailerId: retailerId
1673
+ retailerId: activeRetailer.id
1025
1674
  };
1026
- activeTab = state.active_tab;
1027
- _context7.prev = 11;
1028
1675
 
1029
1676
  if (!result) {
1030
- _context7.next = 28;
1677
+ _context15.next = 16;
1031
1678
  break;
1032
1679
  }
1033
1680
 
1034
1681
  data.result = result;
1035
- data.retailerId = retailerId;
1036
- _context7.next = 17;
1682
+ _context15.next = 12;
1037
1683
  return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1038
1684
  headers: {
1039
1685
  Authorization: token
1040
1686
  }
1041
1687
  });
1042
1688
 
1043
- case 17:
1044
- res = _context7.sent;
1045
- newStatuses = JSON.parse(res.data.body);
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
1051
-
1052
- updatedStatusByRetailer = state.product.statusByRetailer.map(function (item) {
1053
- return item.retailer_id === retailerId && item.service === concept ? (0, _objectSpread5.default)((0, _objectSpread5.default)({}, item), {}, {
1054
- status: serviceStatus
1055
- }) : item;
1056
- });
1057
- updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, {
1058
- statusByRetailer: updatedStatusByRetailer // version_status: articleStatus,
1059
- // status: articleStatus,
1060
- // article_status: articleStatus
1061
-
1062
- });
1063
- dispatch({
1064
- type: "SET_PRODUCT",
1065
- payload: updatedProduct
1066
- }); // Mostrar modal de éxito
1067
-
1068
- dispatch({
1069
- type: "SET_MODAL",
1070
- payload: {
1071
- show: true,
1072
- title: "",
1073
- message: result === "A" ? "Aprobado con éxito" : "Rechazado con éxito",
1074
- image: _genericModalCheck.default
1075
- }
1076
- });
1077
- _context7.next = 33;
1689
+ case 12:
1690
+ res = _context15.sent;
1691
+ getServices();
1692
+ _context15.next = 21;
1078
1693
  break;
1079
1694
 
1080
- case 28:
1081
- //Caso del botón "Enviar evaluación"
1082
- //Se construye el mensaje y se actualiza el estatus
1695
+ case 16:
1083
1696
  specialistDone = ["RC", "RA", "CA"].includes(evalStatus);
1084
1697
 
1085
1698
  if (specialistDone) {
1086
- message = "".concat(activeTab, " enviada a facilitador");
1087
- icon = activeTab === "Descripción" ? _descriptionSent.default : activeTab === "Ficha técnica" ? _attributesSent.default : _uploadingImages.default;
1699
+ _message = "".concat(activeTab, " enviada a facilitador");
1700
+ getSectionIcon();
1088
1701
  } else if (["IE", "AC", "RP", "RCA"].includes(evalStatus)) {
1089
- message = "Evaluación enviada";
1090
- icon = _genericModalCheck.default;
1702
+ _message = "Evaluación enviada";
1703
+ getSectionIcon();
1091
1704
  }
1092
1705
 
1093
- _context7.next = 32;
1706
+ _context15.next = 20;
1094
1707
  return _axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
1095
1708
  headers: {
1096
1709
  Authorization: token
1097
1710
  }
1098
1711
  });
1099
1712
 
1100
- case 32:
1101
- res = _context7.sent;
1713
+ case 20:
1714
+ res = _context15.sent;
1102
1715
 
1103
- case 33:
1104
- if (res.data.statusCode === 200) {
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) => ({
1110
- // id: r.id_retailer,
1111
- // name: r.retailerName,
1112
- // }));
1113
- // const messageToChat = createMessage(
1114
- // retailers,
1115
- // retailerId,
1116
- // evalStatus,
1117
- // newStatus,
1118
- // activeTab,
1119
- // );
1120
- // const messageData = {
1121
- // paramsBody: {
1122
- // id: articleId,
1123
- // version: state.product.version,
1124
- // items: [{ type: "status", value: messageToChat }],
1125
- // retailerId: retailerId,
1126
- // status: state.product.status,
1127
- // },
1128
- // paramsHeader: { Authorization: token },
1129
- // };
1130
- // await sendMessage(messageData);
1131
-
1132
- _updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, (_objectSpread2 = {}, (0, _defineProperty2.default)(_objectSpread2, "".concat(concept, "_status"), newStatus), (0, _defineProperty2.default)(_objectSpread2, "statusByRetailer", state.product.statusByRetailer.map(function (item) {
1133
- if (item.retailer_id === retailerId && item.service === concept) {
1134
- return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, item), {}, {
1135
- status: newStatus
1136
- });
1137
- }
1716
+ case 21:
1717
+ if (!(res.data.statusCode === 200)) {
1718
+ _context15.next = 34;
1719
+ break;
1720
+ }
1138
1721
 
1139
- return item;
1140
- })), _objectSpread2)); //Actualizamos el services_data en el servicio específico del retailer actual
1722
+ _JSON$parse5 = JSON.parse(res.data.body), newStatus = _JSON$parse5.newStatus, newOrderStatus = _JSON$parse5.newOrderStatus, newArticleStatus = _JSON$parse5.newArticleStatus;
1723
+ messageToChat = (0, _utils.createMessage)(product.retailers, activeRetailer.id, evalStatus, newStatus, activeTab);
1724
+ _data = {
1725
+ paramsBody: {
1726
+ id: product.article.id_article,
1727
+ version: version,
1728
+ items: [{
1729
+ type: "status",
1730
+ value: messageToChat
1731
+ }],
1732
+ retailerId: activeRetailer.id,
1733
+ status: product.status
1734
+ },
1735
+ paramsHeader: {
1736
+ Authorization: token
1737
+ }
1738
+ };
1739
+ _context15.next = 27;
1740
+ return (0, _utils.sendMessage)(_data);
1141
1741
 
1142
- updatedServicesData = (_state$services_data2 = state.services_data) === null || _state$services_data2 === void 0 ? void 0 : _state$services_data2.map(function (service) {
1143
- return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, service), {}, {
1144
- status: (service === null || service === void 0 ? void 0 : service.id_retailer) === retailerId && (service === null || service === void 0 ? void 0 : service.service) === concept ? newStatus : service === null || service === void 0 ? void 0 : service.status
1145
- });
1146
- });
1147
- sessionProduct = sessionStorage.getItem("productSelected");
1148
-
1149
- if (sessionProduct) {
1150
- productInSession = JSON.parse(sessionProduct);
1151
- updatedProductInSession = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, productInSession), {}, (_objectSpread3 = {}, (0, _defineProperty2.default)(_objectSpread3, "".concat(concept, "_status"), newStatus), (0, _defineProperty2.default)(_objectSpread3, "statusByRetailer", state.product.statusByRetailer.map(function (item) {
1152
- if (item.retailer_id === retailerId && item.service === concept) {
1153
- return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, item), {}, {
1154
- status: newStatus
1155
- });
1156
- }
1742
+ case 27:
1743
+ if (newOrderStatus) productTemp.status = newArticleStatus[articleId];
1744
+ productTemp["".concat(concept, "_status")] = newStatus;
1745
+ _context15.next = 31;
1746
+ return loadData();
1747
+
1748
+ case 31:
1749
+ if (_message) setMessage(_message);
1750
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1751
+ setProduct(productTemp);
1752
+
1753
+ case 34:
1754
+ _context15.next = 40;
1755
+ break;
1157
1756
 
1158
- return item;
1159
- })), _objectSpread3));
1160
- sessionStorage.setItem("productSelected", JSON.stringify(updatedProductInSession));
1161
- }
1757
+ case 36:
1758
+ _context15.prev = 36;
1759
+ _context15.t0 = _context15["catch"](1);
1760
+ setLoading(false);
1761
+ console.log(_context15.t0);
1162
1762
 
1163
- if (message) {
1164
- dispatch({
1165
- type: "SET_MODAL",
1166
- payload: {
1167
- show: true,
1168
- title: "",
1169
- message: message,
1170
- image: _genericModalCheck.default
1171
- }
1172
- });
1173
- }
1763
+ case 40:
1764
+ case "end":
1765
+ return _context15.stop();
1766
+ }
1767
+ }
1768
+ }, _callee15, null, [[1, 36]]);
1769
+ }));
1174
1770
 
1175
- dispatch({
1176
- type: "SET_PRODUCT",
1177
- payload: _updatedProduct
1178
- });
1179
- dispatch({
1180
- type: "SET_SERVICES_DATA",
1181
- payload: updatedServicesData
1182
- });
1183
- }
1771
+ return function sendToFacilitator(_x5) {
1772
+ return _ref20.apply(this, arguments);
1773
+ };
1774
+ }();
1775
+
1776
+ var userAssigned = function userAssigned(tab, rol) {
1777
+ var concept = getConcept(activeTab);
1778
+ var allowedRoles = [1, 4, 5, 6, 7, 8];
1779
+ var validUser = allowedRoles.includes(user === null || user === void 0 ? void 0 : user.id_role);
1780
+
1781
+ if (!rol) {
1782
+ switch (user.id_role) {
1783
+ case 4:
1784
+ case 5:
1785
+ rol = "facilitator";
1786
+ break;
1787
+
1788
+ case 7:
1789
+ case 8:
1790
+ rol = "especialist";
1791
+ break;
1792
+ }
1793
+ }
1184
1794
 
1185
- _context7.next = 40;
1795
+ return user.id_role === 1 || product.article["id_".concat(concept, "_").concat(rol)] === user.id_user && validUser;
1796
+ };
1797
+
1798
+ var auditorAssigned = function auditorAssigned() {
1799
+ return (product === null || product === void 0 ? void 0 : product.article["id_auditor"]) === user.id_user;
1800
+ };
1801
+
1802
+ var createComment = /*#__PURE__*/function () {
1803
+ var _ref21 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(e, body, tab) {
1804
+ var _product$article20;
1805
+
1806
+ var concept, data;
1807
+ return _regenerator.default.wrap(function _callee16$(_context16) {
1808
+ while (1) {
1809
+ switch (_context16.prev = _context16.next) {
1810
+ case 0:
1811
+ concept = "";
1812
+ _context16.t0 = activeTab;
1813
+ _context16.next = _context16.t0 === "Ficha técnica" ? 4 : _context16.t0 === "Imágenes" ? 6 : 8;
1186
1814
  break;
1187
1815
 
1188
- case 36:
1189
- _context7.prev = 36;
1190
- _context7.t0 = _context7["catch"](11);
1191
- console.error("Error sending evaluation:", _context7.t0);
1192
- dispatch({
1193
- type: "SET_MODAL",
1194
- payload: {
1195
- show: true,
1196
- title: "Error",
1197
- message: "Hubo un error al procesar la evaluación",
1198
- image: _errorModal.default
1816
+ case 4:
1817
+ concept = "datasheet";
1818
+ return _context16.abrupt("break", 10);
1819
+
1820
+ case 6:
1821
+ concept = "images";
1822
+ return _context16.abrupt("break", 10);
1823
+
1824
+ case 8:
1825
+ concept = "description";
1826
+ return _context16.abrupt("break", 10);
1827
+
1828
+ case 10:
1829
+ data = {
1830
+ articleId: product === null || product === void 0 ? void 0 : (_product$article20 = product.article) === null || _product$article20 === void 0 ? void 0 : _product$article20.id_article,
1831
+ orderId: product === null || product === void 0 ? void 0 : product.orderId,
1832
+ message: body === null || body === void 0 ? void 0 : body.replace(/<.*?\/?>/gm, ""),
1833
+ concept: concept,
1834
+ version: version
1835
+ };
1836
+ _context16.next = 13;
1837
+ return _axios.default.post("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1838
+ headers: {
1839
+ Authorization: token
1199
1840
  }
1200
1841
  });
1201
1842
 
1202
- case 40:
1203
- _context7.prev = 40;
1204
- dispatch({
1205
- type: "SET_SAVING",
1206
- payload: false
1207
- });
1208
- return _context7.finish(40);
1843
+ case 13:
1844
+ _context16.next = 15;
1845
+ return getComments(tab);
1209
1846
 
1210
- case 43:
1847
+ case 15:
1848
+ setMessage("");
1849
+ setComponentsArray([]);
1850
+
1851
+ case 17:
1211
1852
  case "end":
1212
- return _context7.stop();
1853
+ return _context16.stop();
1213
1854
  }
1214
1855
  }
1215
- }, _callee7, null, [[11, 36, 40, 43]]);
1856
+ }, _callee16);
1216
1857
  }));
1217
1858
 
1218
- return function sendSingleEvaluation(_x2) {
1219
- return _ref10.apply(this, arguments);
1859
+ return function createComment(_x6, _x7, _x8) {
1860
+ return _ref21.apply(this, arguments);
1220
1861
  };
1221
1862
  }();
1222
1863
 
1223
- var handleOnApproveAllServices = /*#__PURE__*/function () {
1224
- var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
1225
- return _regenerator.default.wrap(function _callee8$(_context8) {
1226
- while (1) {
1227
- switch (_context8.prev = _context8.next) {
1228
- case 0:
1229
- _context8.next = 2;
1230
- return sendBulkEvaluation("A");
1864
+ var getRequired = function getRequired(services) {
1865
+ try {
1866
+ var _services$2, _services$2$retailerM, _services$3, _services$3$inputs;
1867
+
1868
+ var objetcTemp = {};
1869
+ var datasheetServicesArray = Object.values(services[0]);
1870
+ var allDatasheetInputs = datasheetServicesArray.pop();
1871
+ var descriptionsServicesArray = services[1];
1872
+ var dsInputsRequired = [];
1873
+ var desInputsRequired = 0;
1874
+ datasheetServicesArray === null || datasheetServicesArray === void 0 ? void 0 : datasheetServicesArray.forEach(function (datasheet) {
1875
+ var _servicesData$filter = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (srv) {
1876
+ return srv.id_retailer === datasheet.retailer.id && srv.service === getConcept(activeTab);
1877
+ }),
1878
+ _servicesData$filter2 = (0, _slicedToArray2.default)(_servicesData$filter, 1),
1879
+ requested = _servicesData$filter2[0];
1231
1880
 
1232
- case 2:
1233
- case "end":
1234
- return _context8.stop();
1235
- }
1236
- }
1237
- }, _callee8);
1238
- }));
1881
+ requested && (datasheet === null || datasheet === void 0 ? void 0 : datasheet.data) && Object.values(datasheet === null || datasheet === void 0 ? void 0 : datasheet.data).forEach(function (dataGroup) {
1882
+ dsInputsRequired.push.apply(dsInputsRequired, (0, _toConsumableArray2.default)(dataGroup.inputs.filter(function (input) {
1883
+ return allDatasheetInputs[input].required && allDatasheetInputs[input].id_retailer === activeRetailer.id && (allDatasheetInputs[input].value === undefined || !allDatasheetInputs[input].value);
1884
+ })));
1885
+ });
1886
+ });
1887
+ objetcTemp["Ficha técnica"] = dsInputsRequired.length;
1888
+ var regex = /(<\/?p>)|(<\/?strong>)|(<br>)/gm;
1889
+ descriptionsServicesArray.forEach(function (description) {
1890
+ if (description.id != activeRetailer.id) return;
1239
1891
 
1240
- return function handleOnApproveAllServices() {
1241
- return _ref11.apply(this, arguments);
1242
- };
1243
- }();
1892
+ var _servicesData$filter3 = servicesData.filter(function (srv) {
1893
+ return srv.id_retailer === description.id && srv.service === getConcept(activeTab);
1894
+ }),
1895
+ _servicesData$filter4 = (0, _slicedToArray2.default)(_servicesData$filter3, 1),
1896
+ requested = _servicesData$filter4[0];
1244
1897
 
1245
- var handleOnRejectAllServices = function handleOnRejectAllServices() {
1246
- setRejectAll(true);
1247
- setShowRejectModal(true);
1898
+ if (requested) {
1899
+ description.inputs.forEach(function (input) {
1900
+ var _input$value;
1901
+
1902
+ if (input.required && (!input.value || ((_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.replace(regex, "")) === "")) {
1903
+ desInputsRequired++;
1904
+ }
1905
+ });
1906
+ }
1907
+ });
1908
+ objetcTemp["Descripción"] = desInputsRequired;
1909
+ var retailersRequested = [];
1910
+ (_services$2 = services[2]) === null || _services$2 === void 0 ? void 0 : (_services$2$retailerM = _services$2.retailerMandatories) === null || _services$2$retailerM === void 0 ? void 0 : _services$2$retailerM.forEach(function (retMan) {
1911
+ return retMan.forEach(function (rm) {
1912
+ return retailersRequested.push(rm);
1913
+ });
1914
+ });
1915
+ var requiredImages = (_services$3 = services[2]) === null || _services$3 === void 0 ? void 0 : (_services$3$inputs = _services$3.inputs) === null || _services$3$inputs === void 0 ? void 0 : _services$3$inputs.filter(function (e) {
1916
+ return e.required === 1 && retailersRequested.filter(function (ret) {
1917
+ return ret.id_image === e.id && servicesData.filter(function (srv) {
1918
+ return srv.id_retailer === ret.id_retailer;
1919
+ }).length > 0;
1920
+ }).length > 0;
1921
+ });
1922
+ var requiredCounter = 0;
1923
+ requiredImages === null || requiredImages === void 0 ? void 0 : requiredImages.forEach(function (req) {
1924
+ return services[2].values.filter(function (img) {
1925
+ return img.image_id === req.id;
1926
+ }).length === 0 && requiredCounter++;
1927
+ });
1928
+ objetcTemp["Imágenes"] = requiredCounter;
1929
+ setRequiredNull(objetcTemp);
1930
+ } catch (error) {
1931
+ console.log(error);
1932
+ }
1248
1933
  };
1249
1934
 
1250
- var sendBulkEvaluation = /*#__PURE__*/function () {
1251
- var _ref12 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(result) {
1252
- var _state$services_data3, evaluationArray, conceptArray, status, updatedStatusByRetailer, updatedProduct, updatedServicesData;
1935
+ (0, _react.useEffect)(function () {
1936
+ setComment(comments[activeTab]);
1937
+ }, [activeTab]);
1253
1938
 
1254
- return _regenerator.default.wrap(function _callee9$(_context9) {
1939
+ var commentRevised = /*#__PURE__*/function () {
1940
+ var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
1941
+ var data;
1942
+ return _regenerator.default.wrap(function _callee17$(_context17) {
1255
1943
  while (1) {
1256
- switch (_context9.prev = _context9.next) {
1944
+ switch (_context17.prev = _context17.next) {
1257
1945
  case 0:
1258
- dispatch({
1259
- type: "SET_SAVING",
1260
- payload: true
1261
- });
1262
- _context9.prev = 1;
1263
- evaluationArray = [];
1264
- conceptArray = (0, _utils.getConceptsByRole)(user.id_role);
1265
- (_state$services_data3 = state.services_data) === null || _state$services_data3 === void 0 ? void 0 : _state$services_data3.forEach(function (ret, idx) {
1266
- var retailer_service = ret.service,
1267
- id_retailer = ret.id_retailer,
1268
- status_retailer_service = ret.status;
1269
- var lastStatusLevel = status_retailer_service.replace(/.*\//, "");
1270
-
1271
- if (conceptArray.includes(retailer_service) && statusArray !== null && statusArray !== void 0 && statusArray.includes(lastStatusLevel)) {
1272
- var data = {
1273
- articleId: state.product.id_article,
1274
- orderId: state.product.id_order,
1275
- concept: retailer_service,
1276
- result: result,
1277
- evalStatus: status_retailer_service,
1278
- retailerId: id_retailer
1279
- };
1280
- evaluationArray.push(_axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
1281
- headers: {
1282
- Authorization: token
1283
- }
1284
- }));
1285
- }
1286
- });
1287
- _context9.next = 7;
1288
- return Promise.all(evaluationArray);
1289
-
1290
- case 7:
1291
- status = "".concat(result, "A"); // Actualizar el statusByRetailer para todos los retailers y conceptos
1292
-
1293
- updatedStatusByRetailer = state.product.statusByRetailer.map(function (item) {
1294
- return conceptArray.includes(item.service) ? (0, _objectSpread5.default)((0, _objectSpread5.default)({}, item), {}, {
1295
- status: status
1296
- }) : item;
1297
- }); // Actualizar el producto con los nuevos estados
1298
-
1299
- updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, {
1300
- article_status: status,
1301
- status: status,
1302
- datasheet_status: state.product.datasheet_status === "NA" ? "NA" : status,
1303
- description_status: state.product.description_status === "NA" ? "NA" : status,
1304
- images_status: state.product.images_status === "NA" ? "NA" : status,
1305
- statusByRetailer: updatedStatusByRetailer
1306
- });
1307
- dispatch({
1308
- type: "SET_PRODUCT",
1309
- payload: updatedProduct
1310
- });
1311
- updatedServicesData = state.services_data.map(function (service) {
1312
- return conceptArray.includes(service.service) ? (0, _objectSpread5.default)((0, _objectSpread5.default)({}, service), {}, {
1313
- status: status
1314
- }) : service;
1315
- });
1316
- dispatch({
1317
- type: "SET_SERVICES_DATA",
1318
- payload: updatedServicesData
1319
- }); // sessionStorage.setItem(
1320
- // "productSelected",
1321
- // JSON.stringify(updatedProduct),
1322
- // );
1323
- // sessionStorage.setItem(
1324
- // "productEdit",
1325
- // JSON.stringify({
1326
- // ArticleId: updatedProduct.id_article,
1327
- // idCategory: updatedProduct.id_category,
1328
- // product: updatedProduct,
1329
- // }),
1330
- // );
1331
- // Mostrar modal de éxito
1332
-
1333
- dispatch({
1334
- type: "SET_MODAL",
1335
- payload: {
1336
- show: true,
1337
- title: "",
1338
- message: result === "A" ? "Todos los servicios aprobados con éxito" : "Todos los servicios rechazados con éxito",
1339
- image: _genericModalCheck.default
1946
+ data = {
1947
+ commentId: comment.id
1948
+ };
1949
+ _context17.next = 3;
1950
+ return _axios.default.put("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1951
+ headers: {
1952
+ Authorization: sessionStorage.getItem("jwt")
1340
1953
  }
1341
1954
  });
1342
- _context9.next = 19;
1343
- break;
1344
-
1345
- case 16:
1346
- _context9.prev = 16;
1347
- _context9.t0 = _context9["catch"](1);
1348
- console.error("Error in bulk evaluation:", _context9.t0);
1349
1955
 
1350
- case 19:
1351
- _context9.prev = 19;
1352
- dispatch({
1353
- type: "SET_SAVING",
1354
- payload: false
1355
- });
1356
- return _context9.finish(19);
1956
+ case 3:
1957
+ setCrossComment(false);
1958
+ _context17.next = 6;
1959
+ return getComments();
1357
1960
 
1358
- case 22:
1961
+ case 6:
1359
1962
  case "end":
1360
- return _context9.stop();
1963
+ return _context17.stop();
1361
1964
  }
1362
1965
  }
1363
- }, _callee9, null, [[1, 16, 19, 22]]);
1966
+ }, _callee17);
1364
1967
  }));
1365
1968
 
1366
- return function sendBulkEvaluation(_x3) {
1367
- return _ref12.apply(this, arguments);
1969
+ return function commentRevised() {
1970
+ return _ref22.apply(this, arguments);
1368
1971
  };
1369
1972
  }();
1370
1973
 
1371
- var handleOnChangeAssignations = /*#__PURE__*/function () {
1372
- var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(assignationType, assignationId) {
1373
- var concept, data, updatedProduct;
1374
- return _regenerator.default.wrap(function _callee10$(_context10) {
1974
+ var setAssignation = /*#__PURE__*/function () {
1975
+ var _ref23 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(assignationType, assignationId) {
1976
+ var _product$article21;
1977
+
1978
+ var concept, productTemp, data;
1979
+ return _regenerator.default.wrap(function _callee18$(_context18) {
1375
1980
  while (1) {
1376
- switch (_context10.prev = _context10.next) {
1981
+ switch (_context18.prev = _context18.next) {
1377
1982
  case 0:
1378
- concept = (0, _utils.getConceptByTab)(state.active_tab);
1983
+ concept = "";
1984
+ _context18.t0 = activeTab;
1985
+ _context18.next = _context18.t0 === "Ficha técnica" ? 4 : _context18.t0 === "Imágenes" ? 6 : 8;
1986
+ break;
1987
+
1988
+ case 4:
1989
+ concept = "datasheet";
1990
+ return _context18.abrupt("break", 10);
1991
+
1992
+ case 6:
1993
+ concept = "images";
1994
+ return _context18.abrupt("break", 10);
1995
+
1996
+ case 8:
1997
+ concept = "description";
1998
+ return _context18.abrupt("break", 10);
1999
+
2000
+ case 10:
2001
+ productTemp = product;
2002
+ productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1379
2003
  data = {
1380
2004
  articleList: [{
1381
- orderId: state.product.id_order,
1382
- articleId: state.product.id_article
2005
+ orderId: product.orderId,
2006
+ articleId: product === null || product === void 0 ? void 0 : (_product$article21 = product.article) === null || _product$article21 === void 0 ? void 0 : _product$article21.id_article
1383
2007
  }],
1384
2008
  concept: concept,
1385
2009
  userId: assignationId
1386
2010
  };
1387
- _context10.next = 4;
2011
+ _context18.next = 15;
1388
2012
  return (0, _axios.default)({
1389
2013
  method: "post",
1390
2014
  url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
@@ -1394,420 +2018,583 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1394
2018
  }
1395
2019
  });
1396
2020
 
1397
- case 4:
1398
- updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, (0, _defineProperty2.default)({}, "id_".concat(concept, "_").concat(assignationType), assignationId));
1399
- dispatch({
1400
- type: "SET_PRODUCT",
1401
- payload: updatedProduct
1402
- });
2021
+ case 15:
2022
+ loadAssignations(productTemp);
2023
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1403
2024
 
1404
- case 6:
2025
+ case 17:
1405
2026
  case "end":
1406
- return _context10.stop();
2027
+ return _context18.stop();
1407
2028
  }
1408
2029
  }
1409
- }, _callee10);
2030
+ }, _callee18);
1410
2031
  }));
1411
2032
 
1412
- return function handleOnChangeAssignations(_x4, _x5) {
1413
- return _ref13.apply(this, arguments);
2033
+ return function setAssignation(_x9, _x10) {
2034
+ return _ref23.apply(this, arguments);
1414
2035
  };
1415
2036
  }();
1416
2037
 
1417
- var handleOnSetAssignation = function handleOnSetAssignation() {
1418
- console.log("handleOnSetAssignation - pendiente de implementar");
1419
- };
1420
-
1421
- var handleOnSetImages = function handleOnSetImages() {
1422
- console.log("handleOnSetImages - pendiente de implementar");
1423
- };
2038
+ var downloadImages = function downloadImages() {
2039
+ var _images$values4;
1424
2040
 
1425
- var handleOnSetCheckAll = function handleOnSetCheckAll(isChecked) {
1426
- dispatch({
1427
- type: "TOGGLE_CHECK_ALL_IMAGES",
1428
- payload: isChecked
2041
+ selectedImages.length > 0 ? selectedImages.forEach(function (e) {
2042
+ if (e.id) {
2043
+ (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.article.upc, "_").concat(e.name, ".").concat(e.ext));
2044
+ }
2045
+ }) : images === null || images === void 0 ? void 0 : (_images$values4 = images.values) === null || _images$values4 === void 0 ? void 0 : _images$values4.forEach(function (e) {
2046
+ if (e.id) {
2047
+ (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.article.upc, "_").concat(e.name, ".").concat(e.ext));
2048
+ }
1429
2049
  });
1430
2050
  };
1431
2051
 
1432
- var handleOnSetSelectedImages = function handleOnSetSelectedImages() {
1433
- /*
1434
- Esta función no se utiliza actualmente.
1435
- En la versión anterior se usaban dos funciones distintas para el checkbox
1436
- "Seleccionar todo":
1437
- - Una para cambiar el valor booleano del checkbox.
1438
- - Otra para actualizar el array de imágenes seleccionadas.
1439
- En la versión actual se unificó la lógica en una sola función,
1440
- `handleOnSetCheckAll`, que recibe el valor `true` o `false` del checkbox
1441
- "Seleccionar todo" y, a partir de este, agrega o elimina todas las imágenes
1442
- del array de imágenes seleccionadas.
1443
- */
1444
- console.log("setSelectedImages");
1445
- };
1446
-
1447
- var handleOnSubmitComment = /*#__PURE__*/function () {
1448
- var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(e) {
1449
- var commentText;
1450
- return _regenerator.default.wrap(function _callee11$(_context11) {
2052
+ var deleteImages = /*#__PURE__*/function () {
2053
+ var _ref24 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
2054
+ var values, imgsInBack, imgsLeft, data;
2055
+ return _regenerator.default.wrap(function _callee19$(_context19) {
1451
2056
  while (1) {
1452
- switch (_context11.prev = _context11.next) {
2057
+ switch (_context19.prev = _context19.next) {
1453
2058
  case 0:
1454
- e.preventDefault();
1455
- commentText = document.querySelector("#commentary-box .ql-container .ql-editor > p").innerHTML;
1456
- _context11.prev = 2;
1457
- _context11.next = 5;
1458
- return createComment(commentText, token);
1459
-
1460
- case 5:
1461
- dispatch({
1462
- type: "SET_MODAL",
1463
- payload: {
1464
- show: true,
1465
- title: "",
1466
- message: "Comentario guardado con éxito",
1467
- image: _genericModalCheck.default
1468
- }
2059
+ setLoading(true);
2060
+ values = images.values;
2061
+ imgsInBack = [];
2062
+ selectedImages.forEach(function (selectedImg) {
2063
+ if (selectedImg.id) imgsInBack.push(selectedImg);
2064
+ });
2065
+ imgsLeft = values.filter(function (value) {
2066
+ return selectedImages.indexOf(value) === -1;
1469
2067
  });
1470
- _context11.next = 12;
1471
- break;
1472
2068
 
1473
- case 8:
1474
- _context11.prev = 8;
1475
- _context11.t0 = _context11["catch"](2);
1476
- console.error("Error saving comment:", _context11.t0);
1477
- dispatch({
1478
- type: "SET_MODAL",
1479
- payload: {
1480
- show: true,
1481
- title: "Error",
1482
- message: "Hubo un error al guardar el comentario",
1483
- image: _errorModal.default
2069
+ if (!(imgsInBack.length > 0)) {
2070
+ _context19.next = 15;
2071
+ break;
2072
+ }
2073
+
2074
+ data = {
2075
+ articleId: product.article.id_article,
2076
+ deleteImages: imgsInBack,
2077
+ orderId: product.orderId
2078
+ };
2079
+ _context19.prev = 7;
2080
+ _context19.next = 10;
2081
+ return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), data, {
2082
+ headers: {
2083
+ Authorization: token
1484
2084
  }
1485
2085
  });
1486
2086
 
2087
+ case 10:
2088
+ _context19.next = 15;
2089
+ break;
2090
+
1487
2091
  case 12:
2092
+ _context19.prev = 12;
2093
+ _context19.t0 = _context19["catch"](7);
2094
+ console.log(_context19.t0);
2095
+
2096
+ case 15:
2097
+ setImages({
2098
+ action: "deleteImage",
2099
+ selectedImages: selectedImages
2100
+ });
2101
+ getRequired([services[0], services[1], (0, _objectSpread2.default)((0, _objectSpread2.default)({}, services[2]), {}, {
2102
+ values: imgsLeft
2103
+ })]);
2104
+ setLoading(false);
2105
+ setMessage("");
2106
+ setComponentsArray([]);
2107
+
2108
+ case 20:
1488
2109
  case "end":
1489
- return _context11.stop();
2110
+ return _context19.stop();
1490
2111
  }
1491
2112
  }
1492
- }, _callee11, null, [[2, 8]]);
2113
+ }, _callee19, null, [[7, 12]]);
1493
2114
  }));
1494
2115
 
1495
- return function handleOnSubmitComment(_x6) {
1496
- return _ref14.apply(this, arguments);
2116
+ return function deleteImages() {
2117
+ return _ref24.apply(this, arguments);
1497
2118
  };
1498
2119
  }();
1499
2120
 
1500
- var handleOnSendEvaluationToFacilitator = function handleOnSendEvaluationToFacilitator() {
1501
- sendSingleEvaluation();
2121
+ var askToDeleteImages = function askToDeleteImages() {
2122
+ if (selectedImages.length > 0) {
2123
+ setMessage("¿Está seguro de eliminar las imágenes seleccionadas?");
2124
+ setComponentsArray([/*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2125
+ text: "¿Está seguro de eliminar las imágenes seleccionadas?",
2126
+ headerType: "retailer-name-header",
2127
+ color: "white"
2128
+ }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2129
+ buttonType: "general-white-button",
2130
+ label: "Cancelar",
2131
+ onClick: function onClick() {
2132
+ return setMessage("");
2133
+ }
2134
+ }, "2"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2135
+ buttonType: "general-button-default",
2136
+ label: "Aceptar",
2137
+ onClick: function onClick() {
2138
+ setMessage("");
2139
+ deleteImages();
2140
+ }
2141
+ }, "3")]);
2142
+ }
1502
2143
  };
1503
2144
 
1504
- var isEvaluationFinished = function isEvaluationFinished(id_rol, tab, statusArray) {
1505
- var _servicesByTab$find, _servicesByTab$find$s, _product$, _srv;
2145
+ var getRetailerStatus = function getRetailerStatus(servicesData, tab) {
2146
+ var arr = servicesData === null || servicesData === void 0 ? void 0 : servicesData.slice();
2147
+ var concept = getConcept(tab);
2148
+ var retailerService = {};
1506
2149
 
1507
- var servicesData = state.services_data;
1508
- var activeRetailer = state.active_retailer;
1509
- var product = state.product;
1510
- var concept = (0, _utils.getConceptByTab)(tab);
1511
- var servicesByTab = servicesData === null || servicesData === void 0 ? void 0 : servicesData.filter(function (serv) {
1512
- return serv.service === concept;
2150
+ var _arr$filter = arr === null || arr === void 0 ? void 0 : arr.filter(function (service) {
2151
+ return service.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && service.service === concept;
1513
2152
  });
1514
- var statusBySelectedRetailerService = servicesByTab === null || servicesByTab === void 0 ? void 0 : (_servicesByTab$find = servicesByTab.find(function (serv) {
1515
- return serv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id_retailer);
1516
- })) === null || _servicesByTab$find === void 0 ? void 0 : (_servicesByTab$find$s = _servicesByTab$find.status) === null || _servicesByTab$find$s === void 0 ? void 0 : _servicesByTab$find$s.replace(/.*\//, "");
1517
- var currentProducStatus = product === null || product === void 0 ? void 0 : (_product$ = product["".concat(concept, "_status")]) === null || _product$ === void 0 ? void 0 : _product$.replace(/.*\//, "");
1518
- var unvalidated = ["IE", "CA"].includes(currentProducStatus);
1519
- var auditorUnvalidated = !["RA", "AA", "ACA", "AP"].includes(currentProducStatus);
1520
- var result;
1521
-
1522
- switch (id_rol) {
1523
- case 7:
1524
- case 8:
1525
- var canSendEvaluation = statusArray.includes(statusBySelectedRetailerService); // const conditionTwo = statusArray.includes(product?.status);
1526
- // const conditionThree =
1527
- // servicesByTab.filter((service) =>
1528
- // statusArray.includes(service.status?.replace(/.*\//, "")),
1529
- // ).length === servicesByTab.length;
1530
- // return (canSendEvaluation && conditionTwo) || conditionThree;
1531
2153
 
1532
- return canSendEvaluation;
2154
+ var _arr$filter2 = (0, _slicedToArray2.default)(_arr$filter, 1);
1533
2155
 
1534
- case 4:
1535
- case 5:
1536
- var filteredSrv45 = servicesByTab === null || servicesByTab === void 0 ? void 0 : servicesByTab.filter(function (serv) {
1537
- return statusArray.includes(serv === null || serv === void 0 ? void 0 : serv.status);
1538
- });
1539
- var condition45 = unvalidated && ["CA", "IE"].includes(product === null || product === void 0 ? void 0 : product.status) && (filteredSrv45 === null || filteredSrv45 === void 0 ? void 0 : filteredSrv45.length) === (servicesByTab === null || servicesByTab === void 0 ? void 0 : servicesByTab.length);
1540
- return condition45;
2156
+ retailerService = _arr$filter2[0];
2157
+ return retailerService ? retailerService.status : "NS";
2158
+ };
1541
2159
 
1542
- case 6:
1543
- var statusInArray = statusArray.includes(product === null || product === void 0 ? void 0 : product.status);
1544
- var allSrvValid = (_srv = srv) === null || _srv === void 0 ? void 0 : _srv.every(function (serv) {
1545
- return ["RA", "AA", "AP", "ACA"].includes(serv === null || serv === void 0 ? void 0 : serv.status);
1546
- });
1547
- var condition6 = statusInArray && allSrvValid && auditorUnvalidated;
1548
- return condition6;
2160
+ (0, _react.useEffect)(function () {
2161
+ var status = getRetailerStatus(servicesData, activeTab);
2162
+ setRetailerStatus(status);
2163
+ }, [activeTab, servicesData, activeRetailer]);
2164
+ (0, _react.useEffect)(function () {
2165
+ services.length > 0 && getRequired(services);
2166
+ }, [services, servicesData, activeTab]);
2167
+ (0, _react.useEffect)(function () {
2168
+ setSaving(loading);
2169
+ }, [loading]);
1549
2170
 
1550
- default:
1551
- console.log("Default case - returning false");
1552
- return false;
1553
- }
1554
- };
2171
+ var validateAll = /*#__PURE__*/function () {
2172
+ var _ref25 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(result) {
2173
+ var evaluationArray, conceptArray, messages, productTemp, messagesResponse;
2174
+ return _regenerator.default.wrap(function _callee20$(_context20) {
2175
+ while (1) {
2176
+ switch (_context20.prev = _context20.next) {
2177
+ case 0:
2178
+ _context20.prev = 0;
2179
+ setLoading(true);
2180
+ evaluationArray = [];
2181
+ conceptArray = [];
2182
+ _context20.t0 = user.id_role;
2183
+ _context20.next = _context20.t0 === 4 ? 7 : _context20.t0 === 5 ? 9 : 11;
2184
+ break;
1555
2185
 
1556
- var handleOnChangeProductVersion = function handleOnChangeProductVersion(version) {
1557
- console.log('se cambia la version');
1558
- dispatch({
1559
- type: "SET_PRODUCT_VERSION",
1560
- payload: version
1561
- });
1562
- loadData(true, version);
1563
- };
2186
+ case 7:
2187
+ conceptArray = ["description", "datasheet"];
2188
+ return _context20.abrupt("break", 13);
1564
2189
 
1565
- var ProductEditionSkeleton = function ProductEditionSkeleton() {
1566
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
1567
- headerTop: 0,
1568
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1569
- px: 1.5,
1570
- py: 1,
1571
- pb: 0,
1572
- display: "flex",
1573
- alignItems: "center",
1574
- justifyContent: "space-between",
1575
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1576
- variant: "text",
1577
- width: 300,
1578
- height: 40
1579
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Stack, {
1580
- direction: "row",
1581
- spacing: 2,
1582
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1583
- variant: "circular",
1584
- width: 32,
1585
- height: 32
1586
- })
2190
+ case 9:
2191
+ conceptArray = ["images"];
2192
+ return _context20.abrupt("break", 13);
2193
+
2194
+ case 11:
2195
+ conceptArray = ["description", "datasheet", "images"];
2196
+ return _context20.abrupt("break", 13);
2197
+
2198
+ case 13:
2199
+ messages = [];
2200
+ servicesData === null || servicesData === void 0 ? void 0 : servicesData.forEach(function (ret) {
2201
+ if (conceptArray.includes(ret.service)) {
2202
+ var _product$id_order;
2203
+
2204
+ var data = {
2205
+ articleId: product.article.id_article,
2206
+ orderId: (_product$id_order = product.id_order) !== null && _product$id_order !== void 0 ? _product$id_order : product.orderId,
2207
+ concept: ret.service,
2208
+ result: result,
2209
+ evalStatus: ret.status,
2210
+ retailerId: ret.id_retailer
2211
+ };
2212
+ evaluationArray.push(_axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
2213
+ headers: {
2214
+ Authorization: token
2215
+ }
2216
+ }));
2217
+ }
2218
+ });
2219
+ _context20.next = 17;
2220
+ return Promise.all(evaluationArray);
2221
+
2222
+ case 17:
2223
+ productTemp = product;
2224
+ productTemp.status = "".concat(result, "A");
2225
+ productTemp.datasheet_status = productTemp.datasheet_status === "NS" ? "NS" : "".concat(result, "A");
2226
+ productTemp.description_status = productTemp.description_status === "NS" ? "NS" : "".concat(result, "A");
2227
+ productTemp.images_status = productTemp.images_status === "NS" ? "NS" : "".concat(result, "A");
2228
+ sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
2229
+ setProduct(productTemp);
2230
+ _context20.next = 26;
2231
+ return Promise.all(messages);
2232
+
2233
+ case 26:
2234
+ messagesResponse = _context20.sent;
2235
+ _context20.next = 29;
2236
+ return loadData();
2237
+
2238
+ case 29:
2239
+ _context20.next = 34;
2240
+ break;
2241
+
2242
+ case 31:
2243
+ _context20.prev = 31;
2244
+ _context20.t1 = _context20["catch"](0);
2245
+ console.log(_context20.t1);
2246
+
2247
+ case 34:
2248
+ _context20.prev = 34;
2249
+ setLoading(false);
2250
+ return _context20.finish(34);
2251
+
2252
+ case 37:
2253
+ case "end":
2254
+ return _context20.stop();
2255
+ }
2256
+ }
2257
+ }, _callee20, null, [[0, 31, 34, 37]]);
2258
+ }));
2259
+
2260
+ return function validateAll(_x11) {
2261
+ return _ref25.apply(this, arguments);
2262
+ };
2263
+ }();
2264
+
2265
+ var getObservation = /*#__PURE__*/function () {
2266
+ var _ref26 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
2267
+ var response, parseData;
2268
+ return _regenerator.default.wrap(function _callee21$(_context21) {
2269
+ while (1) {
2270
+ switch (_context21.prev = _context21.next) {
2271
+ case 0:
2272
+ _context21.next = 2;
2273
+ return _axios.default.get("".concat(process.env.REACT_APP_READ_OBSERVATION, "?articleId=").concat(product.article.id_article, "&orderId=").concat(product === null || product === void 0 ? void 0 : product.orderId), {
2274
+ headers: {
2275
+ Authorization: sessionStorage.getItem("jwt")
2276
+ }
2277
+ });
2278
+
2279
+ case 2:
2280
+ response = _context21.sent;
2281
+ parseData = JSON.parse(response.data.body).data[0];
2282
+ setObservation(parseData.observations);
2283
+
2284
+ case 5:
2285
+ case "end":
2286
+ return _context21.stop();
2287
+ }
2288
+ }
2289
+ }, _callee21);
2290
+ }));
2291
+
2292
+ return function getObservation() {
2293
+ return _ref26.apply(this, arguments);
2294
+ };
2295
+ }();
2296
+
2297
+ (0, _react.useEffect)(function () {
2298
+ getObservation();
2299
+ }, []);
2300
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
2301
+ headerTop: headerTop,
2302
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
2303
+ setHeaderTop: setHeaderTop,
2304
+ auditableVersion: auditableVersion,
2305
+ setCompare: setCompare,
2306
+ isAuditor: [1, 6].includes(user.id_role),
2307
+ withChat: location === null || location === void 0 ? void 0 : (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.withChat,
2308
+ chatType: location === null || location === void 0 ? void 0 : (_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.chatType,
2309
+ productSelected: product,
2310
+ token: token,
2311
+ activeRetailer: activeRetailer
2312
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2313
+ className: "data-container",
2314
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2315
+ className: "image-data-panel",
2316
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagePreviewer.ImagePreviewer, {
2317
+ activeImage: images !== null && images !== void 0 && images.values ? images === null || images === void 0 ? void 0 : images.values[activeImage] : {},
2318
+ imagesArray: images,
2319
+ setActiveImage: setActiveImage,
2320
+ setShowModal: setShowModal
2321
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageDataTable.ImageDataTable, {
2322
+ lists: images,
2323
+ activeImage: images !== null && images !== void 0 && images.values ? images === null || images === void 0 ? void 0 : images.values[activeImage] : {},
2324
+ retailerSelected: activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id,
2325
+ setImages: setImages,
2326
+ assignationsImages: assig["Imágenes"],
2327
+ imagesStatus: product === null || product === void 0 ? void 0 : product.images_status,
2328
+ setAssignation: setAssignation,
2329
+ isRetailer: isRetailer,
2330
+ onClickSave: function onClickSave() {
2331
+ var _product$services;
2332
+
2333
+ return (product === null || product === void 0 ? void 0 : (_product$services = product.services) === null || _product$services === void 0 ? void 0 : _product$services.images) === 1 && updateImages();
2334
+ },
2335
+ showSaveButton: auditorAssigned() || userAssigned(),
2336
+ setShowVersionSelector: setShowVersionSelector,
2337
+ version: version,
2338
+ shotThd: shotThd
1587
2339
  })]
1588
2340
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1589
- className: "data-container",
1590
- style: {
1591
- display: "flex",
1592
- gap: "8px",
1593
- padding: "0 12px 12px"
1594
- },
1595
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1596
- className: "image-data-panel",
1597
- style: {
1598
- flex: "0 0 320px",
1599
- display: "flex",
1600
- flexDirection: "column",
1601
- gap: "20px"
2341
+ className: "product-information",
2342
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader, {
2343
+ headerData: product,
2344
+ productObservation: observation,
2345
+ percent: activePercentage,
2346
+ activeRetailer: activeRetailer,
2347
+ servicesData: servicesData,
2348
+ setActiveRetailer: setActiveRetailer,
2349
+ sendToFacilitator: sendToFacilitator,
2350
+ approve: function approve() {
2351
+ sendToFacilitator("A");
1602
2352
  },
1603
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1604
- variant: "rounded",
1605
- width: "100%",
1606
- height: 400
1607
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Stack, {
1608
- direction: "row",
1609
- spacing: 2,
1610
- justifyContent: "center",
1611
- children: [1, 2, 3, 4].map(function (item) {
1612
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1613
- variant: "rounded",
1614
- width: 60,
1615
- height: 80
1616
- }, item);
1617
- })
1618
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1619
- mt: 2,
1620
- children: [1, 2, 3, 4].map(function (item) {
1621
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1622
- display: "flex",
1623
- justifyContent: "space-between",
1624
- py: 1,
1625
- borderBottom: "1px solid #f0f0f0",
1626
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1627
- variant: "text",
1628
- width: "40%"
1629
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1630
- variant: "text",
1631
- width: "20%"
1632
- })]
1633
- }, item);
1634
- })
1635
- })]
1636
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1637
- className: "product-information",
1638
- style: {
1639
- flex: 1,
1640
- display: "flex",
1641
- flexDirection: "column",
1642
- gap: "14px"
2353
+ reject: function reject() {
2354
+ setShowRejectModal(true);
1643
2355
  },
1644
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1645
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1646
- variant: "text",
1647
- width: "80%",
1648
- height: 50
1649
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Stack, {
1650
- direction: "row",
1651
- spacing: 2,
1652
- alignItems: "center",
1653
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1654
- variant: "rounded",
1655
- width: 180,
1656
- height: 24
1657
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1658
- variant: "rounded",
1659
- width: 300,
1660
- height: 24
1661
- })]
1662
- })]
1663
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1664
- display: "flex",
1665
- gap: 4,
1666
- pb: 1,
1667
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1668
- variant: "text",
1669
- width: 140,
1670
- height: 45
1671
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1672
- variant: "text",
1673
- width: 140,
1674
- height: 45
1675
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1676
- variant: "text",
1677
- width: 140,
1678
- height: 45
2356
+ showApproveRejectAll: approveRejectAllButtons() && (auditorAssigned() || userAssigned()),
2357
+ showValidationButtons: approveRejectButtons() && (auditorAssigned() || userAssigned()),
2358
+ approveAll: function approveAll() {
2359
+ return validateAll("A");
2360
+ },
2361
+ rejectAll: function rejectAll() {
2362
+ setShowRejectModal(true);
2363
+ setValRejAll(true);
2364
+ },
2365
+ isObservationVisible: isObservationVisible,
2366
+ toggleObservation: toggleObservation // handleClickOutside={handleClickOutside}
2367
+ ,
2368
+ hideObservation: hideObservation
2369
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
2370
+ tabsSections: tabsSections,
2371
+ status: retailerStatus,
2372
+ activeTab: activeTab,
2373
+ setActiveTab: setActiveTab,
2374
+ setImageLayout: setImageLayout,
2375
+ downloadImages: downloadImages,
2376
+ askToDeleteImages: askToDeleteImages,
2377
+ assig: assig[activeTab],
2378
+ setAssignation: setAssignation,
2379
+ isRetailer: isRetailer,
2380
+ showSaveButton: auditorAssigned() || userAssigned(),
2381
+ version: version,
2382
+ desc: desc,
2383
+ setDesc: setDesc,
2384
+ fich: fich,
2385
+ setFich: setFich,
2386
+ imag: imag,
2387
+ setImag: setImag,
2388
+ updatedDescriptions: updatedDescriptions,
2389
+ setUpdatedDescriptions: setUpdatedDescriptions,
2390
+ updatedDatasheets: updatedDatasheets,
2391
+ setUpdatedDatasheets: setUpdatedDatasheets,
2392
+ images: images,
2393
+ setImages: setImages,
2394
+ selectedImages: selectedImages,
2395
+ setSelectedImages: setSelectedImages,
2396
+ setShowVersionSelector: setShowVersionSelector,
2397
+ onClickSave: function onClickSave() {
2398
+ switch (activeTab) {
2399
+ case "Descripción":
2400
+ !saving && (product === null || product === void 0 ? void 0 : product.description_status) !== "NS" && saveDescriptions();
2401
+ break;
2402
+
2403
+ case "Ficha técnica":
2404
+ !saving && (product === null || product === void 0 ? void 0 : product.datasheet_status) !== "NS" && saveDatasheets();
2405
+ break;
2406
+
2407
+ case "Imágenes":
2408
+ !saving && (product === null || product === void 0 ? void 0 : product.images_status) !== "NS" && updateImages();
2409
+ break;
2410
+
2411
+ default:
2412
+ break;
2413
+ }
2414
+ },
2415
+ canAssign: ![7, 8].includes(user.id_role)
2416
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2417
+ className: "services-information-container " + (imageLayout && activeTab === "Imágenes" ? "image-services" : ""),
2418
+ children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
2419
+ children: [!imageLayout && activeTab === "Imágenes" && (product === null || product === void 0 ? void 0 : (_product$services2 = product.services) === null || _product$services2 === void 0 ? void 0 : _product$services2.images) === 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {
2420
+ setSelectedImages: setSelectedImages,
2421
+ checkAll: checkAll,
2422
+ setCheckAll: setCheckAll,
2423
+ shotThd: shotThd
2424
+ }), activeTab === "Ficha técnica" && ((product === null || product === void 0 ? void 0 : product.datasheet_status) !== "NS" ? (_datasheets$ = datasheets[0]) === null || _datasheets$ === void 0 ? void 0 : (_datasheets$$data = _datasheets$.data) === null || _datasheets$$data === void 0 ? void 0 : _datasheets$$data.map(function (dataGroup, index) {
2425
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2426
+ articleId: product.article.id_article,
2427
+ version: version,
2428
+ activeSection: activeTab,
2429
+ inputGroup: dataGroup,
2430
+ dataInputs: datasheets[1],
2431
+ auditInputs: auditDatasheets[1],
2432
+ updatedDatasheets: updatedDatasheets,
2433
+ setUpdatedDatasheets: setUpdatedDatasheets,
2434
+ compare: compare
2435
+ }, index + "-" + activeRetailer.name);
2436
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2437
+ text: "No cuentas con este servicio",
2438
+ headerType: "input-name-header"
2439
+ })), activeTab === "Descripción" && ((product === null || product === void 0 ? void 0 : product.description_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2440
+ activeSection: activeTab,
2441
+ inputGroup: descriptions[0],
2442
+ auditInputGroup: auditDescriptions[0],
2443
+ updatedDescriptions: updatedDescriptions,
2444
+ setUpdatedDescriptions: setUpdatedDescriptions,
2445
+ articleId: product === null || product === void 0 ? void 0 : (_product$article22 = product.article) === null || _product$article22 === void 0 ? void 0 : _product$article22.id_article,
2446
+ version: version,
2447
+ dinamicHeight: true,
2448
+ compare: compare
2449
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2450
+ text: "No cuentas con este servicio",
2451
+ headerType: "input-name-header"
2452
+ })), activeTab === "Imágenes" && ((product === null || product === void 0 ? void 0 : product.images_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)("section", {
2453
+ className: "container",
2454
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getRootProps({
2455
+ className: "dropzone"
2456
+ })), {}, {
2457
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", (0, _objectSpread2.default)({}, getInputProps())), /*#__PURE__*/(0, _jsxRuntime.jsx)("aside", {
2458
+ children: thumbs()
2459
+ })]
2460
+ }))
2461
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2462
+ text: "No cuentas con este servicio",
2463
+ headerType: "input-name-header"
2464
+ }))]
2465
+ })
2466
+ }), (userAssigned(activeTab) || auditorAssigned()) && product["".concat(getConcept(activeTab), "_status")] !== "NS" && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2467
+ className: "commentary-box",
2468
+ children: [!comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2469
+ className: "commentary",
2470
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
2471
+ label: "Caja de Comentario",
2472
+ inputType: "textarea",
2473
+ inputCols: 80,
2474
+ inputRows: 4,
2475
+ inputId: "commentary-box",
2476
+ index: 0
2477
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2478
+ className: "buttons-box",
2479
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2480
+ buttonType: "general-transparent-button",
2481
+ label: "Enviar comentario",
2482
+ onClick: handleCommentSubmit
2483
+ })
1679
2484
  })]
1680
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1681
- display: "flex",
1682
- flexDirection: "column",
1683
- gap: 4,
1684
- children: [1, 2, 3].map(function (item) {
1685
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1686
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1687
- display: "flex",
1688
- justifyContent: "space-between",
1689
- alignItems: "center",
1690
- mb: 1,
1691
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1692
- variant: "text",
1693
- width: "30%",
1694
- height: 24
1695
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1696
- variant: "rounded",
1697
- width: 175,
1698
- height: 25,
1699
- sx: {
1700
- borderRadius: "7.5px"
2485
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2486
+ className: "feedback-box",
2487
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Commentary.Commentary, {
2488
+ comment: comment === null || comment === void 0 ? void 0 : comment.message,
2489
+ reviewed: crossComment
2490
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2491
+ buttonType: "circular-button accept-button",
2492
+ onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
2493
+ return _regenerator.default.wrap(function _callee22$(_context22) {
2494
+ while (1) {
2495
+ switch (_context22.prev = _context22.next) {
2496
+ case 0:
2497
+ setCrossComment(true);
2498
+ commentRevised();
2499
+
2500
+ case 2:
2501
+ case "end":
2502
+ return _context22.stop();
1701
2503
  }
1702
- })]
1703
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1704
- variant: "rounded",
1705
- width: "100%",
1706
- height: 70
1707
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
1708
- display: "flex",
1709
- justifyContent: "flex-end",
1710
- mt: 0.5,
1711
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1712
- variant: "text",
1713
- width: 60
1714
- })
1715
- })]
1716
- }, item);
1717
- })
1718
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1719
- mt: "auto",
1720
- pt: 4,
1721
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1722
- variant: "rounded",
1723
- width: "100%",
1724
- height: 120
1725
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
1726
- display: "flex",
1727
- justifyContent: "flex-end",
1728
- gap: 2,
1729
- mt: 2,
1730
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1731
- variant: "rounded",
1732
- width: 180,
1733
- height: 45,
1734
- sx: {
1735
- borderRadius: "24px"
1736
- }
1737
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
1738
- variant: "rounded",
1739
- width: 180,
1740
- height: 45,
1741
- sx: {
1742
- borderRadius: "24px"
1743
- }
1744
- })]
2504
+ }
2505
+ }, _callee22);
2506
+ }))
1745
2507
  })]
2508
+ }), [7, 8].includes(user.id_role) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2509
+ buttonType: evaluationFinished(user.id_role, activeTab, statusArray) && requiredNull[activeTab] === 0 ? "general-green-button" : "general-button-disabled",
2510
+ label: "Enviar evaluación",
2511
+ onClick: function onClick() {
2512
+ return sendToFacilitator();
2513
+ }
1746
2514
  })]
1747
2515
  })]
1748
2516
  })]
1749
- });
1750
- };
1751
-
1752
- (0, _react.useEffect)(function () {
1753
- console.log({
1754
- stateProduct: state.product
1755
- });
1756
- }, [state.product]);
1757
- if (state.loading || !state.services || !state.product) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1758
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProductEditionSkeleton, {})
1759
- });
1760
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_AiProductEdition.AiProductEditionProvider, {
1761
- isCreatorsEdition: true,
1762
- user: user,
1763
- token: token,
1764
- state: state,
1765
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
1766
- headerTop: headerTop,
1767
- children: [showRejectModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.Modal, {
1768
- title: rejectAll ? "Agregar mensaje para rechazar todo" : "Agregar mensaje de rechazo",
1769
- show: showRejectModal,
1770
- customComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
1771
- inputType: "textarea",
1772
- inputId: "modal-message-box",
1773
- index: 0,
1774
- color: "white"
1775
- }),
1776
- buttons: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.ButtonV2, {
1777
- type: "white",
1778
- label: "Cancelar",
1779
- size: 12,
1780
- onClick: function onClick() {
1781
- setShowRejectModal(false);
1782
- }
1783
- }, "btn-Cancelar"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.ButtonV2, {
1784
- type: "pink",
1785
- label: "Aceptar",
1786
- size: 12,
1787
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
1788
- var elements, isMessageEmpty, container, existingAlert, alert, fullMessage;
1789
- return _regenerator.default.wrap(function _callee12$(_context12) {
2517
+ }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductImageModal.ProductImageModal, {
2518
+ images: images,
2519
+ setShowModal: setShowModal,
2520
+ sendToFacilitator: sendToFacilitator,
2521
+ approveRejectButtons: approveRejectButtons()
2522
+ }), message.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GenericModal.GenericModal, {
2523
+ buttonType: componentsArray.length > 0 && "delete-product",
2524
+ componentsArray: componentsArray.length > 0 ? componentsArray : [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
2525
+ src: _genericModalCheck.default,
2526
+ alt: "success icon"
2527
+ }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2528
+ headerType: "retailer-name-header",
2529
+ text: message,
2530
+ color: "white"
2531
+ }, "2")],
2532
+ onClick: function onClick() {
2533
+ return setMessage("");
2534
+ }
2535
+ }), showVersionSelector && /*#__PURE__*/(0, _jsxRuntime.jsx)(_VersionSelector.VersionSelector, {
2536
+ modalId: "version-selector",
2537
+ articleId: product.article.id_article,
2538
+ setVersion: setVersion,
2539
+ companyName: product.article.company_name,
2540
+ currentVersion: version,
2541
+ setShowVersionSelector: setShowVersionSelector,
2542
+ jwt: token
2543
+ }), showRejectModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.Modal, {
2544
+ title: "Agregar mensaje de rechazo para ".concat(activeTab === null || activeTab === void 0 ? void 0 : activeTab.toLowerCase()),
2545
+ show: showRejectModal,
2546
+ customComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
2547
+ inputType: "textarea",
2548
+ inputId: "modal-message-box",
2549
+ index: 0,
2550
+ color: "white"
2551
+ }),
2552
+ buttons: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.ButtonV2, {
2553
+ type: "white",
2554
+ label: "Cancelar",
2555
+ size: 12,
2556
+ onClick: function onClick() {
2557
+ setShowRejectModal(false);
2558
+ }
2559
+ }, "btn-Cancelar"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.ButtonV2, {
2560
+ type: "pink",
2561
+ label: "Aceptar",
2562
+ size: 12,
2563
+ onClick: /*#__PURE__*/function () {
2564
+ var _ref28 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23(e) {
2565
+ var elements, brCounter, container, existingAlert, alert, fullMessage;
2566
+ return _regenerator.default.wrap(function _callee23$(_context23) {
1790
2567
  while (1) {
1791
- switch (_context12.prev = _context12.next) {
2568
+ switch (_context23.prev = _context23.next) {
1792
2569
  case 0:
1793
2570
  elements = document.querySelectorAll("#modal-message-box .ql-container .ql-editor > p");
1794
2571
 
1795
2572
  if (!(!elements || elements.length === 0)) {
1796
- _context12.next = 4;
2573
+ _context23.next = 4;
1797
2574
  break;
1798
2575
  }
1799
2576
 
1800
2577
  console.error("Elemento no encontrado");
1801
- return _context12.abrupt("return");
2578
+ return _context23.abrupt("return");
1802
2579
 
1803
2580
  case 4:
1804
- isMessageEmpty = Array.from(elements).every(function (el) {
2581
+ brCounter = 0;
2582
+ elements.forEach(function (el) {
1805
2583
  var body = el.innerHTML;
1806
- return !body || body.replace(/<.*?\/?>/gm, "").trim() === "";
2584
+
2585
+ if (typeof body !== "string") {
2586
+ console.log("El contenido de body no es una cadena", body);
2587
+ isMessageEmpty = true;
2588
+ return;
2589
+ }
2590
+
2591
+ if (!body || body.replace(/<.*?\/?>/gm, "").trim() === "") {
2592
+ brCounter++;
2593
+ }
1807
2594
  });
1808
2595
 
1809
- if (!isMessageEmpty) {
1810
- _context12.next = 10;
2596
+ if (!(brCounter === elements.length)) {
2597
+ _context23.next = 17;
1811
2598
  break;
1812
2599
  }
1813
2600
 
@@ -1815,354 +2602,65 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
1815
2602
  existingAlert = container.querySelector(".alert-error");
1816
2603
 
1817
2604
  if (!existingAlert) {
1818
- alert = document.createElement("div");
1819
- alert.className = "alert-error";
1820
- alert.style.cssText = "\n color: #d32f2f;\n background-color: #ffebee;\n border: 1px solid #ef5350;\n border-radius: 4px;\n padding: 12px 16px;\n margin-top: 10px;\n font-size: 14px;\n display: flex;\n align-items: center;\n gap: 8px;\n font-family: 'Roboto', sans-serif;\n text-align: center;\n ";
1821
- alert.innerHTML = "<span>El mensaje no puede estar vac\xEDo.</span>";
1822
- container.appendChild(alert);
2605
+ _context23.next = 11;
2606
+ break;
1823
2607
  }
1824
2608
 
1825
- return _context12.abrupt("return");
1826
-
1827
- case 10:
1828
- fullMessage = Array.from(elements).map(function (element) {
1829
- return element.innerHTML;
1830
- }).join("").replace(/<br\s*\/?>/gi, "\n");
1831
- _context12.next = 13;
1832
- return createComment(fullMessage, token);
2609
+ return _context23.abrupt("return");
2610
+
2611
+ case 11:
2612
+ // Crear alerta con estilos
2613
+ alert = document.createElement("div");
2614
+ alert.className = "alert-error";
2615
+ alert.style.cssText = "\n color: #d32f2f;\n background-color: #ffebee;\n border: 1px solid #ef5350;\n border-radius: 4px;\n padding: 12px 16px;\n margin-top: 10px;\n font-size: 14px;\n display: flex;\n align-items: center;\n gap: 8px;\n font-family: 'Roboto', sans-serif;\n text-align: center;\n ";
2616
+ alert.innerHTML = "\n <span>El mensaje no puede estar vac\xEDo.</span>\n ";
2617
+ container.appendChild(alert);
2618
+ return _context23.abrupt("return");
2619
+
2620
+ case 17:
2621
+ fullMessage = "";
2622
+ elements.forEach(function (element) {
2623
+ var body = element.innerHTML;
2624
+ fullMessage += body;
2625
+ });
2626
+ fullMessage = fullMessage.replace(/<br\s*\/?>/gi, "\n");
2627
+ _context23.next = 22;
2628
+ return createComment(e, fullMessage, activeTab);
1833
2629
 
1834
- case 13:
1835
- rejectAll ? sendBulkEvaluation("R") : sendSingleEvaluation("R");
2630
+ case 22:
2631
+ valRejAll ? validateAll("R") : sendToFacilitator("R");
2632
+ setMessage("Rechazado");
1836
2633
  setShowRejectModal(false);
1837
2634
 
1838
- case 15:
2635
+ case 25:
1839
2636
  case "end":
1840
- return _context12.stop();
2637
+ return _context23.stop();
1841
2638
  }
1842
2639
  }
1843
- }, _callee12);
1844
- }))
1845
- }, "btn-Aceptar")]
1846
- }), state.modal.show && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GenericModal.GenericModal, {
1847
- componentsArray: [state.modal.image && /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
1848
- src: state.modal.image,
1849
- alt: "modal icon"
1850
- }, "1"), state.modal.title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1851
- headerType: "retailer-name-header",
1852
- text: state.modal.title,
1853
- color: "white"
1854
- }, "2"), state.modal.message && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1855
- headerType: "retailer-name-header",
1856
- text: state.modal.message,
1857
- color: "white"
1858
- }, "3"), state.modal.buttons && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1859
- style: {
1860
- marginTop: "16px"
1861
- },
1862
- children: state.modal.buttons.map(function (button, index) {
1863
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1864
- buttonType: button.buttonType,
1865
- label: button.text,
1866
- onClick: button.action
1867
- }, index);
1868
- })
1869
- }, "4")].filter(Boolean),
1870
- onClick: function onClick() {
1871
- return dispatch({
1872
- type: "SET_MODAL",
1873
- payload: {
1874
- show: false,
1875
- title: "",
1876
- message: "",
1877
- image: null
1878
- }
2640
+ }, _callee23);
2641
+ }));
2642
+
2643
+ return function (_x12) {
2644
+ return _ref28.apply(this, arguments);
2645
+ };
2646
+ }()
2647
+ }, "btn-Aceptar")]
2648
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.Modal, {
2649
+ className: "container-modalAlert",
2650
+ show: modalAlert.show,
2651
+ title: modalAlert.title,
2652
+ message: modalAlert.message,
2653
+ icon: "info",
2654
+ onClickBtnDefault: function onClickBtnDefault(event) {
2655
+ setModalAlert(function (prev) {
2656
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, prev), {}, {
2657
+ show: false,
2658
+ errorInputMessage: false
1879
2659
  });
1880
- }
1881
- }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductImageModal.ProductImageModal, {
1882
- images: state.images_values,
1883
- setShowModal: setShowModal,
1884
- approveRejectButtons: canShowSingleEvaluationButtons(),
1885
- sendToFacilitator: handleOnSendEvaluationToFacilitator
1886
- }), showVersionSelector && /*#__PURE__*/(0, _jsxRuntime.jsx)(_VersionSelector.VersionSelector, {
1887
- modalId: "version-selector",
1888
- articleId: state.product.id_article,
1889
- setVersion: handleOnChangeProductVersion,
1890
- companyName: state.product.company,
1891
- currentVersion: state.product.version,
1892
- setShowVersionSelector: setShowVersionSelector,
1893
- jwt: token
1894
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
1895
- setHeaderTop: setHeaderTop,
1896
- auditableVersion: auditableVersion,
1897
- setCompare: setCompare,
1898
- isAuditor: [1, 6].includes(user.id_role),
1899
- withChat: location === null || location === void 0 ? void 0 : (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.withChat,
1900
- chatType: location === null || location === void 0 ? void 0 : (_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.chatType,
1901
- productSelected: state.product,
1902
- token: token,
1903
- activeRetailer: {
1904
- id: (_state$active_retaile4 = state.active_retailer) === null || _state$active_retaile4 === void 0 ? void 0 : _state$active_retaile4.id_retailer,
1905
- name: (_state$active_retaile5 = state.active_retailer) === null || _state$active_retaile5 === void 0 ? void 0 : _state$active_retaile5.retailer
1906
- }
1907
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1908
- className: "data-container",
1909
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1910
- className: "image-data-panel",
1911
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagePreviewer.ImagePreviewer, {
1912
- activeImage: (_state$images_values$2 = state.images_values.values[state.current_image]) !== null && _state$images_values$2 !== void 0 ? _state$images_values$2 : {},
1913
- imagesArray: state.images_values || [],
1914
- setActiveImage: handleOnChangeCurrentImage,
1915
- setShowModal: handleOnShowModalGallery
1916
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageDataTable.ImageDataTable // states
1917
- , {
1918
- lists: state.images_values || [],
1919
- 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] : {},
1920
- assignationsImages: state.collaborator_assignations["Imágenes"],
1921
- imagesStatus: ((_state$product8 = state.product) === null || _state$product8 === void 0 ? void 0 : _state$product8.images_status) || "-",
1922
- retailerSelected: (_state$active_retaile6 = state.active_retailer) === null || _state$active_retaile6 === void 0 ? void 0 : _state$active_retaile6.id_retailer,
1923
- isRetailer: isRetailer,
1924
- version: state.product.version,
1925
- shotThd: shotThd,
1926
- setShowVersionSelector: setShowVersionSelector // actions
1927
- ,
1928
- setImages: handleOnChangeCurrentImage,
1929
- setAssignation: handleOnChangeAssignations // No se usa?
1930
- ,
1931
- onClickSave: handleOnClickSaveImages,
1932
- showSaveButton: isAuditorAssigned() || isUserAssignedToService()
1933
- })]
1934
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
1935
- className: "product-information",
1936
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader // states
1937
- , {
1938
- headerData: state.product,
1939
- productObservation: observation,
1940
- percent: state.active_percentage.percentagesGeneral.required,
1941
- activeRetailer: {
1942
- id: (_state$active_retaile7 = state.active_retailer) === null || _state$active_retaile7 === void 0 ? void 0 : _state$active_retaile7.id_retailer,
1943
- name: (_state$active_retaile8 = state.active_retailer) === null || _state$active_retaile8 === void 0 ? void 0 : _state$active_retaile8.retailer,
1944
- image: (_state$active_retaile9 = state.active_retailer) === null || _state$active_retaile9 === void 0 ? void 0 : _state$active_retaile9.image
1945
- },
1946
- servicesData: state.services_data ? state.services_data : null,
1947
- isObservationVisible: isObservationVisible // actions
1948
- ,
1949
- setActiveRetailer: handleOnChangeActiveRetailer,
1950
- approve: handleOnApproveSingleService,
1951
- approveAll: handleOnApproveAllServices,
1952
- reject: handleOnRejectSingleService,
1953
- rejectAll: handleOnRejectAllServices,
1954
- toggleObservation: handleOnToggleObservation,
1955
- hideObservation: handleOnHideObservation // sendToFacilitator={handleOnSendEvaluationToFacilitator} // No se usa?
1956
- // validations
1957
- ,
1958
- showApproveRejectAll: canShowBulkEvaluationButtons() || isAuditorAssigned() || isUserAssignedToService(),
1959
- showValidationButtons: canShowSingleEvaluationButtons() && (isAuditorAssigned() || isUserAssignedToService())
1960
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
1961
- tabsSections: tabsSections,
1962
- status: getStatusByCurrentServiceAndRetailer(),
1963
- activeTab: state.active_tab,
1964
- isRetailer: isRetailer,
1965
- assig: state.collaborator_assignations[state.active_tab],
1966
- version: state.product.version,
1967
- updatedDescriptions: state.updated_descriptions_inputs,
1968
- updatedDatasheets: state.updated_datasheets_inputs,
1969
- updatedImages: state.updated_images_values,
1970
- images: state.services.images // selectedImages={selectedImages} prop pasada asi: FullTabsMenu -> TabsMenu Pero en TabsMenu no se espera ninguna prop setSelectedImages
1971
- // setters
1972
- ,
1973
- setActiveTab: handleOnChangeActiveTab,
1974
- setImageLayout: handleOnToggleImageLayout,
1975
- setUpdatedDescriptions: handleOnSetUpdatedDescriptions,
1976
- setUpdatedDatasheets: handleOnSetUpdatedDatasheets,
1977
- setAssignation: handleOnSetAssignation // No se usa?
1978
- ,
1979
- setImages: handleOnSetImages // No se usa?
1980
- ,
1981
- setShowVersionSelector: setShowVersionSelector // setSelectedImages={setSelectedImages} prop pasada asi: FullTabsMenu -> TabsMenu Pero en TabsMenu no se espera ninguna prop setSelectedImages
1982
- // actions
1983
- ,
1984
- downloadImages: handleOnDownloadImages,
1985
- askToDeleteImages: handleOnAskToDeleteImages,
1986
- showSaveButton: isAuditorAssigned() || isUserAssignedToService(),
1987
- onClickSave: handleOnClickSave // validations
1988
- ,
1989
- canAssign: ![7, 8].includes(user.id_role)
1990
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
1991
- className: "services-information-container " + (imageLayout && state.active_tab === "Imágenes" ? "image-services" : ""),
1992
- id: "services-information-container",
1993
- children: state.saving ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1994
- children: [state.active_tab === "Descripción" && (((_state$product9 = state.product) === null || _state$product9 === void 0 ? void 0 : _state$product9.description_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
1995
- activeSection: state.active_tab,
1996
- inputGroup: state.descriptions_inputs[0],
1997
- updatedDescriptions: state.updated_descriptions_inputs,
1998
- articleId: (_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.id_article,
1999
- version: state.product.version,
2000
- auditInputGroup: auditDescriptions[0],
2001
- setUpdatedDescriptions: handleOnSetUpdatedDescriptions,
2002
- dinamicHeight: true,
2003
- compare: compare
2004
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2005
- text: "No cuentas con este servicio",
2006
- headerType: "input-name-header"
2007
- })), state.active_tab === "Ficha técnica" && (((_state$product11 = state.product) === null || _state$product11 === void 0 ? void 0 : _state$product11.datasheet_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
2008
- children: (_state$datasheets_inp = state.datasheets_inputs[0]) === null || _state$datasheets_inp === void 0 ? void 0 : (_state$datasheets_inp2 = _state$datasheets_inp.data) === null || _state$datasheets_inp2 === void 0 ? void 0 : _state$datasheets_inp2.map(function (dataGroup, index) {
2009
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2010
- articleId: state.product.id_article,
2011
- version: state.version,
2012
- activeSection: state.active_tab,
2013
- inputGroup: dataGroup,
2014
- dataInputs: state.datasheets_inputs[1],
2015
- auditInputs: auditDatasheets[1],
2016
- updatedDatasheets: state.updated_datasheets_inputs,
2017
- setUpdatedDatasheets: handleOnSetUpdatedDatasheets,
2018
- compare: compare
2019
- }, index + "-" + state.active_retailer.retailer);
2020
- })
2021
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2022
- text: "No cuentas con este servicio",
2023
- headerType: "input-name-header"
2024
- })), state.active_tab === "Imágenes" && (((_state$product12 = state.product) === null || _state$product12 === void 0 ? void 0 : _state$product12.images_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
2025
- children: [!imageLayout && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {
2026
- checkAll: state.all_image_checked // Determina si el checkbox "Seleccionar todo" está marcado
2027
- ,
2028
- setCheckAll: handleOnSetCheckAll // Toggler de true o false para el checkbox "Seleccionar todo"
2029
- ,
2030
- setSelectedImages: handleOnSetSelectedImages // shotThd={shotThd} // No se usa?
2031
-
2032
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("section", {
2033
- className: "container",
2034
- style: {
2035
- position: "relative"
2036
- },
2037
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread5.default)((0, _objectSpread5.default)({}, getRootProps({
2038
- className: "dropzone ".concat(isDragActive ? "drag-active" : "")
2039
- })), {}, {
2040
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", (0, _objectSpread5.default)({}, getInputProps())), isDragActive && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2041
- className: "drag-overlay",
2042
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2043
- children: "Suelta las im\xE1genes aqu\xED"
2044
- })
2045
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("aside", {
2046
- children: thumbs()
2047
- })]
2048
- })), ((_state$images_values12 = state.images_values) === null || _state$images_values12 === void 0 ? void 0 : _state$images_values12.values.length) === 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2049
- style: {
2050
- position: "absolute",
2051
- top: "50%",
2052
- left: "50%",
2053
- transform: "translate(-50%, -50%)",
2054
- textAlign: "center",
2055
- padding: "40px",
2056
- width: "80%",
2057
- maxWidth: "500px",
2058
- fontFamily: "Arial, sans-serif"
2059
- },
2060
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2061
- style: {
2062
- fontSize: "18px",
2063
- color: "#666",
2064
- marginBottom: "16px"
2065
- },
2066
- children: "Este producto no tiene im\xE1genes"
2067
- }), isAuditorAssigned() || isUserAssignedToService() ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
2068
- style: {
2069
- fontSize: "14px",
2070
- color: "#999",
2071
- marginBottom: "20px"
2072
- },
2073
- children: ["Arrastra las im\xE1genes aqu\xED o", " ", /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
2074
- onClick: open,
2075
- style: {
2076
- color: "#007bff",
2077
- cursor: "pointer",
2078
- textDecoration: "underline"
2079
- },
2080
- children: "haz clic para abrir el explorador de archivos"
2081
- })]
2082
- }) : null]
2083
- })]
2084
- })]
2085
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2086
- text: "No cuentas con este servicio",
2087
- headerType: "input-name-header"
2088
- }))]
2089
- })
2090
- }), (isUserAssignedToService(state.active_tab) || isAuditorAssigned()) && state.product["".concat((0, _utils.getConceptByTab)(state.active_tab), "_status")] !== "NS" && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2091
- className: "commentary-box",
2092
- children: [!state.comment ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2093
- className: "commentary",
2094
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
2095
- label: "Caja de Comentario",
2096
- inputType: "textarea",
2097
- inputCols: 80,
2098
- inputRows: 4,
2099
- inputId: "commentary-box",
2100
- index: 0
2101
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2102
- className: "buttons-box",
2103
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2104
- buttonType: "general-transparent-button",
2105
- label: "Enviar comentario",
2106
- onClick: handleOnSubmitComment
2107
- })
2108
- })]
2109
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2110
- className: "feedback-box",
2111
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Commentary.Commentary, {
2112
- comment: (_state$comment = state.comment) === null || _state$comment === void 0 ? void 0 : _state$comment.message,
2113
- reviewed: crossComment
2114
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2115
- buttonType: "circular-button accept-button",
2116
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
2117
- return _regenerator.default.wrap(function _callee13$(_context13) {
2118
- while (1) {
2119
- switch (_context13.prev = _context13.next) {
2120
- case 0:
2121
- setCrossComment(true);
2122
- commentRevised();
2123
-
2124
- case 2:
2125
- case "end":
2126
- return _context13.stop();
2127
- }
2128
- }
2129
- }, _callee13);
2130
- }))
2131
- })]
2132
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2133
- className: "action-buttons",
2134
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2135
- buttonType: "general-pink-button",
2136
- label: "Cambio de Estatus",
2137
- onClick: function onClick() {
2138
- return setOpenChangeStatusModal(true);
2139
- },
2140
- id: "button-change-status"
2141
- }), [7, 8].includes(user.id_role) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2142
- buttonType: isEvaluationFinished(user.id_role, state.active_tab, statusArray) && state.missing_required_fields[state.active_tab] === 0 ? "general-green-button" : "general-button-disabled",
2143
- label: "Enviar evaluación",
2144
- onClick: handleOnSendEvaluationToFacilitator
2145
- })]
2146
- })]
2147
- })]
2148
- })]
2149
- })]
2150
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChangeStatusModal.default, {
2151
- state: state,
2152
- open: openChangeStatusModal,
2153
- onClose: function onClose() {
2154
- setOpenChangeStatusModal(false);
2155
- },
2156
- reloadData: loadData,
2157
- token: token
2660
+ });
2661
+ }
2158
2662
  })]
2159
2663
  });
2160
2664
  };
2161
2665
 
2162
- var RetailerProductEdition = function RetailerProductEdition(props) {
2163
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_providerProductEdition.ProviderProductEditionProvider, {
2164
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RetailerProductEditionView, (0, _objectSpread5.default)({}, props))
2165
- });
2166
- };
2167
-
2168
2666
  exports.RetailerProductEdition = RetailerProductEdition;