contentoh-components-library 21.4.45 → 21.4.47

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 (34) hide show
  1. package/dist/components/molecules/BoxAttribute/index.js +2 -2
  2. package/dist/components/organisms/Box/index.js +44 -7
  3. package/dist/components/organisms/BoxOnboarding/index.js +37 -48
  4. package/dist/components/organisms/InputGroup/index.js +17 -19
  5. package/dist/components/pages/ProviderProductEdition/index.js +36 -16
  6. package/package.json +1 -1
  7. package/src/components/molecules/BoxAttribute/index.js +2 -2
  8. package/src/components/organisms/Box/index.js +1 -3
  9. package/src/components/organisms/BoxOnboarding/index.js +17 -12
  10. package/src/components/organisms/InputGroup/index.js +2 -2
  11. package/src/components/pages/ProviderProductEdition/index.js +25 -3
  12. package/src/components/pages/ProviderProductEdition/out.json +0 -0
  13. package/src/components/pages/ProviderProductEdition/out2.json +0 -0
  14. package/dist/assets/images/Icons/delete.svg +0 -8
  15. package/dist/assets/images/Icons/edit.svg +0 -3
  16. package/dist/components/molecules/ButtonsAssignation/ButtonsAssignation.stories.js +0 -34
  17. package/dist/components/molecules/ButtonsAssignation/index.js +0 -142
  18. package/dist/components/molecules/ButtonsAssignation/styles.js +0 -20
  19. package/dist/components/molecules/ButtonsEdition/ButtonsEdition.stories.js +0 -34
  20. package/dist/components/molecules/ButtonsEdition/index.js +0 -182
  21. package/dist/components/molecules/ButtonsEdition/styles.js +0 -24
  22. package/dist/components/molecules/ProductSkuStatus/ProductSkuStatus.stories.js +0 -64
  23. package/dist/components/molecules/ProductSkuStatus/index.js +0 -36
  24. package/dist/components/molecules/ProductSkuStatus/styles.js +0 -18
  25. package/dist/components/molecules/Validation/Validation.stories.js +0 -28
  26. package/dist/components/molecules/Validation/index.js +0 -77
  27. package/dist/components/molecules/Validation/styles.js +0 -18
  28. package/dist/components/organisms/BarButtons/BarButtons.stories.js +0 -30
  29. package/dist/components/organisms/BarButtons/index.js +0 -61
  30. package/dist/components/organisms/BarButtons/styles.js +0 -18
  31. package/dist/components/pages/ProviderProductEdition1/ProviderProductEdition.stories.js +0 -222
  32. package/dist/components/pages/ProviderProductEdition1/index.js +0 -2339
  33. package/dist/components/pages/ProviderProductEdition1/styles.js +0 -23
  34. package/src/components/organisms/BoxOnboarding/out.json +0 -1
