contentoh-components-library 21.5.92 → 21.5.93
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.
- package/dist/components/atoms/GeneralButton/styles.js +1 -1
- package/dist/components/atoms/GeneralInput/index.js +54 -245
- package/dist/components/atoms/GeneralInput/styles.js +3 -7
- package/dist/components/atoms/InputFormatter/index.js +68 -223
- package/dist/components/atoms/InputFormatter/styles.js +4 -20
- package/dist/components/molecules/StatusAsignationInfo/index.js +1 -11
- package/dist/components/molecules/TabsMenu/index.js +12 -13
- package/dist/components/molecules/TagAndInput/index.js +24 -361
- package/dist/components/molecules/TagAndInput/styles.js +2 -2
- package/dist/components/organisms/FullProductNameHeader/index.js +22 -6
- package/dist/components/organisms/InputGroup/index.js +18 -22
- package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +337 -150
- package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +15 -15
- package/dist/components/pages/ProviderProductEdition/index.js +362 -368
- package/dist/components/pages/ProviderProductEdition/utils.js +0 -1
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +196 -179
- package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js +260 -59
- package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +38 -50
- package/dist/components/pages/RetailerProductEdition/index.js +2234 -1716
- package/dist/components/pages/RetailerProductEdition/styles.js +2 -4
- package/dist/components/pages/RetailerProductEdition/utils.js +2 -251
- package/dist/contexts/AiProductEdition.js +158 -230
- package/package.json +2 -4
- package/src/components/atoms/GeneralButton/styles.js +0 -4
- package/src/components/atoms/GeneralInput/index.js +60 -237
- package/src/components/atoms/GeneralInput/styles.js +0 -81
- package/src/components/atoms/InputFormatter/index.js +51 -200
- package/src/components/atoms/InputFormatter/styles.js +0 -284
- package/src/components/molecules/StatusAsignationInfo/index.js +1 -9
- package/src/components/molecules/TabsMenu/index.js +11 -12
- package/src/components/molecules/TagAndInput/index.js +21 -286
- package/src/components/molecules/TagAndInput/styles.js +17 -59
- package/src/components/organisms/FullProductNameHeader/index.js +28 -4
- package/src/components/organisms/FullTabsMenu/index.js +1 -1
- package/src/components/organisms/InputGroup/index.js +4 -12
- package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +202 -174
- package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +14 -14
- package/src/components/pages/ProviderProductEdition/index.js +452 -453
- package/src/components/pages/ProviderProductEdition/utils.js +2 -2
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +224 -201
- package/src/components/pages/RetailerProductEdition/index.js +1718 -1547
- package/src/components/pages/RetailerProductEdition/styles.js +2 -67
- package/src/components/pages/RetailerProductEdition/utils.js +0 -240
- package/dist/ai/utils/compare-strings.js +0 -45
- package/dist/components/organisms/ChangeStatusModal/index.js +0 -531
- package/dist/components/organisms/ChangeStatusModal/styles.js +0 -85
- package/dist/global-files/statusDictionary.js +0 -103
- package/src/ai/utils/compare-strings.js +0 -45
- package/src/assets/images/Icons/arrow.png +0 -0
- package/src/assets/images/Icons/cancel.png +0 -0
- package/src/assets/images/Icons/ia-icon.png +0 -0
- package/src/assets/images/Icons/loading.svg +0 -5
- package/src/assets/images/Icons/reload.png +0 -0
- package/src/components/atoms/RetailerSelector/RetailerSelector.stories.js +0 -10
- package/src/components/atoms/RetailerSelector/index.js +0 -3
- package/src/components/atoms/RetailerSelector/styles.js +0 -0
- package/src/components/organisms/ChangeStatusModal/index.jsx +0 -488
- package/src/components/organisms/ChangeStatusModal/styles.js +0 -333
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.context.jsx +0 -575
- package/src/components/pages/RetailerProductEdition/context/provider-product-edition.reducer.js +0 -62
- package/src/components/pages/RetailerProductEdition/context/reducers/active-state.js +0 -344
- package/src/components/pages/RetailerProductEdition/context/reducers/inputs.js +0 -155
- package/src/components/pages/RetailerProductEdition/context/reducers/product.js +0 -114
- package/src/components/pages/RetailerProductEdition/context/reducers/system.js +0 -60
- package/src/components/pages/RetailerProductEdition/index_old.js +0 -1979
- package/src/components/pages/RetailerProductEdition/stories/Auditor.stories.js +0 -101
- package/src/components/pages/RetailerProductEdition/stories/ImageEditor.stories.js +0 -115
- package/src/components/pages/RetailerProductEdition/stories/TextEditor.stories.js +0 -174
- package/src/contexts/AiProductEdition.jsx +0 -339
- package/src/global-files/statusDictionary.js +0 -103
package/dist/components/pages/RetailerProductEdition/context/provider-product-edition.context.js
CHANGED
|
@@ -35,6 +35,8 @@ var _errorModal = _interopRequireDefault(require("../../../../assets/images/gene
|
|
|
35
35
|
|
|
36
36
|
var _utils = require("../utils");
|
|
37
37
|
|
|
38
|
+
var _data = require("../../../../global-files/data");
|
|
39
|
+
|
|
38
40
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
39
41
|
|
|
40
42
|
var _excluded = ["src"],
|
|
@@ -68,7 +70,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
68
70
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(token) {
|
|
69
71
|
var _state$product, _state$product2;
|
|
70
72
|
|
|
71
|
-
var dataObject, _state$product3, res, inputs, filledRequiredCount;
|
|
73
|
+
var dataObject, _state$product3, res, inputs, filledRequiredCount, body, newStatus, _state$product4, productFromLocalStorage, updatedProduct;
|
|
72
74
|
|
|
73
75
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
74
76
|
while (1) {
|
|
@@ -89,7 +91,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
89
91
|
dataObject = {
|
|
90
92
|
articleId: (_state$product = state.product) === null || _state$product === void 0 ? void 0 : _state$product.id_article,
|
|
91
93
|
articleData: state.updated_descriptions_inputs
|
|
92
|
-
};
|
|
94
|
+
};
|
|
93
95
|
|
|
94
96
|
if ((_state$product2 = state.product) !== null && _state$product2 !== void 0 && _state$product2.id_order) {
|
|
95
97
|
dataObject.orderId = (_state$product3 = state.product) === null || _state$product3 === void 0 ? void 0 : _state$product3.id_order;
|
|
@@ -132,6 +134,36 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
132
134
|
filledRequiredCount += 1;
|
|
133
135
|
}
|
|
134
136
|
});
|
|
137
|
+
body = JSON.parse(res.data.body);
|
|
138
|
+
newStatus = body === null || body === void 0 ? void 0 : body.newStatus;
|
|
139
|
+
|
|
140
|
+
if (newStatus) {
|
|
141
|
+
productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
|
|
142
|
+
updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
|
|
143
|
+
description_status: newStatus,
|
|
144
|
+
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product4 = state.product) === null || _state$product4 === void 0 ? void 0 : _state$product4.statusByRetailer) || []).map(function (retailerStatus) {
|
|
145
|
+
return retailerStatus.service === "description" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
|
|
146
|
+
status: newStatus
|
|
147
|
+
}) : retailerStatus;
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
|
|
151
|
+
dispatch({
|
|
152
|
+
type: "UPDATE_DESCRIPTION_STATUS",
|
|
153
|
+
payload: newStatus
|
|
154
|
+
});
|
|
155
|
+
dispatch({
|
|
156
|
+
type: "SET_SERVICES_DATA",
|
|
157
|
+
payload: (state.services_data || []).map(function (srv) {
|
|
158
|
+
var _state$active_retaile;
|
|
159
|
+
|
|
160
|
+
return srv.service === "description" && srv.id_retailer === ((_state$active_retaile = state.active_retailer) === null || _state$active_retaile === void 0 ? void 0 : _state$active_retaile.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
161
|
+
status: newStatus
|
|
162
|
+
}) : srv;
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
135
167
|
dispatch({
|
|
136
168
|
type: "SET_MISSING_REQUIRED_FIELDS",
|
|
137
169
|
payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.missing_required_fields), {}, {
|
|
@@ -191,9 +223,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
191
223
|
|
|
192
224
|
var saveDatasheets = /*#__PURE__*/function () {
|
|
193
225
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(token) {
|
|
194
|
-
var _state$
|
|
226
|
+
var _state$product5, _state$product6;
|
|
195
227
|
|
|
196
|
-
var dataObject, _state$
|
|
228
|
+
var dataObject, _state$product7, res, _state$active_retaile2, datasheetInputs, retailerId, filledRequiredCount, body, newStatus, _state$product8, productFromLocalStorage, updatedProduct;
|
|
197
229
|
|
|
198
230
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
199
231
|
while (1) {
|
|
@@ -212,12 +244,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
212
244
|
payload: true
|
|
213
245
|
});
|
|
214
246
|
dataObject = {
|
|
215
|
-
articleId: (_state$
|
|
247
|
+
articleId: (_state$product5 = state.product) === null || _state$product5 === void 0 ? void 0 : _state$product5.id_article,
|
|
216
248
|
articleData: state.updated_datasheets_inputs
|
|
217
249
|
};
|
|
218
250
|
|
|
219
|
-
if ((_state$
|
|
220
|
-
dataObject.orderId = (_state$
|
|
251
|
+
if ((_state$product6 = state.product) !== null && _state$product6 !== void 0 && _state$product6.id_order) {
|
|
252
|
+
dataObject.orderId = (_state$product7 = state.product) === null || _state$product7 === void 0 ? void 0 : _state$product7.id_order;
|
|
221
253
|
}
|
|
222
254
|
|
|
223
255
|
_context2.prev = 5;
|
|
@@ -247,7 +279,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
247
279
|
}); // Contar cuántos campos requeridos que antes estaban vacíos ahora tienen valor
|
|
248
280
|
|
|
249
281
|
datasheetInputs = state.datasheets_inputs[1];
|
|
250
|
-
retailerId = (_state$
|
|
282
|
+
retailerId = (_state$active_retaile2 = state.active_retailer) === null || _state$active_retaile2 === void 0 ? void 0 : _state$active_retaile2.id_retailer;
|
|
251
283
|
filledRequiredCount = 0;
|
|
252
284
|
state.updated_datasheets_inputs.forEach(function (updatedInput) {
|
|
253
285
|
var key = "".concat(updatedInput.attributeId, "_").concat(retailerId);
|
|
@@ -257,6 +289,36 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
257
289
|
filledRequiredCount += 1;
|
|
258
290
|
}
|
|
259
291
|
});
|
|
292
|
+
body = JSON.parse(res.data.body);
|
|
293
|
+
newStatus = body === null || body === void 0 ? void 0 : body.newStatus;
|
|
294
|
+
|
|
295
|
+
if (newStatus) {
|
|
296
|
+
productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
|
|
297
|
+
updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
|
|
298
|
+
datasheet_status: newStatus,
|
|
299
|
+
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product8 = state.product) === null || _state$product8 === void 0 ? void 0 : _state$product8.statusByRetailer) || []).map(function (retailerStatus) {
|
|
300
|
+
return retailerStatus.service === "datasheet" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
|
|
301
|
+
status: newStatus
|
|
302
|
+
}) : retailerStatus;
|
|
303
|
+
})
|
|
304
|
+
});
|
|
305
|
+
sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
|
|
306
|
+
dispatch({
|
|
307
|
+
type: "UPDATE_DATASHEET_STATUS",
|
|
308
|
+
payload: newStatus
|
|
309
|
+
});
|
|
310
|
+
dispatch({
|
|
311
|
+
type: "SET_SERVICES_DATA",
|
|
312
|
+
payload: (state.services_data || []).map(function (srv) {
|
|
313
|
+
var _state$active_retaile3;
|
|
314
|
+
|
|
315
|
+
return srv.service === "datasheet" && srv.id_retailer === ((_state$active_retaile3 = state.active_retailer) === null || _state$active_retaile3 === void 0 ? void 0 : _state$active_retaile3.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
316
|
+
status: newStatus
|
|
317
|
+
}) : srv;
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
260
322
|
dispatch({
|
|
261
323
|
type: "SET_MISSING_REQUIRED_FIELDS",
|
|
262
324
|
payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.missing_required_fields), {}, {
|
|
@@ -310,9 +372,10 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
310
372
|
|
|
311
373
|
var updateImages = /*#__PURE__*/function () {
|
|
312
374
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(token) {
|
|
313
|
-
var _state$images_values, _state$
|
|
375
|
+
var _state$images_values, _state$product9, _state$product10, _state$product11, _data$articleData, _data$updateImages;
|
|
376
|
+
|
|
377
|
+
var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res, imageBody, newStatus, _state$product12, productFromLocalStorage, updatedProduct, _freshImages$values, _state$product13, id_article, version, _state$active_retaile5, category, id_category, id_retailer, imagesRes, freshImages, orderMap, orderedValues, filteredValues;
|
|
314
378
|
|
|
315
|
-
var updatedImages, attrForImgs, generalAttrs, retailerKey, retailerAttrs, mergedAttrs, data, valid, promiseArray, res;
|
|
316
379
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
317
380
|
while (1) {
|
|
318
381
|
switch (_context3.prev = _context3.next) {
|
|
@@ -346,7 +409,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
346
409
|
return retailerAttr;
|
|
347
410
|
});
|
|
348
411
|
data = {
|
|
349
|
-
articleId: (_state$
|
|
412
|
+
articleId: (_state$product9 = state.product) === null || _state$product9 === void 0 ? void 0 : _state$product9.id_article,
|
|
350
413
|
attrReqImgs: mergedAttrs.map(function (e) {
|
|
351
414
|
var _e$value;
|
|
352
415
|
|
|
@@ -362,15 +425,18 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
362
425
|
return e.id;
|
|
363
426
|
})
|
|
364
427
|
};
|
|
365
|
-
if ((_state$
|
|
428
|
+
if ((_state$product10 = state.product) !== null && _state$product10 !== void 0 && _state$product10.orderId) data["orderId"] = (_state$product11 = state.product) === null || _state$product11 === void 0 ? void 0 : _state$product11.orderId;
|
|
366
429
|
valid = (data === null || data === void 0 ? void 0 : (_data$articleData = data.articleData) === null || _data$articleData === void 0 ? void 0 : _data$articleData.every(function (e) {
|
|
367
430
|
return e === null || e === void 0 ? void 0 : e.image_id;
|
|
368
431
|
})) && (data === null || data === void 0 ? void 0 : (_data$updateImages = data.updateImages) === null || _data$updateImages === void 0 ? void 0 : _data$updateImages.every(function (e) {
|
|
369
432
|
return e === null || e === void 0 ? void 0 : e.image_id;
|
|
370
|
-
}));
|
|
433
|
+
}));
|
|
434
|
+
console.log({
|
|
435
|
+
data: data
|
|
436
|
+
});
|
|
371
437
|
|
|
372
438
|
if (!valid) {
|
|
373
|
-
_context3.next =
|
|
439
|
+
_context3.next = 61;
|
|
374
440
|
break;
|
|
375
441
|
}
|
|
376
442
|
|
|
@@ -389,7 +455,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
389
455
|
isApproved: true
|
|
390
456
|
});
|
|
391
457
|
});
|
|
392
|
-
_context3.prev =
|
|
458
|
+
_context3.prev = 16;
|
|
393
459
|
promiseArray = data.articleData.map(function (e) {
|
|
394
460
|
var file = Buffer.from(e.src.replace(/^data:image\/\w+;base64,/, ""), "base64");
|
|
395
461
|
var params = {
|
|
@@ -400,10 +466,10 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
400
466
|
};
|
|
401
467
|
return myBucket.putObject(params).promise();
|
|
402
468
|
});
|
|
403
|
-
_context3.next =
|
|
469
|
+
_context3.next = 20;
|
|
404
470
|
return Promise.all(promiseArray);
|
|
405
471
|
|
|
406
|
-
case
|
|
472
|
+
case 20:
|
|
407
473
|
// Eliminar el buffer base64 antes de enviar al endpoint para evitar error 413
|
|
408
474
|
data.articleData = data.articleData.map(function (_ref5) {
|
|
409
475
|
var src = _ref5.src,
|
|
@@ -415,7 +481,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
415
481
|
rest = (0, _objectWithoutProperties2.default)(_ref6, _excluded2);
|
|
416
482
|
return rest;
|
|
417
483
|
});
|
|
418
|
-
_context3.next =
|
|
484
|
+
_context3.next = 24;
|
|
419
485
|
return _axios.default.put(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, data, {
|
|
420
486
|
params: {
|
|
421
487
|
image: true,
|
|
@@ -426,37 +492,137 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
426
492
|
}
|
|
427
493
|
});
|
|
428
494
|
|
|
429
|
-
case
|
|
495
|
+
case 24:
|
|
430
496
|
res = _context3.sent;
|
|
431
497
|
|
|
432
|
-
if (res.data.statusCode === 200) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
payload: []
|
|
437
|
-
}); // Mostrar modal de éxito
|
|
498
|
+
if (!(res.data.statusCode === 200)) {
|
|
499
|
+
_context3.next = 49;
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
438
502
|
|
|
503
|
+
// Limpiar las imágenes actualizadas
|
|
504
|
+
dispatch({
|
|
505
|
+
type: "SET_UPDATED_IMAGES_VALUES",
|
|
506
|
+
payload: []
|
|
507
|
+
});
|
|
508
|
+
imageBody = JSON.parse(res.data.body);
|
|
509
|
+
newStatus = imageBody === null || imageBody === void 0 ? void 0 : imageBody.newStatus;
|
|
510
|
+
|
|
511
|
+
if (newStatus) {
|
|
512
|
+
productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
|
|
513
|
+
updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
|
|
514
|
+
images_status: newStatus,
|
|
515
|
+
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product12 = state.product) === null || _state$product12 === void 0 ? void 0 : _state$product12.statusByRetailer) || []).map(function (retailerStatus) {
|
|
516
|
+
return retailerStatus.service === "images" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
|
|
517
|
+
status: newStatus
|
|
518
|
+
}) : retailerStatus;
|
|
519
|
+
})
|
|
520
|
+
});
|
|
521
|
+
sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
|
|
439
522
|
dispatch({
|
|
440
|
-
type: "
|
|
441
|
-
payload:
|
|
442
|
-
show: true,
|
|
443
|
-
title: "",
|
|
444
|
-
message: "Imágenes guardadas con éxito",
|
|
445
|
-
image: _genericModalCheck.default
|
|
446
|
-
}
|
|
523
|
+
type: "UPDATE_IMAGES_STATUS",
|
|
524
|
+
payload: newStatus
|
|
447
525
|
});
|
|
448
|
-
|
|
526
|
+
dispatch({
|
|
527
|
+
type: "SET_SERVICES_DATA",
|
|
528
|
+
payload: (state.services_data || []).map(function (srv) {
|
|
529
|
+
var _state$active_retaile4;
|
|
530
|
+
|
|
531
|
+
return srv.service === "images" && srv.id_retailer === ((_state$active_retaile4 = state.active_retailer) === null || _state$active_retaile4 === void 0 ? void 0 : _state$active_retaile4.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
532
|
+
status: newStatus
|
|
533
|
+
}) : srv;
|
|
534
|
+
})
|
|
535
|
+
});
|
|
536
|
+
} // Refrescar images_values con datos reales del backend
|
|
537
|
+
|
|
449
538
|
|
|
450
|
-
_context3.
|
|
539
|
+
_context3.prev = 30;
|
|
540
|
+
_state$product13 = state.product, id_article = _state$product13.id_article, version = _state$product13.version;
|
|
541
|
+
_state$active_retaile5 = state.active_retailer, category = _state$active_retaile5.category, id_category = _state$active_retaile5.id_category, id_retailer = _state$active_retaile5.id_retailer;
|
|
542
|
+
_context3.next = 35;
|
|
543
|
+
return _axios.default.post("".concat(process.env.REACT_APP_ARTICLE_DATA_IMAGES_ENDPOINT, "?articleId=").concat(id_article, "&version=").concat(version), {
|
|
544
|
+
category: category,
|
|
545
|
+
retailersList: [id_retailer]
|
|
546
|
+
}, {
|
|
547
|
+
headers: {
|
|
548
|
+
Authorization: token
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
case 35:
|
|
553
|
+
imagesRes = _context3.sent;
|
|
554
|
+
freshImages = JSON.parse(imagesRes.data.body).data;
|
|
555
|
+
freshImages.values = freshImages === null || freshImages === void 0 ? void 0 : (_freshImages$values = freshImages.values) === null || _freshImages$values === void 0 ? void 0 : _freshImages$values.map(function (value) {
|
|
556
|
+
var _freshImages$inputs$f;
|
|
557
|
+
|
|
558
|
+
value.name = (_freshImages$inputs$f = freshImages.inputs.find(function (e) {
|
|
559
|
+
return e.id === value.image_id;
|
|
560
|
+
})) === null || _freshImages$inputs$f === void 0 ? void 0 : _freshImages$inputs$f.name;
|
|
561
|
+
return (0, _data.getImage)(value);
|
|
562
|
+
});
|
|
563
|
+
orderMap = freshImages.inputsByRetailer.flat().reduce(function (acc, item) {
|
|
564
|
+
acc[item.id_image] = item.order;
|
|
565
|
+
return acc;
|
|
566
|
+
}, {});
|
|
567
|
+
orderedValues = (0, _toConsumableArray2.default)(freshImages.values).sort(function (a, b) {
|
|
568
|
+
var _orderMap$a$image_id, _orderMap$b$image_id;
|
|
569
|
+
|
|
570
|
+
var orderA = (_orderMap$a$image_id = orderMap[a.image_id]) !== null && _orderMap$a$image_id !== void 0 ? _orderMap$a$image_id : Number.MAX_SAFE_INTEGER;
|
|
571
|
+
var orderB = (_orderMap$b$image_id = orderMap[b.image_id]) !== null && _orderMap$b$image_id !== void 0 ? _orderMap$b$image_id : Number.MAX_SAFE_INTEGER;
|
|
572
|
+
return orderA - orderB;
|
|
573
|
+
});
|
|
574
|
+
filteredValues = freshImages.values.filter(function (value) {
|
|
575
|
+
return freshImages.inputsByRetailer.some(function (retailerInput) {
|
|
576
|
+
return retailerInput.some(function (input) {
|
|
577
|
+
return input.id_retailer === id_retailer && input.id_image === value.image_id;
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
dispatch({
|
|
582
|
+
type: "SET_IMAGES_VALUES",
|
|
583
|
+
payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, freshImages), {}, {
|
|
584
|
+
values: filteredValues
|
|
585
|
+
})
|
|
586
|
+
});
|
|
587
|
+
dispatch({
|
|
588
|
+
type: "SET_SERVICES",
|
|
589
|
+
payload: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.services), {}, {
|
|
590
|
+
images: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, freshImages), {}, {
|
|
591
|
+
values: orderedValues
|
|
592
|
+
})
|
|
593
|
+
})
|
|
594
|
+
});
|
|
595
|
+
_context3.next = 48;
|
|
596
|
+
break;
|
|
597
|
+
|
|
598
|
+
case 45:
|
|
599
|
+
_context3.prev = 45;
|
|
600
|
+
_context3.t0 = _context3["catch"](30);
|
|
601
|
+
console.log("Error al refrescar images_values:", _context3.t0);
|
|
602
|
+
|
|
603
|
+
case 48:
|
|
604
|
+
// Mostrar modal de éxito
|
|
605
|
+
dispatch({
|
|
606
|
+
type: "SET_MODAL",
|
|
607
|
+
payload: {
|
|
608
|
+
show: true,
|
|
609
|
+
title: "",
|
|
610
|
+
message: "Imágenes guardadas con éxito",
|
|
611
|
+
image: _genericModalCheck.default
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
case 49:
|
|
616
|
+
_context3.next = 56;
|
|
451
617
|
break;
|
|
452
618
|
|
|
453
|
-
case
|
|
454
|
-
_context3.prev =
|
|
455
|
-
_context3.
|
|
456
|
-
console.log(_context3.
|
|
619
|
+
case 51:
|
|
620
|
+
_context3.prev = 51;
|
|
621
|
+
_context3.t1 = _context3["catch"](16);
|
|
622
|
+
console.log(_context3.t1);
|
|
457
623
|
dispatch({
|
|
458
624
|
type: "SET_ERRORS",
|
|
459
|
-
payload: [].concat((0, _toConsumableArray2.default)(state.errors), [_context3.
|
|
625
|
+
payload: [].concat((0, _toConsumableArray2.default)(state.errors), [_context3.t1])
|
|
460
626
|
});
|
|
461
627
|
dispatch({
|
|
462
628
|
type: "SET_MODAL",
|
|
@@ -468,19 +634,19 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
468
634
|
}
|
|
469
635
|
});
|
|
470
636
|
|
|
471
|
-
case
|
|
472
|
-
_context3.prev =
|
|
637
|
+
case 56:
|
|
638
|
+
_context3.prev = 56;
|
|
473
639
|
dispatch({
|
|
474
640
|
type: "SET_SAVING",
|
|
475
641
|
payload: false
|
|
476
642
|
});
|
|
477
|
-
return _context3.finish(
|
|
643
|
+
return _context3.finish(56);
|
|
478
644
|
|
|
479
|
-
case
|
|
480
|
-
_context3.next =
|
|
645
|
+
case 59:
|
|
646
|
+
_context3.next = 62;
|
|
481
647
|
break;
|
|
482
648
|
|
|
483
|
-
case
|
|
649
|
+
case 61:
|
|
484
650
|
dispatch({
|
|
485
651
|
type: "SET_MODAL",
|
|
486
652
|
payload: {
|
|
@@ -491,12 +657,12 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
491
657
|
}
|
|
492
658
|
});
|
|
493
659
|
|
|
494
|
-
case
|
|
660
|
+
case 62:
|
|
495
661
|
case "end":
|
|
496
662
|
return _context3.stop();
|
|
497
663
|
}
|
|
498
664
|
}
|
|
499
|
-
}, _callee3, null, [[
|
|
665
|
+
}, _callee3, null, [[16, 51, 56, 59], [30, 45]]);
|
|
500
666
|
}));
|
|
501
667
|
|
|
502
668
|
return function updateImages(_x3) {
|
|
@@ -506,9 +672,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
506
672
|
|
|
507
673
|
var saveImageAttrs = /*#__PURE__*/function () {
|
|
508
674
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(token) {
|
|
509
|
-
var _state$images_values$, _state$images_values2, _state$images_values3, _state$
|
|
675
|
+
var _state$images_values$, _state$images_values2, _state$images_values3, _state$product14, _state$product15, _state$product16;
|
|
510
676
|
|
|
511
|
-
var activeImage, attrForImgs, data, _state$
|
|
677
|
+
var activeImage, attrForImgs, data, _state$product17, _state$product18, res, attrBody, newStatus, _state$product19, productFromLocalStorage, updatedProduct;
|
|
512
678
|
|
|
513
679
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
514
680
|
while (1) {
|
|
@@ -529,7 +695,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
529
695
|
activeImage = state.images_values.values[state.current_image];
|
|
530
696
|
attrForImgs = (_state$images_values$ = (_state$images_values2 = state.images_values) === null || _state$images_values2 === void 0 ? void 0 : (_state$images_values3 = _state$images_values2.attrForImgs) === null || _state$images_values3 === void 0 ? void 0 : _state$images_values3.general) !== null && _state$images_values$ !== void 0 ? _state$images_values$ : [];
|
|
531
697
|
data = {
|
|
532
|
-
articleId: (_state$
|
|
698
|
+
articleId: (_state$product14 = state.product) === null || _state$product14 === void 0 ? void 0 : _state$product14.id_article,
|
|
533
699
|
attrReqImgs: attrForImgs.map(function (e) {
|
|
534
700
|
var _e$value2;
|
|
535
701
|
|
|
@@ -542,8 +708,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
542
708
|
updateImages: activeImage ? [activeImage] : []
|
|
543
709
|
};
|
|
544
710
|
|
|
545
|
-
if ((_state$
|
|
546
|
-
data.orderId = ((_state$
|
|
711
|
+
if ((_state$product15 = state.product) !== null && _state$product15 !== void 0 && _state$product15.orderId || (_state$product16 = state.product) !== null && _state$product16 !== void 0 && _state$product16.id_order) {
|
|
712
|
+
data.orderId = ((_state$product17 = state.product) === null || _state$product17 === void 0 ? void 0 : _state$product17.orderId) || ((_state$product18 = state.product) === null || _state$product18 === void 0 ? void 0 : _state$product18.id_order);
|
|
547
713
|
}
|
|
548
714
|
|
|
549
715
|
_context4.prev = 7;
|
|
@@ -566,6 +732,36 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
566
732
|
type: "SET_UPDATED_ATTR_FOR_IMGS",
|
|
567
733
|
payload: []
|
|
568
734
|
});
|
|
735
|
+
attrBody = JSON.parse(res.data.body);
|
|
736
|
+
newStatus = attrBody === null || attrBody === void 0 ? void 0 : attrBody.newStatus;
|
|
737
|
+
|
|
738
|
+
if (newStatus) {
|
|
739
|
+
productFromLocalStorage = JSON.parse(sessionStorage.getItem("productSelected"));
|
|
740
|
+
updatedProduct = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, productFromLocalStorage || state.product), {}, {
|
|
741
|
+
images_status: newStatus,
|
|
742
|
+
statusByRetailer: ((productFromLocalStorage === null || productFromLocalStorage === void 0 ? void 0 : productFromLocalStorage.statusByRetailer) || ((_state$product19 = state.product) === null || _state$product19 === void 0 ? void 0 : _state$product19.statusByRetailer) || []).map(function (retailerStatus) {
|
|
743
|
+
return retailerStatus.service === "images" ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, retailerStatus), {}, {
|
|
744
|
+
status: newStatus
|
|
745
|
+
}) : retailerStatus;
|
|
746
|
+
})
|
|
747
|
+
});
|
|
748
|
+
sessionStorage.setItem("productSelected", JSON.stringify(updatedProduct));
|
|
749
|
+
dispatch({
|
|
750
|
+
type: "UPDATE_IMAGES_STATUS",
|
|
751
|
+
payload: newStatus
|
|
752
|
+
});
|
|
753
|
+
dispatch({
|
|
754
|
+
type: "SET_SERVICES_DATA",
|
|
755
|
+
payload: (state.services_data || []).map(function (srv) {
|
|
756
|
+
var _state$active_retaile6;
|
|
757
|
+
|
|
758
|
+
return srv.service === "images" && srv.id_retailer === ((_state$active_retaile6 = state.active_retailer) === null || _state$active_retaile6 === void 0 ? void 0 : _state$active_retaile6.id_retailer) ? (0, _objectSpread2.default)((0, _objectSpread2.default)({}, srv), {}, {
|
|
759
|
+
status: newStatus
|
|
760
|
+
}) : srv;
|
|
761
|
+
})
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
|
|
569
765
|
dispatch({
|
|
570
766
|
type: "SET_MODAL",
|
|
571
767
|
payload: {
|
|
@@ -620,9 +816,9 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
620
816
|
}();
|
|
621
817
|
|
|
622
818
|
var handleOnDownloadImages = function handleOnDownloadImages() {
|
|
623
|
-
var _state$
|
|
819
|
+
var _state$product20, _state$product21, _state$product21$arti, _state$images_values4, _state$images_values5;
|
|
624
820
|
|
|
625
|
-
var upc = ((_state$
|
|
821
|
+
var upc = ((_state$product20 = state.product) === null || _state$product20 === void 0 ? void 0 : _state$product20.upc) || ((_state$product21 = state.product) === null || _state$product21 === void 0 ? void 0 : (_state$product21$arti = _state$product21.article) === null || _state$product21$arti === void 0 ? void 0 : _state$product21$arti.upc);
|
|
626
822
|
state.selected_images.length > 0 ? state.selected_images.forEach(function (e) {
|
|
627
823
|
if (e.id) {
|
|
628
824
|
saveAs("https://".concat(process.env.REACT_APP_IMAGES_BUCKET, ".s3.amazonaws.com/").concat(e.srcDB), "".concat(upc, "_").concat(e.name, ".").concat(e.ext));
|
|
@@ -636,7 +832,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
636
832
|
|
|
637
833
|
var deleteImages = /*#__PURE__*/function () {
|
|
638
834
|
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(token) {
|
|
639
|
-
var imgsInBack, _state$
|
|
835
|
+
var imgsInBack, _state$product22, data;
|
|
640
836
|
|
|
641
837
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
642
838
|
while (1) {
|
|
@@ -657,7 +853,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
657
853
|
}
|
|
658
854
|
|
|
659
855
|
data = {
|
|
660
|
-
articleId: (_state$
|
|
856
|
+
articleId: (_state$product22 = state.product) === null || _state$product22 === void 0 ? void 0 : _state$product22.id_article,
|
|
661
857
|
deleteImages: imgsInBack
|
|
662
858
|
};
|
|
663
859
|
_context5.prev = 4;
|
|
@@ -737,7 +933,7 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
737
933
|
|
|
738
934
|
var createComment = /*#__PURE__*/function () {
|
|
739
935
|
var _ref9 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(body, token) {
|
|
740
|
-
var _state$
|
|
936
|
+
var _state$product23, _state$product24, _state$product25;
|
|
741
937
|
|
|
742
938
|
var concept, data;
|
|
743
939
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
@@ -746,8 +942,8 @@ var ProviderProductEditionProvider = function ProviderProductEditionProvider(_re
|
|
|
746
942
|
case 0:
|
|
747
943
|
concept = (0, _utils.getConceptByTab)(state.active_tab);
|
|
748
944
|
data = {
|
|
749
|
-
articleId: (_state$
|
|
750
|
-
orderId: ((_state$
|
|
945
|
+
articleId: (_state$product23 = state.product) === null || _state$product23 === void 0 ? void 0 : _state$product23.id_article,
|
|
946
|
+
orderId: ((_state$product24 = state.product) === null || _state$product24 === void 0 ? void 0 : _state$product24.orderId) || ((_state$product25 = state.product) === null || _state$product25 === void 0 ? void 0 : _state$product25.id_order),
|
|
751
947
|
message: body,
|
|
752
948
|
concept: concept,
|
|
753
949
|
version: state.product.version
|
|
@@ -811,5 +1007,10 @@ var useProviderProductEdition = function useProviderProductEdition() {
|
|
|
811
1007
|
|
|
812
1008
|
return context;
|
|
813
1009
|
};
|
|
1010
|
+
/*
|
|
1011
|
+
src: "https://d24s337exbt5zr.cloudfront.net/eyJidWNrZXQiOiJjb250ZW50LW1hbmFnZW1lbnQtaW1hZ2VzLXByb2QiLCJrZXkiOiJpZC0xNDQ3MTEvMy8xLTRjZGVjNTZkLTVjYWMtNGY3NC04ZWM0LWZmMmRmOTFjZDdiOS5qcGciLCJlZGl0cyI6eyJyZXNpemUiOnsid2lkdGgiOjEwMDAsImhlaWdodCI6MTAwMCwiZml0IjoiY29udGFpbiIsImJhY2tncm91bmQiOnsiciI6MjU1LCJnIjoyNTUsImIiOjI1NSwiYWxwaGEiOjF9fX19"
|
|
1012
|
+
srcDB: "id-144711/3/1-4cdec56d-5cac-4f74-8ec4-ff2df91cd7b9.jpg"
|
|
1013
|
+
*/
|
|
1014
|
+
|
|
814
1015
|
|
|
815
1016
|
exports.useProviderProductEdition = useProviderProductEdition;
|