@@ -1,2339 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ProviderProductEdition1 = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
17
-
18
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
19
-
20
- var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
21
-
22
- var _styles = require("./styles");
23
-
24
- var _HeaderTop = require("../../molecules/HeaderTop");
25
-
26
- var _ImagePreviewer = require("../../organisms/ImagePreviewer");
27
-
28
- var _ImageDataTable = require("../../organisms/ImageDataTable");
29
-
30
- var _FullProductNameHeader = require("../../organisms/FullProductNameHeader");
31
-
32
- var _FullTabsMenu = require("../../organisms/FullTabsMenu");
33
-
34
- var _InputGroup = require("../../organisms/InputGroup");
35
-
36
- var _react = require("react");
37
-
38
- var _GalleryElement = require("../../molecules/GalleryElement");
39
-
40
- var _fileSaver = require("file-saver");
41
-
42
- var _data = require("../../../global-files/data");
43
-
44
- var _GalleryHeader = require("../../molecules/GalleryHeader");
45
-
46
- var _ProductImageModal = require("../../organisms/ProductImageModal");
47
-
48
- var _reactDropzone = require("react-dropzone");
49
-
50
- var _axios = _interopRequireDefault(require("axios"));
51
-
52
- var _uuid = require("uuid");
53
-
54
- var _awsSdk = _interopRequireDefault(require("aws-sdk"));
55
-
56
- var _index = require("../../molecules/TagAndInput/index");
57
-
58
- var _GeneralButton = require("../../atoms/GeneralButton");
59
-
60
- var _Commentary = require("../../atoms/Commentary");
61
-
62
- var _GenericModal = require("../../atoms/GenericModal");
63
-
64
- var _ScreenHeader = require("../../atoms/ScreenHeader");
65
-
66
- var _Loading = require("../../atoms/Loading");
67
-
68
- var _genericModalCheck = _interopRequireDefault(require("../../../assets/images/genericModal/genericModalCheck.svg"));
69
-
70
- var _reactRouterDom = require("react-router-dom");
71
-
72
- var _defaultProfileImage = _interopRequireDefault(require("../../../assets/images/defaultImages/defaultProfileImage.svg"));
73
-
74
- var _errorModal = _interopRequireDefault(require("../../../assets/images/genericModal/errorModal.svg"));
75
-
76
- var _index2 = require("../../organisms/GlobalModal/index");
77
-
78
- var _SliderToolTip = require("../../atoms/SliderToolTip");
79
-
80
- var _infoIcon = _interopRequireDefault(require("../../../assets/images/sliderToolTip/infoIcon.svg"));
81
-
82
- var _slide = _interopRequireDefault(require("../../../assets/images/sliderToolTip/slide1.svg"));
83
-
84
- var _slide2 = _interopRequireDefault(require("../../../assets/images/sliderToolTip/slide2.svg"));
85
-
86
- var _slide3 = _interopRequireDefault(require("../../../assets/images/sliderToolTip/slide3.svg"));
87
-
88
- var _slide4 = _interopRequireDefault(require("../../../assets/images/sliderToolTip/slide4.svg"));
89
-
90
- var _slide5 = _interopRequireDefault(require("../../../assets/images/sliderToolTip/slide5.svg"));
91
-
92
- var _VersionSelector = require("../../organisms/VersionSelector");
93
-
94
- var _customHooks = require("../../../global-files/customHooks");
95
-
96
- var _utils = require("../RetailerProductEdition/utils");
97
-
98
- var _Modal = require("../../organisms/Modal");
99
-
100
- var _ButtonV = require("../../atoms/ButtonV2");
101
-
102
- var _jsxRuntime = require("react/jsx-runtime");
103
-
104
- var reducerImages = function reducerImages(state, action) {
105
- var _action$init, _action$init$inputsBy;
106
-
107
- var values = state.values,
108
- attrForImgs = state.attrForImgs,
109
- inputsByRetailer = state.inputsByRetailer;
110
-
111
- switch (action.action) {
112
- case "init":
113
- var newInputsByRetailer = {};
114
- 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) {
115
- inputs === null || inputs === void 0 ? void 0 : inputs.forEach(function (input) {
116
- if (!newInputsByRetailer["".concat(input.id_retailer)]) newInputsByRetailer["".concat(input.id_retailer)] = [];
117
- newInputsByRetailer["".concat(input.id_retailer)].push(input);
118
- });
119
- });
120
- inputsByRetailer = newInputsByRetailer;
121
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, action.init), {}, {
122
- inputsByRetailer: inputsByRetailer,
123
- valuesInitial: action.init.values,
124
- inputsInitial: action.init.inputs
125
- });
126
-
127
- case "addImg":
128
- values = [].concat((0, _toConsumableArray2.default)(values), [action.img]);
129
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
130
- values: values
131
- });
132
-
133
- case "changeImageInfo":
134
- values[action.index][action.attribute] = action.value;
135
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
136
- values: values
137
- });
138
-
139
- case "changeAttrValue":
140
- var index = attrForImgs.general.findIndex(function (f) {
141
- return f.id = action.id;
142
- });
143
-
144
- if (index !== -1) {
145
- attrForImgs.general[index].value = action.value;
146
- }
147
-
148
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
149
- attrForImgs: attrForImgs,
150
- values: values
151
- });
152
-
153
- case "deleteImage":
154
- values = values.filter(function (value) {
155
- return action.selectedImages.indexOf(value) === -1;
156
- });
157
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
158
- values: values
159
- });
160
-
161
- case "orderImages":
162
- {
163
- var _inputsByRetailer = state.inputsByRetailer,
164
- valuesInitial = state.valuesInitial,
165
- inputsInitial = state.inputsInitial,
166
- inputs = state.inputs;
167
-
168
- try {
169
- var _inputsByRetailer$act;
170
-
171
- var orderedImages = [];
172
- var imageIdArray = [];
173
- if (action !== null && action !== void 0 && action.retailerId && !_inputsByRetailer[action.retailerId]) _inputsByRetailer[action.retailerId] = [];
174
- action.retailerId && ((_inputsByRetailer$act = _inputsByRetailer[action.retailerId]) === null || _inputsByRetailer$act === void 0 ? void 0 : _inputsByRetailer$act.filter(function (input) {
175
- imageIdArray.push(input.id_image);
176
- valuesInitial.forEach(function (value) {
177
- if (value.image_id === input.id_image) orderedImages.push(value);
178
- });
179
- }));
180
- inputs = inputsInitial === null || inputsInitial === void 0 ? void 0 : inputsInitial.filter(function (input) {
181
- return imageIdArray.includes(input.id);
182
- });
183
- values = orderedImages.length > 0 ? orderedImages : [];
184
- } catch (error) {
185
- console.log(error);
186
- }
187
-
188
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, state), {}, {
189
- values: values,
190
- inputs: inputs
191
- });
192
- }
193
-
194
- default:
195
- return state;
196
- }
197
- };
198
-
199
- var S3_BUCKET = process.env.REACT_APP_IMAGES_BUCKET;
200
- var REGION = "us-east-1";
201
-
202
- _awsSdk.default.config.update({
203
- accessKeyId: process.env.REACT_APP_KUTS3,
204
- secretAccessKey: process.env.REACT_APP_AKUTS3
205
- });
206
-
207
- var myBucket = new _awsSdk.default.S3({
208
- params: {
209
- Bucket: S3_BUCKET
210
- },
211
- region: REGION
212
- });
213
-
214
- var ProviderProductEdition1 = function ProviderProductEdition1(_ref) {
215
- var _product$retailers, _product$retailersAva, _location$state4, _location$state5, _location$state6, _datasheets$, _datasheets$$data;
216
-
217
- var tabsSections = _ref.tabsSections,
218
- _ref$productSelected = _ref.productSelected,
219
- productSelected = _ref$productSelected === void 0 ? {} : _ref$productSelected,
220
- productToEdit = _ref.productToEdit,
221
- _ref$user = _ref.user,
222
- user = _ref$user === void 0 ? {} : _ref$user,
223
- _ref$location = _ref.location,
224
- location = _ref$location === void 0 ? {} : _ref$location,
225
- token = _ref.token,
226
- _ref$revision = _ref.revision,
227
- revision = _ref$revision === void 0 ? false : _ref$revision,
228
- setShowContentohRequestModal = _ref.setShowContentohRequestModal,
229
- showSurvey = _ref.showSurvey,
230
- company = _ref.company,
231
- addToCart = _ref.addToCart;
232
-
233
- var _useState = (0, _react.useState)("Descripción"),
234
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
235
- activeTab = _useState2[0],
236
- setActiveTab = _useState2[1];
237
-
238
- var _useState3 = (0, _react.useState)(),
239
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
240
- activeImage = _useState4[0],
241
- setActiveImage = _useState4[1];
242
-
243
- var _useState5 = (0, _react.useState)(false),
244
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
245
- imageLayout = _useState6[0],
246
- setImageLayout = _useState6[1];
247
-
248
- var _useState7 = (0, _react.useState)(0),
249
- _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
250
- headerTop = _useState8[0],
251
- setHeaderTop = _useState8[1];
252
-
253
- var _useState9 = (0, _react.useState)([]),
254
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
255
- descriptions = _useState10[0],
256
- setDescriptions = _useState10[1];
257
-
258
- var _useState11 = (0, _react.useState)([]),
259
- _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
260
- datasheets = _useState12[0],
261
- setDatasheets = _useState12[1];
262
-
263
- var _useReducer = (0, _react.useReducer)(reducerImages, {}),
264
- _useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
265
- images = _useReducer2[0],
266
- setImages = _useReducer2[1];
267
-
268
- var _useState13 = (0, _react.useState)(false),
269
- _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
270
- showModal = _useState14[0],
271
- setShowModal = _useState14[1];
272
-
273
- var _useDropzone = (0, _reactDropzone.useDropzone)({
274
- accept: "image/*",
275
- noKeyboard: true,
276
- multiple: true,
277
- noClick: true,
278
- onDrop: function onDrop(acceptedFiles) {
279
- var newImages = [];
280
- acceptedFiles.map(function (file) {
281
- var reader = new FileReader();
282
- reader.fileName = file.name;
283
-
284
- reader.onload = /*#__PURE__*/function () {
285
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(e) {
286
- var ext, img;
287
- return _regenerator.default.wrap(function _callee$(_context) {
288
- while (1) {
289
- switch (_context.prev = _context.next) {
290
- case 0:
291
- ext = e.srcElement.fileName.split(".");
292
- img = new Image();
293
- img.src = e.target.result;
294
- setTimeout(function () {
295
- var width = img.width;
296
- var height = img.height;
297
- var newImg = {
298
- action: "addImg",
299
- img: {
300
- src: e.target.result,
301
- name: e.target.fileName,
302
- ext: ext[ext.length - 1],
303
- width: width,
304
- height: height
305
- }
306
- };
307
- setImages(newImg);
308
- }, 500);
309
-
310
- case 4:
311
- case "end":
312
- return _context.stop();
313
- }
314
- }
315
- }, _callee);
316
- }));
317
-
318
- return function (_x) {
319
- return _ref2.apply(this, arguments);
320
- };
321
- }();
322
-
323
- reader.onerror = function (error) {
324
- console.log("dropzoneError: ", error);
325
- };
326
-
327
- reader.readAsDataURL(file);
328
- return file;
329
- });
330
- }
331
- }),
332
- getRootProps = _useDropzone.getRootProps,
333
- getInputProps = _useDropzone.getInputProps;
334
-
335
- var _useState15 = (0, _react.useState)([]),
336
- _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
337
- updatedDatasheets = _useState16[0],
338
- setUpdatedDatasheets = _useState16[1];
339
-
340
- var _useState17 = (0, _react.useState)([]),
341
- _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
342
- updatedDescriptions = _useState18[0],
343
- setUpdatedDescriptions = _useState18[1];
344
-
345
- var _useState19 = (0, _react.useState)(false),
346
- _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
347
- imagesUploaded = _useState20[0],
348
- setImagesUploaded = _useState20[1];
349
-
350
- var _useState21 = (0, _react.useState)(),
351
- _useState22 = (0, _slicedToArray2.default)(_useState21, 2),
352
- dataImages = _useState22[0],
353
- setDataImages = _useState22[1];
354
-
355
- var _useState23 = (0, _react.useState)(product !== null && product !== void 0 && product.retailers ? new Array(product === null || product === void 0 ? void 0 : (_product$retailers = product.retailers) === null || _product$retailers === void 0 ? void 0 : _product$retailers.length).fill({
356
- percentage: 0
357
- }) : new Array(product === null || product === void 0 ? void 0 : (_product$retailersAva = product.retailersAvailable) === null || _product$retailersAva === void 0 ? void 0 : _product$retailersAva.length).fill({
358
- percentage: 0
359
- })),
360
- _useState24 = (0, _slicedToArray2.default)(_useState23, 2),
361
- percentages = _useState24[0],
362
- setPercentages = _useState24[1];
363
-
364
- var _useState25 = (0, _react.useState)(0),
365
- _useState26 = (0, _slicedToArray2.default)(_useState25, 2),
366
- activePercentage = _useState26[0],
367
- setActivePercentage = _useState26[1];
368
-
369
- var _useState27 = (0, _react.useState)({}),
370
- _useState28 = (0, _slicedToArray2.default)(_useState27, 2),
371
- activeRetailer = _useState28[0],
372
- setActiveRetailer = _useState28[1];
373
-
374
- var _useState29 = (0, _react.useState)([]),
375
- _useState30 = (0, _slicedToArray2.default)(_useState29, 2),
376
- services = _useState30[0],
377
- setServices = _useState30[1];
378
-
379
- var _useState31 = (0, _react.useState)([]),
380
- _useState32 = (0, _slicedToArray2.default)(_useState31, 2),
381
- servicesData = _useState32[0],
382
- setServicesData = _useState32[1];
383
-
384
- var _useState33 = (0, _react.useState)(""),
385
- _useState34 = (0, _slicedToArray2.default)(_useState33, 2),
386
- message = _useState34[0],
387
- setMessage = _useState34[1];
388
-
389
- var _useState35 = (0, _react.useState)(JSON.parse(sessionStorage.getItem("productSelected")) ? JSON.parse(sessionStorage.getItem("productSelected")) : productSelected),
390
- _useState36 = (0, _slicedToArray2.default)(_useState35, 2),
391
- product = _useState36[0],
392
- setProduct = _useState36[1];
393
-
394
- var _useState37 = (0, _react.useState)(JSON.parse(sessionStorage.getItem("productEdit")) ? JSON.parse(sessionStorage.getItem("productEdit")) : productToEdit),
395
- _useState38 = (0, _slicedToArray2.default)(_useState37, 2),
396
- productEdit = _useState38[0],
397
- setProductEdit = _useState38[1];
398
-
399
- var _useState39 = (0, _react.useState)(product === null || product === void 0 ? void 0 : product.version),
400
- _useState40 = (0, _slicedToArray2.default)(_useState39, 2),
401
- version = _useState40[0],
402
- setVersion = _useState40[1];
403
-
404
- var _useState41 = (0, _react.useState)({}),
405
- _useState42 = (0, _slicedToArray2.default)(_useState41, 1),
406
- comments = _useState42[0];
407
-
408
- var _useState43 = (0, _react.useState)(""),
409
- _useState44 = (0, _slicedToArray2.default)(_useState43, 2),
410
- comment = _useState44[0],
411
- setComment = _useState44[1];
412
-
413
- var _useState45 = (0, _react.useState)(false),
414
- _useState46 = (0, _slicedToArray2.default)(_useState45, 2),
415
- crossComment = _useState46[0],
416
- setCrossComment = _useState46[1];
417
-
418
- var _useState47 = (0, _react.useState)([]),
419
- _useState48 = (0, _slicedToArray2.default)(_useState47, 2),
420
- userGroups = _useState48[0],
421
- setUserGroups = _useState48[1];
422
-
423
- var _useState49 = (0, _react.useState)({}),
424
- _useState50 = (0, _slicedToArray2.default)(_useState49, 2),
425
- assig = _useState50[0],
426
- setAssig = _useState50[1];
427
-
428
- var _useState51 = (0, _react.useState)([]),
429
- _useState52 = (0, _slicedToArray2.default)(_useState51, 2),
430
- selectedImages = _useState52[0],
431
- setSelectedImages = _useState52[1];
432
-
433
- var _useState53 = (0, _react.useState)([]),
434
- _useState54 = (0, _slicedToArray2.default)(_useState53, 2),
435
- componentsArray = _useState54[0],
436
- setComponentsArray = _useState54[1];
437
-
438
- var _useState55 = (0, _react.useState)(false),
439
- _useState56 = (0, _slicedToArray2.default)(_useState55, 2),
440
- checkAll = _useState56[0],
441
- setCheckAll = _useState56[1];
442
-
443
- var isRetailer = user === null || user === void 0 ? void 0 : user.is_retailer;
444
-
445
- var _useState57 = (0, _react.useState)(true),
446
- _useState58 = (0, _slicedToArray2.default)(_useState57, 2),
447
- loading = _useState58[0],
448
- setLoading = _useState58[1];
449
-
450
- var _useState59 = (0, _react.useState)(false),
451
- _useState60 = (0, _slicedToArray2.default)(_useState59, 2),
452
- validatedAll = _useState60[0],
453
- setValidatedAll = _useState60[1];
454
-
455
- var _useState61 = (0, _react.useState)(false),
456
- _useState62 = (0, _slicedToArray2.default)(_useState61, 2),
457
- showRejectModal = _useState62[0],
458
- setShowRejectModal = _useState62[1];
459
-
460
- var _useState63 = (0, _react.useState)({
461
- "Ficha técnica": null,
462
- Descripción: null,
463
- Imágenes: null
464
- }),
465
- _useState64 = (0, _slicedToArray2.default)(_useState63, 2),
466
- origin = _useState64[0],
467
- setOrigin = _useState64[1];
468
-
469
- var _useState65 = (0, _react.useState)(false),
470
- _useState66 = (0, _slicedToArray2.default)(_useState65, 2),
471
- inCart = _useState66[0],
472
- setInCart = _useState66[1];
473
-
474
- var _useState67 = (0, _react.useState)({
475
- message: "¿Estás seguro de continuar?",
476
- detail: " ".concat(user.is_retailer ? "Asegurate de haber revisado las tres secciones" : "Envíar el producto a la cadena"),
477
- button1: {
478
- name: "Cerrar",
479
- action: closeGlobalModal
480
- },
481
- button2: {
482
- name: "Continuar",
483
- action: function action() {
484
- return evaluationToRetailer(false);
485
- }
486
- },
487
- img: _defaultProfileImage.default
488
- }),
489
- _useState68 = (0, _slicedToArray2.default)(_useState67, 2),
490
- dataGenericModal = _useState68[0],
491
- setDataGenericModal = _useState68[1];
492
-
493
- var _useState69 = (0, _react.useState)(null),
494
- _useState70 = (0, _slicedToArray2.default)(_useState69, 2),
495
- socketType = _useState70[0],
496
- setSocketType = _useState70[1];
497
-
498
- var _useState71 = (0, _react.useState)(loading),
499
- _useState72 = (0, _slicedToArray2.default)(_useState71, 2),
500
- saving = _useState72[0],
501
- setSaving = _useState72[1];
502
-
503
- var _useState73 = (0, _react.useState)(product.statusByRetailer),
504
- _useState74 = (0, _slicedToArray2.default)(_useState73, 2),
505
- retailerStatus = _useState74[0],
506
- setRetailerStatus = _useState74[1];
507
-
508
- var _useCloseModal = (0, _customHooks.useCloseModal)("version-selector"),
509
- _useCloseModal2 = (0, _slicedToArray2.default)(_useCloseModal, 2),
510
- showVersionSelector = _useCloseModal2[0],
511
- setShowVersionSelector = _useCloseModal2[1];
512
-
513
- var _useState75 = (0, _react.useState)(),
514
- _useState76 = (0, _slicedToArray2.default)(_useState75, 2),
515
- globalModal = _useState76[0],
516
- setGlobalModal = _useState76[1];
517
-
518
- var updateAuditStatus = /*#__PURE__*/function () {
519
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(status) {
520
- var productTemp, retailerStatusCopy, conceptArray;
521
- return _regenerator.default.wrap(function _callee2$(_context2) {
522
- while (1) {
523
- switch (_context2.prev = _context2.next) {
524
- case 0:
525
- productTemp = product;
526
- productTemp.article_status = status;
527
- productTemp.datasheet_status = status;
528
- productTemp.description_status = status;
529
- productTemp.images_status = status;
530
- retailerStatusCopy = (0, _objectSpread3.default)({}, retailerStatus);
531
- conceptArray = ["description", "datasheet", "images"];
532
- Object.keys(retailerStatusCopy).forEach(function (key) {
533
- conceptArray.forEach(function (concept) {
534
- if (retailerStatusCopy[key][concept]) {
535
- retailerStatusCopy[key][concept] = status;
536
- }
537
- });
538
- });
539
- setRetailerStatus(retailerStatusCopy);
540
- productTemp.statusByRetailer = retailerStatusCopy;
541
- setProduct(productTemp);
542
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
543
- setProductEdit({
544
- ArticleId: productTemp.id_article,
545
- idCategory: productTemp.article.id_category,
546
- product: productTemp
547
- });
548
- sessionStorage.setItem("productEdit", JSON.stringify({
549
- ArticleId: productTemp.id_article,
550
- idCategory: productTemp.article.id_category,
551
- product: productTemp
552
- }));
553
- _context2.next = 16;
554
- return loadData();
555
-
556
- case 16:
557
- case "end":
558
- return _context2.stop();
559
- }
560
- }
561
- }, _callee2);
562
- }));
563
-
564
- return function updateAuditStatus(_x2) {
565
- return _ref3.apply(this, arguments);
566
- };
567
- }();
568
-
569
- var addCart = /*#__PURE__*/function () {
570
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(retailers) {
571
- var article, version, articleToOrder, modatlType, resCart;
572
- return _regenerator.default.wrap(function _callee3$(_context3) {
573
- while (1) {
574
- switch (_context3.prev = _context3.next) {
575
- case 0:
576
- article = product.article, version = product.version;
577
- articleToOrder = [{
578
- articleId: article.id_article,
579
- version: version,
580
- userId: user.id_user,
581
- discount: 0,
582
- subtotal: 0,
583
- companyId: user.id_company,
584
- datasheet: retailers,
585
- description: retailers,
586
- image: retailers,
587
- attributeTranslations: false,
588
- descriptionTranslations: false,
589
- build: "[]",
590
- manual: "[]",
591
- userCreated: user.id_user
592
- }];
593
- modatlType = "addedToCartError";
594
-
595
- if (!addToCart) {
596
- _context3.next = 8;
597
- break;
598
- }
599
-
600
- _context3.next = 6;
601
- return addToCart({
602
- data: articleToOrder
603
- });
604
-
605
- case 6:
606
- resCart = _context3.sent;
607
-
608
- if (resCart.data.statusCode === 200) {
609
- modatlType = "addedToCart";
610
- }
611
-
612
- case 8:
613
- showGlobalModal(modatlType);
614
-
615
- case 9:
616
- case "end":
617
- return _context3.stop();
618
- }
619
- }
620
- }, _callee3);
621
- }));
622
-
623
- return function addCart(_x3) {
624
- return _ref4.apply(this, arguments);
625
- };
626
- }();
627
-
628
- var closeGlobalModal = function closeGlobalModal() {
629
- return setGlobalModal();
630
- };
631
-
632
- var seenByProvider = /*#__PURE__*/function () {
633
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
634
- var _productTemp$id_order;
635
-
636
- var productTemp, articleId, orderId, promises, conceptArray;
637
- return _regenerator.default.wrap(function _callee4$(_context4) {
638
- while (1) {
639
- switch (_context4.prev = _context4.next) {
640
- case 0:
641
- productTemp = product;
642
- articleId = productTemp.id_article;
643
- orderId = (_productTemp$id_order = productTemp.id_order) !== null && _productTemp$id_order !== void 0 ? _productTemp$id_order : productTemp.orderId;
644
- promises = [];
645
- conceptArray = ["description", "datasheet", "images"];
646
- conceptArray.forEach(function (concept) {
647
- var sectionStatusKey = "".concat(concept, "_status");
648
- var evalStatus = product[sectionStatusKey] || (product === null || product === void 0 ? void 0 : product.version_status);
649
- var data = {
650
- articleId: articleId,
651
- orderId: orderId,
652
- concept: concept,
653
- evalStatus: evalStatus
654
- };
655
- promises.push(_axios.default.put("".concat(process.env.REACT_APP_SEND_EVAL), data, {
656
- headers: {
657
- Authorization: token
658
- }
659
- }));
660
- });
661
- _context4.next = 8;
662
- return Promise.all(promises);
663
-
664
- case 8:
665
- closeGlobalModal();
666
- _context4.next = 11;
667
- return updateAuditStatus("FAP");
668
-
669
- case 11:
670
- case "end":
671
- return _context4.stop();
672
- }
673
- }
674
- }, _callee4);
675
- }));
676
-
677
- return function seenByProvider() {
678
- return _ref5.apply(this, arguments);
679
- };
680
- }();
681
-
682
- var showGlobalModal = (0, _react.useCallback)(function (type) {
683
- var formatter = new Intl.ListFormat("es", {
684
- type: "conjunction"
685
- });
686
-
687
- switch (type) {
688
- case "generic":
689
- setGlobalModal(dataGenericModal);
690
- break;
691
-
692
- case "commentsSent":
693
- setGlobalModal({
694
- message: "Gracias, tus comentarios fueron entregados.",
695
- detail: "Trabajaremos en conjunto para resolverlo.",
696
- button1: {
697
- name: "Cerrar",
698
- action: closeGlobalModal
699
- },
700
- img: _defaultProfileImage.default,
701
- textArea: false
702
- });
703
- break;
704
-
705
- case "RAC":
706
- var servicesRejected = [];
707
- var translateServices = {
708
- datasheet: "ficha técnica",
709
- description: "descripción",
710
- images: "imágenes"
711
- };
712
- Object.keys(translateServices).forEach(function (service) {
713
- if (product["".concat(service, "_status")] === "RAC") {
714
- servicesRejected.push(translateServices[service]);
715
- }
716
- });
717
- var plural = ["Los servicios", "cumplen"];
718
- var singular = ["El servicio", "cumple"];
719
- var grammar = servicesRejected.length > 1 ? plural : singular;
720
- var formatted = formatter.format(servicesRejected);
721
- var text1 = "".concat(grammar[0], " de ").concat(formatted, " no ").concat(grammar[1], " con lo que la cadena necesita.");
722
- var text2 = "\xA1Solicita el servicio de Content-oh! para completarlo!";
723
- var retailers = product.retailersWithService.map(function (retailer) {
724
- return Number(retailer);
725
- });
726
- setGlobalModal({
727
- message: "Tu producto no cumple con los requerimientos de la cadena",
728
- customComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
729
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
730
- className: "generic-text",
731
- children: [text1, /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), text2]
732
- })
733
- }),
734
- button1: {
735
- name: "Continuar",
736
- action: function () {
737
- var _action = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
738
- return _regenerator.default.wrap(function _callee5$(_context5) {
739
- while (1) {
740
- switch (_context5.prev = _context5.next) {
741
- case 0:
742
- _context5.next = 2;
743
- return seenByProvider();
744
-
745
- case 2:
746
- return _context5.abrupt("return", _context5.sent);
747
-
748
- case 3:
749
- case "end":
750
- return _context5.stop();
751
- }
752
- }
753
- }, _callee5);
754
- }));
755
-
756
- function action() {
757
- return _action.apply(this, arguments);
758
- }
759
-
760
- return action;
761
- }()
762
- },
763
- button2: {
764
- name: "Solicitar a Content-oh!",
765
- action: function () {
766
- var _action2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
767
- return _regenerator.default.wrap(function _callee6$(_context6) {
768
- while (1) {
769
- switch (_context6.prev = _context6.next) {
770
- case 0:
771
- _context6.next = 2;
772
- return addCart(retailers);
773
-
774
- case 2:
775
- _context6.next = 4;
776
- return seenByProvider();
777
-
778
- case 4:
779
- case "end":
780
- return _context6.stop();
781
- }
782
- }
783
- }, _callee6);
784
- }));
785
-
786
- function action() {
787
- return _action2.apply(this, arguments);
788
- }
789
-
790
- return action;
791
- }()
792
- },
793
- img: _errorModal.default
794
- });
795
- break;
796
-
797
- case "AAC":
798
- setGlobalModal({
799
- message: "Felicidades",
800
- detail: "Tu producto cumple con los requerimientos de la cadena.",
801
- button1: {
802
- name: "Continuar",
803
- action: function () {
804
- var _action3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
805
- return _regenerator.default.wrap(function _callee7$(_context7) {
806
- while (1) {
807
- switch (_context7.prev = _context7.next) {
808
- case 0:
809
- _context7.next = 2;
810
- return seenByProvider();
811
-
812
- case 2:
813
- return _context7.abrupt("return", _context7.sent);
814
-
815
- case 3:
816
- case "end":
817
- return _context7.stop();
818
- }
819
- }
820
- }, _callee7);
821
- }));
822
-
823
- function action() {
824
- return _action3.apply(this, arguments);
825
- }
826
-
827
- return action;
828
- }()
829
- },
830
- img: _defaultProfileImage.default
831
- });
832
- break;
833
-
834
- case "addedToCartError":
835
- setGlobalModal({
836
- detail: "Parece que algo salió mal al intentar añadir tu producto a tu carrito.",
837
- button1: {
838
- name: "Continuar",
839
- action: closeGlobalModal
840
- }
841
- });
842
- break;
843
-
844
- case "addedToCart":
845
- setGlobalModal({
846
- message: "Producto añadido",
847
- detail: "Tu producto se añadió al carrito de compras.",
848
- button1: {
849
- name: "Continuar",
850
- action: closeGlobalModal
851
- },
852
- img: _defaultProfileImage.default
853
- });
854
- break;
855
-
856
- default:
857
- closeGlobalModal();
858
- break;
859
- }
860
- }, [activeTab, dataGenericModal, product]);
861
- (0, _react.useEffect)(function () {
862
- checkAll && setSelectedImages(images.values);
863
- }, [checkAll]);
864
- (0, _react.useEffect)(function () {
865
- if (showModal) {
866
- setActiveTab("Imágenes");
867
- }
868
- }, [showModal]);
869
- (0, _react.useEffect)(function () {
870
- var _location$state, _location$state2, _location$state3;
871
-
872
- setOrigin({
873
- "Ficha técnica": location === null || location === void 0 ? void 0 : (_location$state = location.state) === null || _location$state === void 0 ? void 0 : _location$state.origin,
874
- Descripción: location === null || location === void 0 ? void 0 : (_location$state2 = location.state) === null || _location$state2 === void 0 ? void 0 : _location$state2.origin,
875
- Imágenes: location === null || location === void 0 ? void 0 : (_location$state3 = location.state) === null || _location$state3 === void 0 ? void 0 : _location$state3.origin
876
- });
877
- }, [location === null || location === void 0 ? void 0 : (_location$state4 = location.state) === null || _location$state4 === void 0 ? void 0 : _location$state4.origin]);
878
-
879
- var loadData = /*#__PURE__*/function () {
880
- var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
881
- var _product$article, _product$article2, _product$article3, _services$, _services$$values;
882
-
883
- var services;
884
- return _regenerator.default.wrap(function _callee8$(_context8) {
885
- while (1) {
886
- switch (_context8.prev = _context8.next) {
887
- case 0:
888
- _context8.next = 2;
889
- return (0, _data.getRetailerServices)((product === null || product === void 0 ? void 0 : product.id_article) || (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.company_name) || (product === null || product === void 0 ? void 0 : product.categoryName), parseInt((product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_category) || (product === null || product === void 0 ? void 0 : product.id_category)), version, token);
890
-
891
- case 2:
892
- services = _context8.sent;
893
- //Converts the data inside the datasheets object to array
894
- setServices(services);
895
- _context8.next = 6;
896
- return getServices();
897
-
898
- case 6:
899
- setImages({
900
- action: "init",
901
- init: services[2]
902
- });
903
- 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);
904
- (0, _data.getPercentage)({
905
- data: [product]
906
- }).then(function (res) {
907
- return setPercentages(res[0]);
908
- });
909
- setLoading(false);
910
-
911
- case 10:
912
- case "end":
913
- return _context8.stop();
914
- }
915
- }
916
- }, _callee8);
917
- }));
918
-
919
- return function loadData() {
920
- return _ref6.apply(this, arguments);
921
- };
922
- }();
923
-
924
- var getServices = /*#__PURE__*/function () {
925
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
926
- var _product$article4;
927
-
928
- var productInOrder, idArticle, retailers, active, _product$id_order, _servicesResponse$dat, servicesResponse, parsedResponse, retailerResponse;
929
-
930
- return _regenerator.default.wrap(function _callee9$(_context9) {
931
- while (1) {
932
- switch (_context9.prev = _context9.next) {
933
- case 0:
934
- productInOrder = product.id_order || product.orderId;
935
- idArticle = (product === null || product === void 0 ? void 0 : product.id_article) || (product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_article);
936
- retailers = product.retailers || product.retailersAvailable;
937
- active = null;
938
-
939
- if (!(isRevision() || productInOrder)) {
940
- _context9.next = 12;
941
- break;
942
- }
943
-
944
- _context9.next = 7;
945
- return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(idArticle, "&orderId=").concat((_product$id_order = product === null || product === void 0 ? void 0 : product.id_order) !== null && _product$id_order !== void 0 ? _product$id_order : product.orderId, "&end=true"));
946
-
947
- case 7:
948
- servicesResponse = _context9.sent;
949
- 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;
950
- retailerResponse = parsedResponse === null || parsedResponse === void 0 ? void 0 : parsedResponse.map(function (srv) {
951
- return srv.id_retailer;
952
- });
953
- active = retailers === null || retailers === void 0 ? void 0 : retailers.find(function (retailer) {
954
- return retailerResponse.includes(retailer.id);
955
- });
956
- setServicesData(parsedResponse);
957
-
958
- case 12:
959
- retailers && !activeRetailer.id && setActiveRetailer(active ? active : retailers[0]);
960
-
961
- case 13:
962
- case "end":
963
- return _context9.stop();
964
- }
965
- }
966
- }, _callee9);
967
- }));
968
-
969
- return function getServices() {
970
- return _ref7.apply(this, arguments);
971
- };
972
- }();
973
-
974
- var isRevision = function isRevision() {
975
- if (productEdit) {
976
- var concept = getConcept(activeTab);
977
-
978
- var _isRetailer = user.is_retailer === 1;
979
-
980
- var currentService = productEdit === null || productEdit === void 0 ? void 0 : productEdit.product["".concat(concept, "_status")];
981
- var orgn = origin[activeTab];
982
-
983
- var _revision = ["RequestWithContentoh", "RequestWithoutContentoh", "Contentoh"].includes(orgn);
984
-
985
- if (_isRetailer) {
986
- if (_revision && currentService === "AP") return true;
987
- } else {
988
- var _product = productEdit.product;
989
- var isRequestWithoutContentoh = orgn === "RequestWithoutContentoh" && (["R", "CA"].includes(currentService) || currentService === "RCA" && (!_product.id_order || !_product.orderId));
990
- var isRequestWithContentoh = orgn === "RequestWithContentoh" && currentService === "AA";
991
- var isContentoh = orgn === "Contentoh" && currentService === "AA";
992
- if (isContentoh || isRequestWithoutContentoh || isRequestWithContentoh) return true;
993
- }
994
- }
995
-
996
- return false;
997
- };
998
-
999
- var getCart = /*#__PURE__*/function () {
1000
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
1001
- var res, arr;
1002
- return _regenerator.default.wrap(function _callee10$(_context10) {
1003
- while (1) {
1004
- switch (_context10.prev = _context10.next) {
1005
- case 0:
1006
- _context10.next = 2;
1007
- return _axios.default.get(process.env.REACT_APP_CART, {
1008
- headers: {
1009
- Authorization: token
1010
- }
1011
- });
1012
-
1013
- case 2:
1014
- res = _context10.sent;
1015
- arr = JSON.parse(res.data.body).data.map(function (e) {
1016
- return e.article_id;
1017
- });
1018
- setInCart(arr.some(function (e) {
1019
- return e.articleId === product.id_article;
1020
- }));
1021
-
1022
- case 5:
1023
- case "end":
1024
- return _context10.stop();
1025
- }
1026
- }
1027
- }, _callee10);
1028
- }));
1029
-
1030
- return function getCart() {
1031
- return _ref8.apply(this, arguments);
1032
- };
1033
- }();
1034
-
1035
- (0, _react.useEffect)(function () {
1036
- sessionStorage.setItem("user", JSON.stringify(user));
1037
- loadData();
1038
- getCart();
1039
- (0, _data.fetchUsers)(token).then(function (res) {
1040
- return setUserGroups(res);
1041
- });
1042
- setImages({
1043
- action: "orderImages",
1044
- retailerId: activeRetailer.id
1045
- });
1046
- if (["RAC", "AAC"].includes(product.article_status)) showGlobalModal(product.article_status);
1047
- }, [product, version]);
1048
- (0, _react.useEffect)(function () {
1049
- setImages({
1050
- action: "orderImages",
1051
- retailerId: activeRetailer.id
1052
- });
1053
- }, [activeRetailer]);
1054
-
1055
- var loadAssignations = function loadAssignations(currentProduct) {
1056
- setAssig(product === null || product === void 0 ? void 0 : product.asignations);
1057
- };
1058
-
1059
- (0, _react.useEffect)(function () {
1060
- loadAssignations(product);
1061
- }, [userGroups]);
1062
- (0, _react.useEffect)(function () {
1063
- var _Object$keys, _percentages$productT, _retailers$;
1064
-
1065
- var productTemp = product;
1066
- var retailers = (productTemp === null || productTemp === void 0 ? void 0 : productTemp.retailersAvailable) || (productTemp === null || productTemp === void 0 ? void 0 : productTemp.retailers);
1067
-
1068
- if (((_Object$keys = Object.keys((_percentages$productT = percentages[productTemp.id_article]) !== null && _percentages$productT !== void 0 ? _percentages$productT : {})) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) > 0) {
1069
- retailers === null || retailers === void 0 ? void 0 : retailers.forEach(function (retailer, index) {
1070
- var _percentages$productT2;
1071
-
1072
- retailer["percentage"] = Number((_percentages$productT2 = percentages[productTemp.id_article][retailer.id]) === null || _percentages$productT2 === void 0 ? void 0 : _percentages$productT2.percentageRequired);
1073
- });
1074
- }
1075
-
1076
- setProduct(productTemp);
1077
- retailers && setActivePercentage((_retailers$ = retailers[0]) === null || _retailers$ === void 0 ? void 0 : _retailers$.percentage);
1078
- }, [percentages]);
1079
-
1080
- var loadInputs = function loadInputs() {
1081
- if (services.length > 0) {
1082
- var _services$0$activeRet, _services$2, _services$3;
1083
-
1084
- if ((_services$0$activeRet = services[0][activeRetailer.id]) !== null && _services$0$activeRet !== void 0 && _services$0$activeRet.data) services[0][activeRetailer.id].data = Object.values(services[0][activeRetailer.id].data);
1085
- setActivePercentage(Math.round(activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.percentage, 0));
1086
- var datagroups = services[0][activeRetailer.id];
1087
- var inputs = (_services$2 = services[0]) === null || _services$2 === void 0 ? void 0 : _services$2.inputs;
1088
-
1089
- var _descriptions = (_services$3 = services[1]) === null || _services$3 === void 0 ? void 0 : _services$3.filter(function (service) {
1090
- return (service === null || service === void 0 ? void 0 : service.id) === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id);
1091
- });
1092
-
1093
- setDatasheets([datagroups, inputs]);
1094
- setDescriptions(_descriptions);
1095
- }
1096
- };
1097
-
1098
- (0, _react.useEffect)(function () {
1099
- loadInputs();
1100
- activeRetailer.id && setImages({
1101
- action: "orderImages",
1102
- retailerId: activeRetailer.id
1103
- });
1104
- }, [servicesData, activeRetailer, services]);
1105
-
1106
- var thumbs = function thumbs() {
1107
- var _images$imageType, _images$imagePackagin, _images$values;
1108
-
1109
- var imageInputs = socketType === null || socketType === void 0 ? void 0 : socketType.slice();
1110
- 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) {
1111
- return {
1112
- value: e === null || e === void 0 ? void 0 : e.id,
1113
- name: e === null || e === void 0 ? void 0 : e.name
1114
- };
1115
- });
1116
- 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) {
1117
- return {
1118
- value: e === null || e === void 0 ? void 0 : e.id,
1119
- name: e === null || e === void 0 ? void 0 : e.name
1120
- };
1121
- });
1122
- 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) {
1123
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryElement.GalleryElement, {
1124
- setCheckAll: setCheckAll,
1125
- image: image,
1126
- gridLayout: imageLayout,
1127
- id: "gallery-element-" + index,
1128
- index: index + "-" + image.name,
1129
- number: index,
1130
- imageType: imageType,
1131
- imagePackagingType: imagePackagingType,
1132
- imageInputs: imageInputs,
1133
- changeImage: setImages,
1134
- selectedImages: selectedImages,
1135
- setSelectedImages: setSelectedImages
1136
- }, index);
1137
- });
1138
- };
1139
-
1140
- (0, _react.useEffect)(function () {
1141
- var _images$inputs;
1142
-
1143
- 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) {
1144
- return {
1145
- value: e === null || e === void 0 ? void 0 : e.id,
1146
- name: e === null || e === void 0 ? void 0 : e.name,
1147
- required: e === null || e === void 0 ? void 0 : e.required,
1148
- active: images === null || images === void 0 ? void 0 : images.values.some(function (value) {
1149
- return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
1150
- })
1151
- };
1152
- });
1153
- setSocketType(imageInputs);
1154
- }, [images]);
1155
-
1156
- var saveDescriptions = /*#__PURE__*/function () {
1157
- var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
1158
- var dataObject, res;
1159
- return _regenerator.default.wrap(function _callee11$(_context11) {
1160
- while (1) {
1161
- switch (_context11.prev = _context11.next) {
1162
- case 0:
1163
- setLoading(true);
1164
- dataObject = {
1165
- articleId: product === null || product === void 0 ? void 0 : product.id_article,
1166
- articleData: updatedDescriptions
1167
- };
1168
- if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1169
- _context11.prev = 3;
1170
- _context11.next = 6;
1171
- return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?description=true&version=").concat(version), dataObject, {
1172
- headers: {
1173
- Authorization: token
1174
- }
1175
- });
1176
-
1177
- case 6:
1178
- res = _context11.sent;
1179
-
1180
- if (!(res.data.statusCode === 200)) {
1181
- _context11.next = 12;
1182
- break;
1183
- }
1184
-
1185
- setUpdatedDescriptions([]);
1186
- setMessage("Descripciones guardadas con éxito");
1187
- _context11.next = 12;
1188
- return loadData();
1189
-
1190
- case 12:
1191
- _context11.next = 17;
1192
- break;
1193
-
1194
- case 14:
1195
- _context11.prev = 14;
1196
- _context11.t0 = _context11["catch"](3);
1197
- console.log(_context11.t0);
1198
-
1199
- case 17:
1200
- case "end":
1201
- return _context11.stop();
1202
- }
1203
- }
1204
- }, _callee11, null, [[3, 14]]);
1205
- }));
1206
-
1207
- return function saveDescriptions() {
1208
- return _ref9.apply(this, arguments);
1209
- };
1210
- }();
1211
-
1212
- var saveDatasheets = /*#__PURE__*/function () {
1213
- var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12() {
1214
- var dataObject, res;
1215
- return _regenerator.default.wrap(function _callee12$(_context12) {
1216
- while (1) {
1217
- switch (_context12.prev = _context12.next) {
1218
- case 0:
1219
- setLoading(true);
1220
- dataObject = {
1221
- articleId: product === null || product === void 0 ? void 0 : product.id_article,
1222
- articleData: updatedDatasheets
1223
- };
1224
- if (product !== null && product !== void 0 && product.orderId) dataObject["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1225
- _context12.prev = 3;
1226
- _context12.next = 6;
1227
- return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?datasheet=true&version=").concat(version), dataObject, {
1228
- headers: {
1229
- Authorization: token
1230
- }
1231
- });
1232
-
1233
- case 6:
1234
- res = _context12.sent;
1235
-
1236
- if (!(res.data.statusCode === 200)) {
1237
- _context12.next = 12;
1238
- break;
1239
- }
1240
-
1241
- setUpdatedDatasheets([]);
1242
- setMessage("Fichas técnicas guardadas");
1243
- _context12.next = 12;
1244
- return loadData();
1245
-
1246
- case 12:
1247
- _context12.next = 17;
1248
- break;
1249
-
1250
- case 14:
1251
- _context12.prev = 14;
1252
- _context12.t0 = _context12["catch"](3);
1253
- console.log(_context12.t0);
1254
-
1255
- case 17:
1256
- case "end":
1257
- return _context12.stop();
1258
- }
1259
- }
1260
- }, _callee12, null, [[3, 14]]);
1261
- }));
1262
-
1263
- return function saveDatasheets() {
1264
- return _ref10.apply(this, arguments);
1265
- };
1266
- }();
1267
-
1268
- var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
1269
- var _images$values2, _data$articleData, _data$articleData2, _data$updateImages;
1270
-
1271
- var imagesList, imagesListTemp, duplicated, attrForImgs, data, valid, _data$updateImages2, _data$articleData3, _data$articleData4, _data$articleData5, promiseArray;
1272
-
1273
- return _regenerator.default.wrap(function _callee13$(_context13) {
1274
- while (1) {
1275
- switch (_context13.prev = _context13.next) {
1276
- case 0:
1277
- imagesList = images === null || images === void 0 ? void 0 : (_images$values2 = images.values) === null || _images$values2 === void 0 ? void 0 : _images$values2.slice();
1278
- imagesListTemp = imagesList === null || imagesList === void 0 ? void 0 : imagesList.reduce(function (acc, image) {
1279
- acc[image === null || image === void 0 ? void 0 : image.image_id] = ++acc[image === null || image === void 0 ? void 0 : image.image_id] || 0;
1280
- return acc;
1281
- }, {});
1282
- duplicated = imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (image) {
1283
- return imagesListTemp[image === null || image === void 0 ? void 0 : image.image_id];
1284
- });
1285
- attrForImgs = Object.values(images === null || images === void 0 ? void 0 : images.attrForImgs);
1286
- attrForImgs.pop();
1287
- data = {
1288
- articleId: product === null || product === void 0 ? void 0 : product.id_article,
1289
- attrReqImgs: attrForImgs === null || attrForImgs === void 0 ? void 0 : attrForImgs.map(function (e) {
1290
- var _e$, _e$2;
1291
-
1292
- return {
1293
- attrId: (_e$ = e[0]) === null || _e$ === void 0 ? void 0 : _e$.id,
1294
- value: (_e$2 = e[0]) === null || _e$2 === void 0 ? void 0 : _e$2.value
1295
- };
1296
- }),
1297
- articleData: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
1298
- return !e.id;
1299
- }),
1300
- updateImages: imagesList === null || imagesList === void 0 ? void 0 : imagesList.filter(function (e) {
1301
- return e.id;
1302
- })
1303
- };
1304
- if (product !== null && product !== void 0 && product.orderId) data["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1305
- 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) {
1306
- if (e !== null && e !== void 0 && e.image_id && e !== null && e !== void 0 && e.packing_type && e !== null && e !== void 0 && e.image_type) {
1307
- return true;
1308
- }
1309
-
1310
- return false;
1311
- });
1312
-
1313
- 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) {
1314
- 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) {
1315
- if (e !== null && e !== void 0 && e.image_id && e !== null && e !== void 0 && e.packing_type && e !== null && e !== void 0 && e.image_type) {
1316
- return true;
1317
- }
1318
-
1319
- return false;
1320
- });
1321
- }
1322
-
1323
- if (!(valid && (duplicated === null || duplicated === void 0 ? void 0 : duplicated.length) === 0)) {
1324
- _context13.next = 31;
1325
- break;
1326
- }
1327
-
1328
- setLoading(true);
1329
- _context13.prev = 11;
1330
- data === null || data === void 0 ? void 0 : (_data$articleData3 = data.articleData) === null || _data$articleData3 === void 0 ? void 0 : _data$articleData3.forEach(function (e) {
1331
- e.uuid = (0, _uuid.v4)();
1332
- });
1333
- setDataImages(data);
1334
-
1335
- if (!((data === null || data === void 0 ? void 0 : (_data$articleData4 = data.articleData) === null || _data$articleData4 === void 0 ? void 0 : _data$articleData4.length) > 0)) {
1336
- _context13.next = 23;
1337
- break;
1338
- }
1339
-
1340
- setImagesUploaded(false);
1341
- promiseArray = [];
1342
- data === null || data === void 0 ? void 0 : (_data$articleData5 = data.articleData) === null || _data$articleData5 === void 0 ? void 0 : _data$articleData5.forEach(function (e) {
1343
- var file = Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
1344
- var params = {
1345
- ACL: "public-read",
1346
- Body: file,
1347
- Bucket: S3_BUCKET,
1348
- 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)
1349
- };
1350
- promiseArray.push(myBucket.putObject(params).promise());
1351
- });
1352
- _context13.next = 20;
1353
- return Promise.all(promiseArray);
1354
-
1355
- case 20:
1356
- setImagesUploaded(true);
1357
- _context13.next = 24;
1358
- break;
1359
-
1360
- case 23:
1361
- setImagesUploaded(true);
1362
-
1363
- case 24:
1364
- _context13.next = 29;
1365
- break;
1366
-
1367
- case 26:
1368
- _context13.prev = 26;
1369
- _context13.t0 = _context13["catch"](11);
1370
- console.log(_context13.t0); // setMainLoading(false);
1371
-
1372
- case 29:
1373
- _context13.next = 32;
1374
- break;
1375
-
1376
- case 31:
1377
- // setMainLoading(false);
1378
- 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.");
1379
-
1380
- case 32:
1381
- case "end":
1382
- return _context13.stop();
1383
- }
1384
- }
1385
- }, _callee13, null, [[11, 26]]);
1386
- })), [images, imagesUploaded]);
1387
- (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14() {
1388
- var res;
1389
- return _regenerator.default.wrap(function _callee14$(_context14) {
1390
- while (1) {
1391
- switch (_context14.prev = _context14.next) {
1392
- case 0:
1393
- if (!imagesUploaded) {
1394
- _context14.next = 17;
1395
- break;
1396
- }
1397
-
1398
- dataImages.articleData = dataImages === null || dataImages === void 0 ? void 0 : dataImages.articleData.map(function (e) {
1399
- delete e.src;
1400
- e.imageID = e.image_id;
1401
- e.packingType = e.packing_type;
1402
- e.imageType = e.image_type;
1403
- if (product !== null && product !== void 0 && product.orderId) e["orderId"] = product === null || product === void 0 ? void 0 : product.orderId;
1404
- return e;
1405
- });
1406
- _context14.prev = 2;
1407
- _context14.next = 5;
1408
- return _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), dataImages, {
1409
- headers: {
1410
- Authorization: token
1411
- }
1412
- });
1413
-
1414
- case 5:
1415
- res = _context14.sent;
1416
-
1417
- if (!(res.data.statusCode === 200)) {
1418
- _context14.next = 12;
1419
- break;
1420
- }
1421
-
1422
- setImages({});
1423
- setMessage("Imágenes guardadas con éxito");
1424
- sessionStorage.removeItem("imagesList");
1425
- _context14.next = 12;
1426
- return loadData();
1427
-
1428
- case 12:
1429
- _context14.next = 17;
1430
- break;
1431
-
1432
- case 14:
1433
- _context14.prev = 14;
1434
- _context14.t0 = _context14["catch"](2);
1435
- console.log(_context14.t0);
1436
-
1437
- case 17:
1438
- case "end":
1439
- return _context14.stop();
1440
- }
1441
- }
1442
- }, _callee14, null, [[2, 14]]);
1443
- })), [dataImages, imagesUploaded]);
1444
-
1445
- var getConcept = function getConcept(tab) {
1446
- switch (tab) {
1447
- case "Descripción":
1448
- return "description";
1449
-
1450
- case "Ficha técnica":
1451
- return "datasheet";
1452
-
1453
- case "Imágenes":
1454
- return "images";
1455
- }
1456
- };
1457
-
1458
- var createComment = /*#__PURE__*/function () {
1459
- var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
1460
- var messages,
1461
- retailerId,
1462
- data,
1463
- _args15 = arguments;
1464
- return _regenerator.default.wrap(function _callee15$(_context15) {
1465
- while (1) {
1466
- switch (_context15.prev = _context15.next) {
1467
- case 0:
1468
- messages = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : [];
1469
- retailerId = _args15.length > 1 ? _args15[1] : undefined;
1470
- data = {
1471
- paramsBody: {
1472
- id: product.article.id_article || productEdit.ArticleId,
1473
- version: version,
1474
- items: messages,
1475
- retailerId: retailerId,
1476
- status: product.status || productEdit.product.status
1477
- },
1478
- paramsHeader: {
1479
- Authorization: token
1480
- }
1481
- };
1482
- setMessage("");
1483
- return _context15.abrupt("return", (0, _utils.sendMessage)(data));
1484
-
1485
- case 5:
1486
- case "end":
1487
- return _context15.stop();
1488
- }
1489
- }
1490
- }, _callee15);
1491
- }));
1492
-
1493
- return function createComment() {
1494
- return _ref13.apply(this, arguments);
1495
- };
1496
- }();
1497
-
1498
- (0, _react.useEffect)(function () {
1499
- setComment(comments[activeTab]);
1500
- }, [activeTab]);
1501
-
1502
- var commentRevised = /*#__PURE__*/function () {
1503
- var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
1504
- var data;
1505
- return _regenerator.default.wrap(function _callee16$(_context16) {
1506
- while (1) {
1507
- switch (_context16.prev = _context16.next) {
1508
- case 0:
1509
- data = {
1510
- commentId: comment.id
1511
- };
1512
- _context16.next = 3;
1513
- return _axios.default.put("".concat(process.env.REACT_APP_COMMENTS_ENDPOINT), data, {
1514
- headers: {
1515
- Authorization: token
1516
- }
1517
- });
1518
-
1519
- case 3:
1520
- setCrossComment(false);
1521
-
1522
- case 4:
1523
- case "end":
1524
- return _context16.stop();
1525
- }
1526
- }
1527
- }, _callee16);
1528
- }));
1529
-
1530
- return function commentRevised() {
1531
- return _ref14.apply(this, arguments);
1532
- };
1533
- }();
1534
-
1535
- var setAssignation = /*#__PURE__*/function () {
1536
- var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(assignationType, assignationId) {
1537
- var concept, productTemp, data;
1538
- return _regenerator.default.wrap(function _callee17$(_context17) {
1539
- while (1) {
1540
- switch (_context17.prev = _context17.next) {
1541
- case 0:
1542
- concept = "";
1543
- _context17.t0 = activeTab;
1544
- _context17.next = _context17.t0 === "Ficha técnica" ? 4 : _context17.t0 === "Imágenes" ? 6 : 8;
1545
- break;
1546
-
1547
- case 4:
1548
- concept = "datasheet";
1549
- return _context17.abrupt("break", 10);
1550
-
1551
- case 6:
1552
- concept = "images";
1553
- return _context17.abrupt("break", 10);
1554
-
1555
- case 8:
1556
- concept = "description";
1557
- return _context17.abrupt("break", 10);
1558
-
1559
- case 10:
1560
- productTemp = product;
1561
- productTemp.article["id_".concat(concept, "_").concat(assignationType)] = assignationId;
1562
- data = {
1563
- articleList: [{
1564
- orderId: product.orderId,
1565
- articleId: product === null || product === void 0 ? void 0 : product.id_article
1566
- }],
1567
- concept: concept,
1568
- userId: assignationId
1569
- };
1570
- _context17.next = 15;
1571
- return (0, _axios.default)({
1572
- method: "post",
1573
- url: process.env.REACT_APP_ASSIGNATIONS_ENDPOINT,
1574
- data: data,
1575
- headers: {
1576
- Authorization: token
1577
- }
1578
- });
1579
-
1580
- case 15:
1581
- loadAssignations(productTemp);
1582
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1583
-
1584
- case 17:
1585
- case "end":
1586
- return _context17.stop();
1587
- }
1588
- }
1589
- }, _callee17);
1590
- }));
1591
-
1592
- return function setAssignation(_x4, _x5) {
1593
- return _ref15.apply(this, arguments);
1594
- };
1595
- }();
1596
-
1597
- var downloadImages = function downloadImages() {
1598
- var _images$values3;
1599
-
1600
- selectedImages.length > 0 ? selectedImages.forEach(function (e) {
1601
- if (e.id) {
1602
- (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.upc || product.article.upc, "_").concat(e.name, ".").concat(e.ext));
1603
- }
1604
- }) : images === null || images === void 0 ? void 0 : (_images$values3 = images.values) === null || _images$values3 === void 0 ? void 0 : _images$values3.forEach(function (e) {
1605
- if (e.id) {
1606
- (0, _fileSaver.saveAs)("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(product.upc || product.article.upc, "_").concat(e.name, ".").concat(e.ext));
1607
- }
1608
- });
1609
- };
1610
-
1611
- var deleteImages = function deleteImages() {
1612
- setLoading(true);
1613
- var values = images.values;
1614
- var imgsInBack = [];
1615
- selectedImages.forEach(function (selectedImg) {
1616
- if (selectedImg.id) imgsInBack.push(selectedImg);
1617
- });
1618
- var imgsLeft = values.filter(function (value) {
1619
- return selectedImages.indexOf(value) === -1;
1620
- });
1621
-
1622
- if (imgsInBack.length > 0) {
1623
- var _product$article5;
1624
-
1625
- var data = {
1626
- articleId: (product === null || product === void 0 ? void 0 : product.id_article) || (product === null || product === void 0 ? void 0 : (_product$article5 = product.article) === null || _product$article5 === void 0 ? void 0 : _product$article5.id_article),
1627
- deleteImages: imgsInBack
1628
- };
1629
-
1630
- try {
1631
- _axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), data, {
1632
- headers: {
1633
- Authorization: token
1634
- }
1635
- });
1636
- } catch (err) {
1637
- console.log(err);
1638
- }
1639
- }
1640
-
1641
- setImages({
1642
- action: "deleteImage",
1643
- selectedImages: selectedImages
1644
- });
1645
- setTimeout(function () {
1646
- setLoading(false);
1647
- }, 500);
1648
- setMessage("");
1649
- setComponentsArray([]);
1650
- };
1651
-
1652
- var askToDeleteImages = function askToDeleteImages() {
1653
- if (selectedImages.length > 0) {
1654
- setMessage("¿Está seguro de eliminar las imágenes seleccionadas?");
1655
- setComponentsArray([/*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
1656
- text: "¿Está seguro de eliminar las imágenes seleccionadas?",
1657
- headerType: "retailer-name-header",
1658
- color: "white"
1659
- }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1660
- buttonType: "general-white-button",
1661
- label: "Cancelar",
1662
- onClick: function onClick() {
1663
- return setMessage("");
1664
- }
1665
- }, "2"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
1666
- buttonType: "general-button-default",
1667
- label: "Aceptar",
1668
- onClick: function onClick() {
1669
- setMessage("");
1670
- deleteImages();
1671
- }
1672
- }, "3")]);
1673
- }
1674
- };
1675
-
1676
- var sendEvaluation = /*#__PURE__*/function () {
1677
- var _ref16 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(result) {
1678
- var _productTemp$id_order2;
1679
-
1680
- var concept, productTemp, articleId, orderId, sectionStatusKey, evalStatus, data, retailerId, res, body, _JSON$parse, response, newStatuses, statusObject, orderStatus, serviceStatus, newProductEdit, showSurveyByProvider, showSurveyByRetailer, _JSON$parse2, _response, _statusObject, retailerStatusCopy, status;
1681
-
1682
- return _regenerator.default.wrap(function _callee18$(_context18) {
1683
- while (1) {
1684
- switch (_context18.prev = _context18.next) {
1685
- case 0:
1686
- setLoading(true);
1687
- concept = getConcept(activeTab);
1688
- productTemp = product;
1689
- articleId = productTemp.id_article;
1690
- orderId = (_productTemp$id_order2 = productTemp.id_order) !== null && _productTemp$id_order2 !== void 0 ? _productTemp$id_order2 : productTemp.orderId;
1691
- sectionStatusKey = "".concat(getConcept(activeTab), "_status");
1692
- evalStatus = product[sectionStatusKey] || (product === null || product === void 0 ? void 0 : product.version_status);
1693
- data = {
1694
- articleId: articleId,
1695
- orderId: orderId,
1696
- concept: concept,
1697
- evalStatus: evalStatus
1698
- };
1699
- retailerId = activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id;
1700
- _context18.prev = 9;
1701
- body = {
1702
- orderArticleRetailers: [{
1703
- orderId: orderId,
1704
- articleId: articleId,
1705
- retailersIds: [activeRetailer.id]
1706
- }],
1707
- isAproved: false,
1708
- service: concept
1709
- };
1710
-
1711
- if (!result) {
1712
- _context18.next = 29;
1713
- break;
1714
- }
1715
-
1716
- body.isAproved = result === "A";
1717
- _context18.next = 15;
1718
- return _axios.default.post("".concat(process.env.REACT_APP_EVALUATION_REFACTOR), body, {
1719
- headers: {
1720
- Authorization: token
1721
- }
1722
- });
1723
-
1724
- case 15:
1725
- res = _context18.sent;
1726
- response = (_JSON$parse = JSON.parse(res.data.body)) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.successfulData;
1727
- newStatuses = response;
1728
- statusObject = response["".concat(orderId, "-").concat(articleId, "-").concat(activeRetailer.id)];
1729
- orderStatus = statusObject["generalStatus"];
1730
- serviceStatus = newStatuses["".concat(getConcept(activeTab), "Status")];
1731
- newProductEdit = productEdit;
1732
- newProductEdit.product[sectionStatusKey] = serviceStatus;
1733
- setProductEdit(newProductEdit);
1734
- showSurveyByProvider = !user.is_retailer && orderStatus === "AP";
1735
- showSurveyByRetailer = user.is_retailer && orderStatus === "ACA";
1736
- showSurvey && showSurvey(showSurveyByProvider || showSurveyByRetailer);
1737
- _context18.next = 32;
1738
- break;
1739
-
1740
- case 29:
1741
- _context18.next = 31;
1742
- return _axios.default.post("".concat(process.env.REACT_APP_EVALUATION_REFACTOR), body, {
1743
- headers: {
1744
- Authorization: token
1745
- }
1746
- });
1747
-
1748
- case 31:
1749
- res = _context18.sent;
1750
-
1751
- case 32:
1752
- if (res.data.statusCode === 200) {
1753
- _response = (_JSON$parse2 = JSON.parse(res.data.body)) === null || _JSON$parse2 === void 0 ? void 0 : _JSON$parse2.successfulData;
1754
- _statusObject = _response["".concat(orderId, "-").concat(articleId, "-").concat(activeRetailer.id)];
1755
- productTemp.status = _statusObject["generalStatus"];
1756
- retailerStatusCopy = (0, _objectSpread3.default)({}, retailerStatus);
1757
- retailerStatusCopy[activeRetailer.id][concept] = _statusObject["".concat(concept, "Status")];
1758
- setRetailerStatus(retailerStatusCopy);
1759
- productTemp.statusByRetailer = retailerStatusCopy;
1760
- status = _statusObject["".concat(concept, "Status")];
1761
- productTemp["".concat(concept, "_status")] = status;
1762
- setProduct(productTemp);
1763
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1764
- setOrigin(function (prev) {
1765
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, (0, _defineProperty2.default)({}, concept, status));
1766
- });
1767
- }
1768
-
1769
- _context18.next = 38;
1770
- break;
1771
-
1772
- case 35:
1773
- _context18.prev = 35;
1774
- _context18.t0 = _context18["catch"](9);
1775
- console.log(_context18.t0);
1776
-
1777
- case 38:
1778
- loadData();
1779
-
1780
- case 39:
1781
- case "end":
1782
- return _context18.stop();
1783
- }
1784
- }
1785
- }, _callee18, null, [[9, 35]]);
1786
- }));
1787
-
1788
- return function sendEvaluation(_x6) {
1789
- return _ref16.apply(this, arguments);
1790
- };
1791
- }();
1792
-
1793
- var validateAll = /*#__PURE__*/function () {
1794
- var _ref17 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(result) {
1795
- var _product$id_order2, evaluationArray, conceptArray, isAproved, retailersIds, body, userType, productTemp, status, retailerStatusCopy;
1796
-
1797
- return _regenerator.default.wrap(function _callee19$(_context19) {
1798
- while (1) {
1799
- switch (_context19.prev = _context19.next) {
1800
- case 0:
1801
- _context19.prev = 0;
1802
- setLoading(true);
1803
- evaluationArray = [];
1804
- conceptArray = ["description", "datasheet", "images"];
1805
- isAproved = result === "A";
1806
- retailersIds = [];
1807
- servicesData === null || servicesData === void 0 ? void 0 : servicesData.forEach(function (ret) {
1808
- if (!retailersIds.includes(ret.id_retailer)) retailersIds.push(ret.id_retailer);
1809
- });
1810
- body = {
1811
- orderArticleRetailers: [{
1812
- orderId: (_product$id_order2 = product.id_order) !== null && _product$id_order2 !== void 0 ? _product$id_order2 : product.orderId,
1813
- articleId: product.article.id_article,
1814
- retailersIds: retailersIds
1815
- }],
1816
- isAproved: isAproved
1817
- };
1818
- conceptArray.forEach(function (concept) {
1819
- body.service = concept;
1820
- evaluationArray.push(_axios.default.post("".concat(process.env.REACT_APP_EVALUATION_REFACTOR), body, {
1821
- headers: {
1822
- Authorization: token
1823
- }
1824
- }));
1825
- });
1826
- _context19.next = 11;
1827
- return Promise.all(evaluationArray);
1828
-
1829
- case 11:
1830
- userType = user.is_retailer === 1 ? "CA" : "P";
1831
- productTemp = product;
1832
- status = "".concat(result).concat(userType);
1833
- productTemp.status = status;
1834
- productTemp.datasheet_status = productTemp.datasheet_status === "NA" ? "NA" : status;
1835
- productTemp.description_status = productTemp.description_status === "NA" ? "NA" : status;
1836
- productTemp.images_status = productTemp.images_status === "NA" ? "NA" : status;
1837
- retailerStatusCopy = (0, _objectSpread3.default)({}, retailerStatus);
1838
- Object.keys(retailerStatusCopy).forEach(function (key) {
1839
- conceptArray.forEach(function (concept) {
1840
- if (retailerStatusCopy[key][concept]) {
1841
- retailerStatusCopy[key][concept] = status;
1842
- }
1843
- });
1844
- });
1845
- setRetailerStatus(retailerStatusCopy);
1846
- productTemp.statusByRetailer = retailerStatusCopy;
1847
- setProduct(productTemp);
1848
- sessionStorage.setItem("productSelected", JSON.stringify(productTemp));
1849
- setProductEdit({
1850
- ArticleId: productTemp.id_article,
1851
- idCategory: productTemp.article.id_category,
1852
- product: productTemp
1853
- });
1854
- sessionStorage.setItem("productEdit", JSON.stringify({
1855
- ArticleId: productTemp.id_article,
1856
- idCategory: productTemp.article.id_category,
1857
- product: productTemp
1858
- }));
1859
- _context19.next = 28;
1860
- return loadData();
1861
-
1862
- case 28:
1863
- _context19.next = 33;
1864
- break;
1865
-
1866
- case 30:
1867
- _context19.prev = 30;
1868
- _context19.t0 = _context19["catch"](0);
1869
- console.log(_context19.t0);
1870
-
1871
- case 33:
1872
- case "end":
1873
- return _context19.stop();
1874
- }
1875
- }
1876
- }, _callee19, null, [[0, 30]]);
1877
- }));
1878
-
1879
- return function validateAll(_x7) {
1880
- return _ref17.apply(this, arguments);
1881
- };
1882
- }();
1883
-
1884
- var evaluationToRetailer = /*#__PURE__*/function () {
1885
- var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(result) {
1886
- var data, prod, statusComplete;
1887
- return _regenerator.default.wrap(function _callee20$(_context20) {
1888
- while (1) {
1889
- switch (_context20.prev = _context20.next) {
1890
- case 0:
1891
- data = {
1892
- articleId: product.id_article,
1893
- companyId: user.is_retailer ? product.provider_company_id : product.retailer_company_id,
1894
- versionId: product.version,
1895
- status: result
1896
- };
1897
- _context20.next = 3;
1898
- return _axios.default.put("".concat(process.env.REACT_APP_RETAILER_REQUEST), data, {
1899
- headers: {
1900
- Authorization: token
1901
- }
1902
- });
1903
-
1904
- case 3:
1905
- prod = productEdit;
1906
- statusComplete = user.is_retailer ? "".concat(result, "CA") : "".concat(result, "P");
1907
- prod.product.datasheet_status = statusComplete;
1908
- prod.product.description_status = statusComplete;
1909
- prod.product.images_status = statusComplete;
1910
- prod.product.article_status = statusComplete;
1911
- prod.product.services_status = "[\"".concat(statusComplete, "\",\"").concat(statusComplete, "\",\"").concat(statusComplete, "\"]");
1912
- sessionStorage.setItem("productEdit", JSON.stringify(prod));
1913
- setProduct(prod);
1914
- showGlobalModal("generic");
1915
- _context20.next = 15;
1916
- return loadData();
1917
-
1918
- case 15:
1919
- case "end":
1920
- return _context20.stop();
1921
- }
1922
- }
1923
- }, _callee20);
1924
- }));
1925
-
1926
- return function evaluationToRetailer(_x8) {
1927
- return _ref18.apply(this, arguments);
1928
- };
1929
- }();
1930
-
1931
- var getSectionStatus = function getSectionStatus() {
1932
- var concept = getConcept(activeTab);
1933
- return ["AA", "AP", "R", "CA", "RCA"].includes(productEdit.product["".concat(concept, "_status")]);
1934
- };
1935
-
1936
- var enableActions = function enableActions(versionStatus) {
1937
- try {
1938
- if (user.is_retailer) return false;
1939
-
1940
- if (versionStatus) {
1941
- return ["AP", "ACA", "RCA", null].includes(versionStatus);
1942
- }
1943
-
1944
- return true;
1945
- } catch (err) {
1946
- console.log(err, "Unable de check if user is retailer");
1947
- return false;
1948
- }
1949
- };
1950
-
1951
- (0, _react.useEffect)(function () {
1952
- setSaving(loading);
1953
- }, [loading]);
1954
- var slidefront = [{
1955
- slide: _slide.default,
1956
- description: "Creamos tu contenido, y todo lo que haga falta para tu producto, cada sección puedes socilitar contenido enriquecido, y nosotros lo haremos por ti."
1957
- }, {
1958
- slide: _slide2.default,
1959
- description: "Puedes agregar solicitudes de contenido enriquecido a tu carrito de compra las veces que sean necesarias. Una vez completada tu lista con los servicios necesitados sigue el proceso de compra en checkout."
1960
- }, {
1961
- slide: _slide3.default,
1962
- description: "Revisa el contenido que deseas solicilitar, valida y tambien puedes agregar contenido extra, traducciones, o simplemente completar el checkout."
1963
- }, {
1964
- slide: _slide4.default,
1965
- description: "Elige el tipo de entrega de tu producto, puedes ser recolección en el lugar o por el contrario puedes dejarlo en nuestras oficinas."
1966
- }, {
1967
- slide: _slide5.default,
1968
- title: "Bienvenido al modo Content-oh!",
1969
- description: "Finalmente elige la forma de pago que más te guste, procede con el pago y listo."
1970
- }];
1971
-
1972
- var sendToEvaluation = function sendToEvaluation(result) {
1973
- console.log({
1974
- result: result
1975
- });
1976
-
1977
- if (result === "A") {
1978
- if (origin[activeTab] === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
1979
- setDataGenericModal(function (prev) {
1980
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1981
- button2: {
1982
- name: "Continuar",
1983
- action: function action() {
1984
- return evaluationToRetailer("A");
1985
- }
1986
- }
1987
- });
1988
- });
1989
- showGlobalModal("generic");
1990
- } else if (user.is_retailer) {
1991
- if (product.id_order || product.orderId) {
1992
- sendEvaluation("A");
1993
- } else {
1994
- setDataGenericModal(function (prev) {
1995
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
1996
- button2: {
1997
- name: "Continuar",
1998
- action: function action() {
1999
- return evaluationToRetailer("A");
2000
- }
2001
- }
2002
- });
2003
- });
2004
- showGlobalModal("generic");
2005
- }
2006
- } else {
2007
- sendEvaluation("A");
2008
- }
2009
- } else {
2010
- if (origin === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
2011
- return;
2012
- } else if (user.is_retailer) {
2013
- if (product.id_order || product.orderId) {
2014
- sendEvaluation("R");
2015
- } else {
2016
- setDataGenericModal(function (prev) {
2017
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
2018
- button2: {
2019
- name: "Continuar",
2020
- action: function action() {
2021
- return evaluationToRetailer("R");
2022
- }
2023
- }
2024
- });
2025
- });
2026
- showGlobalModal("generic");
2027
- }
2028
- } else {
2029
- sendEvaluation("R");
2030
- }
2031
- }
2032
- };
2033
-
2034
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
2035
- headerTop: headerTop,
2036
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_HeaderTop.HeaderTop, {
2037
- setHeaderTop: setHeaderTop,
2038
- withChat: location === null || location === void 0 ? void 0 : (_location$state5 = location.state) === null || _location$state5 === void 0 ? void 0 : _location$state5.withChat,
2039
- chatType: location === null || location === void 0 ? void 0 : (_location$state6 = location.state) === null || _location$state6 === void 0 ? void 0 : _location$state6.chatType,
2040
- productSelected: productSelected,
2041
- token: token,
2042
- activeRetailer: activeRetailer
2043
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2044
- className: "data-container",
2045
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2046
- className: "image-data-panel",
2047
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagePreviewer.ImagePreviewer, {
2048
- activeImage: images !== null && images !== void 0 && images.values ? images === null || images === void 0 ? void 0 : images.values[activeImage] : {},
2049
- imagesArray: images,
2050
- setActiveImage: setActiveImage,
2051
- setShowModal: setShowModal
2052
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageDataTable.ImageDataTable, {
2053
- lists: images,
2054
- activeImage: images !== null && images !== void 0 && images.values ? images === null || images === void 0 ? void 0 : images.values[activeImage] : {},
2055
- retailerSelected: activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id,
2056
- setImages: setImages,
2057
- assignationsImages: assig,
2058
- imagesStatus: product === null || product === void 0 ? void 0 : product.images_status,
2059
- setAssignation: setAssignation,
2060
- isRetailer: isRetailer,
2061
- onClickSave: function onClickSave() {
2062
- var _product$services;
2063
-
2064
- return (product === null || product === void 0 ? void 0 : (_product$services = product.services) === null || _product$services === void 0 ? void 0 : _product$services.images) === 1 && updateImages();
2065
- },
2066
- setShowVersionSelector: setShowVersionSelector,
2067
- version: version
2068
- })]
2069
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2070
- className: "product-information",
2071
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FullProductNameHeader.FullProductNameHeader, {
2072
- headerData: product,
2073
- percent: activePercentage,
2074
- activeRetailer: activeRetailer,
2075
- setActiveRetailer: setActiveRetailer,
2076
- showValidationButtons: isRevision() && getSectionStatus(),
2077
- servicesData: servicesData ? servicesData : null,
2078
- showApproveRejectAll: isRevision() && getSectionStatus(),
2079
- approveAll: function approveAll() {
2080
- if (origin === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
2081
- setDataGenericModal(function (prev) {
2082
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
2083
- button2: {
2084
- name: "Continuar",
2085
- action: function action() {
2086
- return evaluationToRetailer("A");
2087
- }
2088
- }
2089
- });
2090
- });
2091
- showGlobalModal("generic");
2092
- } else if (user.is_retailer) {
2093
- if (product.id_order || product.orderId) {
2094
- validateAll("A");
2095
- } else {
2096
- setDataGenericModal(function (prev) {
2097
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
2098
- button2: {
2099
- name: "Continuar",
2100
- action: function action() {
2101
- return evaluationToRetailer("A");
2102
- }
2103
- }
2104
- });
2105
- });
2106
- showGlobalModal("generic");
2107
- }
2108
- } else {
2109
- validateAll("A");
2110
- }
2111
- },
2112
- rejectAll: function rejectAll() {
2113
- if (origin === "RequestWithoutContentoh" && !user.is_retailer && (!product.id_order || !product.orderId)) {
2114
- return;
2115
- } else if (user.is_retailer) {
2116
- if (product.id_order || product.orderId) {
2117
- setValidatedAll(true);
2118
- setShowRejectModal(true);
2119
- } else {
2120
- setDataGenericModal(function (prev) {
2121
- return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, {
2122
- button2: {
2123
- name: "Continuar",
2124
- action: function action() {
2125
- return evaluationToRetailer("R");
2126
- }
2127
- }
2128
- });
2129
- });
2130
- showGlobalModal("generic");
2131
- }
2132
- } else {
2133
- setShowRejectModal(true);
2134
- setValidatedAll(true);
2135
- }
2136
- },
2137
- approve: function approve() {
2138
- return sendToEvaluation("A");
2139
- },
2140
- reject: function reject() {
2141
- setShowRejectModal(true);
2142
- }
2143
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
2144
- tabsSections: tabsSections,
2145
- status: activeRetailer !== null && activeRetailer !== void 0 && activeRetailer.id && retailerStatus && retailerStatus[activeRetailer.id] ? retailerStatus[activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id][getConcept(activeTab)] || "NS" : "-",
2146
- activeTab: activeTab,
2147
- setActiveTab: setActiveTab,
2148
- setImageLayout: setImageLayout,
2149
- downloadImages: downloadImages,
2150
- askToDeleteImages: askToDeleteImages,
2151
- assig: assig,
2152
- setAssignation: setAssignation,
2153
- isRetailer: isRetailer,
2154
- showSaveButton: enableActions(product.version_status),
2155
- version: version,
2156
- updatedDescriptions: updatedDescriptions,
2157
- setUpdatedDescriptions: setUpdatedDescriptions,
2158
- updatedDatasheets: updatedDatasheets,
2159
- setUpdatedDatasheets: setUpdatedDatasheets,
2160
- images: images,
2161
- setImages: setImages,
2162
- selectedImages: selectedImages,
2163
- setSelectedImages: setSelectedImages,
2164
- setShowVersionSelector: setShowVersionSelector,
2165
- onClickSave: function onClickSave() {
2166
- switch (activeTab) {
2167
- case "Descripción":
2168
- !saving && saveDescriptions();
2169
- break;
2170
-
2171
- case "Ficha técnica":
2172
- !saving && saveDatasheets();
2173
- break;
2174
-
2175
- case "Imágenes":
2176
- !saving && updateImages();
2177
- break;
2178
-
2179
- default:
2180
- break;
2181
- }
2182
- }
2183
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2184
- className: "services-information-container " + (imageLayout && activeTab === "Imágenes" ? "image-services" : ""),
2185
- children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
2186
- children: [!imageLayout && activeTab === "Imágenes" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {
2187
- setSelectedImages: setSelectedImages,
2188
- checkAll: checkAll,
2189
- setCheckAll: setCheckAll
2190
- }), 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) {
2191
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2192
- articleId: product.id_article,
2193
- version: version,
2194
- activeSection: activeTab,
2195
- inputGroup: dataGroup,
2196
- dataInputs: datasheets[1],
2197
- updatedDatasheets: updatedDatasheets,
2198
- setUpdatedDatasheets: setUpdatedDatasheets //enableActions={enableActions(product.version_status)} ADD THIS VALIDATION
2199
-
2200
- }, index + "-" + activeRetailer.name);
2201
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2202
- text: "No cuentas con este servicio",
2203
- headerType: "input-name-header"
2204
- })), activeTab === "Descripción" && ((product === null || product === void 0 ? void 0 : product.description_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputGroup.InputGroup, {
2205
- activeSection: activeTab,
2206
- inputGroup: descriptions[0],
2207
- updatedDescriptions: updatedDescriptions,
2208
- setUpdatedDescriptions: setUpdatedDescriptions,
2209
- articleId: product === null || product === void 0 ? void 0 : product.id_article,
2210
- version: version,
2211
- dinamicHeight: true
2212
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2213
- text: "No cuentas con este servicio",
2214
- headerType: "input-name-header"
2215
- })), activeTab === "Imágenes" && ((product === null || product === void 0 ? void 0 : product.images_status) !== "NS" ? /*#__PURE__*/(0, _jsxRuntime.jsx)("section", {
2216
- className: "container",
2217
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", (0, _objectSpread3.default)((0, _objectSpread3.default)({}, getRootProps({
2218
- className: "dropzone"
2219
- })), {}, {
2220
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", (0, _objectSpread3.default)({}, getInputProps())), /*#__PURE__*/(0, _jsxRuntime.jsx)("aside", {
2221
- children: thumbs()
2222
- })]
2223
- }))
2224
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2225
- text: "No cuentas con este servicio",
2226
- headerType: "input-name-header"
2227
- }))]
2228
- })
2229
- }), !(isRevision() && getSectionStatus()) && !revision && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
2230
- className: "required-inputs-message",
2231
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
2232
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2233
- children: "Los atributos son requeridos por las plataformas de las cadenas, es muy importante completar los campos requeridos ya que pueden rechazar el producto por falta de informaci\xF3n."
2234
- })
2235
- }), inCart ? /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
2236
- type: "button",
2237
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactRouterDom.Link, {
2238
- to: "/checkout",
2239
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2240
- children: "Articulo en carrito"
2241
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
2242
- children: "Ir a checkout"
2243
- })]
2244
- })
2245
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
2246
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_SliderToolTip.SliderToolTip, {
2247
- infoIcon: _infoIcon.default,
2248
- slidefront: slidefront,
2249
- iconSize: "big-image",
2250
- slidePosition: "top-slide"
2251
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
2252
- onClick: function onClick() {
2253
- setShowContentohRequestModal && setShowContentohRequestModal(true);
2254
- },
2255
- buttonType: "general-default-button",
2256
- label: "Enviar a Content-oh!"
2257
- })]
2258
- })]
2259
- })]
2260
- })]
2261
- }), showModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProductImageModal.ProductImageModal, {
2262
- images: images,
2263
- setShowModal: setShowModal,
2264
- approveRejectButtons: isRevision() && getSectionStatus(),
2265
- sendToFacilitator: sendToEvaluation
2266
- }), message.length > 0 && !showSurvey && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GenericModal.GenericModal, {
2267
- buttonType: componentsArray.length > 0 && "delete-product",
2268
- componentsArray: componentsArray.length > 0 ? componentsArray : [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
2269
- src: _genericModalCheck.default,
2270
- alt: "success icon"
2271
- }, "1"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScreenHeader.ScreenHeader, {
2272
- headerType: "retailer-name-header",
2273
- text: message,
2274
- color: "white"
2275
- }, "2")],
2276
- onClick: function onClick() {
2277
- return setMessage("");
2278
- }
2279
- }), globalModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.GlobalModal, (0, _objectSpread3.default)({
2280
- close: closeGlobalModal
2281
- }, globalModal)), showVersionSelector && /*#__PURE__*/(0, _jsxRuntime.jsx)(_VersionSelector.VersionSelector, {
2282
- modalId: "version-selector",
2283
- articleId: product.id_article,
2284
- setVersion: setVersion,
2285
- companyName: company.company_name,
2286
- currentVersion: version,
2287
- setShowVersionSelector: setShowVersionSelector,
2288
- jwt: token
2289
- }), showRejectModal && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.Modal, {
2290
- title: "Agregar mensaje de rechazo",
2291
- show: showRejectModal,
2292
- customComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.TagAndInput, {
2293
- inputType: "textarea",
2294
- inputId: "modal-message-box",
2295
- index: 0,
2296
- color: "white"
2297
- }),
2298
- buttons: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.ButtonV2, {
2299
- type: "white",
2300
- label: "Cancelar",
2301
- size: 12,
2302
- onClick: function onClick() {
2303
- setShowRejectModal(false);
2304
- }
2305
- }, "btn-Cancelar"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonV.ButtonV2, {
2306
- type: "pink",
2307
- label: "Aceptar",
2308
- size: 12,
2309
- onClick: /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
2310
- var body, messages;
2311
- return _regenerator.default.wrap(function _callee21$(_context21) {
2312
- while (1) {
2313
- switch (_context21.prev = _context21.next) {
2314
- case 0:
2315
- body = document.querySelector("#modal-message-box .ql-container .ql-editor > p").innerHTML;
2316
- messages = [{
2317
- type: "message",
2318
- value: body === null || body === void 0 ? void 0 : body.replace(/<.*?\/?>/gm, "")
2319
- }];
2320
- _context21.next = 4;
2321
- return createComment(messages, activeRetailer.id);
2322
-
2323
- case 4:
2324
- validatedAll ? validateAll("R") : sendToEvaluation("R");
2325
- setShowRejectModal(false);
2326
-
2327
- case 6:
2328
- case "end":
2329
- return _context21.stop();
2330
- }
2331
- }
2332
- }, _callee21);
2333
- }))
2334
- }, "btn-Aceptar")]
2335
- })]
2336
- });
2337
- };
2338
-
2339
- exports.ProviderProductEdition1 = ProviderProductEdition1;