contentoh-components-library 21.0.80 → 21.0.83
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/molecules/GalleryElement/index.js +9 -6
- package/dist/components/molecules/StatusAsignationInfo/index.js +4 -1
- package/dist/components/molecules/TableHeader/styles.js +1 -1
- package/dist/components/pages/ProviderProductEdition/index.js +63 -30
- package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +53 -38
- package/dist/components/pages/RetailerProductEdition/index.js +72 -57
- package/package.json +1 -1
- package/src/components/molecules/GalleryElement/index.js +8 -5
- package/src/components/molecules/StatusAsignationInfo/index.js +1 -0
- package/src/components/molecules/TableHeader/styles.js +4 -1
- package/src/components/pages/ProviderProductEdition/index.js +54 -23
- package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +53 -38
- package/src/components/pages/RetailerProductEdition/index.js +64 -43
|
@@ -34,14 +34,15 @@ var GalleryElement = function GalleryElement(_ref) {
|
|
|
34
34
|
_ref$id = _ref.id,
|
|
35
35
|
id = _ref$id === void 0 ? "chk-default" : _ref$id,
|
|
36
36
|
label = _ref.label,
|
|
37
|
-
|
|
37
|
+
number = _ref.number,
|
|
38
38
|
imageInputs = _ref.imageInputs,
|
|
39
39
|
imageType = _ref.imageType,
|
|
40
40
|
imagePackagingType = _ref.imagePackagingType,
|
|
41
41
|
changeImage = _ref.changeImage,
|
|
42
42
|
selectedImages = _ref.selectedImages,
|
|
43
43
|
setSelectedImages = _ref.setSelectedImages,
|
|
44
|
-
setCheckAll = _ref.setCheckAll
|
|
44
|
+
setCheckAll = _ref.setCheckAll,
|
|
45
|
+
setSocketType = _ref.setSocketType;
|
|
45
46
|
|
|
46
47
|
var _useState = (0, _react.useState)(validation),
|
|
47
48
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -110,14 +111,16 @@ var GalleryElement = function GalleryElement(_ref) {
|
|
|
110
111
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
|
|
111
112
|
width: "100%",
|
|
112
113
|
placeholder: "Tipo de toma",
|
|
113
|
-
options: imageInputs
|
|
114
|
+
options: imageInputs === null || imageInputs === void 0 ? void 0 : imageInputs.filter(function (img) {
|
|
115
|
+
return img.value === image.image_id || !img.active;
|
|
116
|
+
}),
|
|
114
117
|
valueSelected: image.image_id,
|
|
115
118
|
onChange: function onChange(e) {
|
|
116
119
|
changeImage({
|
|
117
120
|
action: "changeImageInfo",
|
|
118
121
|
attribute: "image_id",
|
|
119
122
|
value: +e.target.value,
|
|
120
|
-
index:
|
|
123
|
+
index: number
|
|
121
124
|
});
|
|
122
125
|
}
|
|
123
126
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
|
|
@@ -130,7 +133,7 @@ var GalleryElement = function GalleryElement(_ref) {
|
|
|
130
133
|
action: "changeImageInfo",
|
|
131
134
|
attribute: "image_type",
|
|
132
135
|
value: +e.target.value,
|
|
133
|
-
index:
|
|
136
|
+
index: number
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
|
|
@@ -143,7 +146,7 @@ var GalleryElement = function GalleryElement(_ref) {
|
|
|
143
146
|
action: "changeImageInfo",
|
|
144
147
|
attribute: "packing_type",
|
|
145
148
|
value: +e.target.value,
|
|
146
|
-
index:
|
|
149
|
+
index: number
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
})]
|
|
@@ -75,7 +75,10 @@ var StatusAsignationInfo = function StatusAsignationInfo(_ref) {
|
|
|
75
75
|
}, [showAsignationPanel]);
|
|
76
76
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
77
77
|
id: id,
|
|
78
|
-
children: [
|
|
78
|
+
children: [status !== "-" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.StatusTag, {
|
|
79
|
+
statusType: status,
|
|
80
|
+
ovalForm: true
|
|
81
|
+
}), showSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GeneralButton.Button, {
|
|
79
82
|
buttonType: "circular-button save-button",
|
|
80
83
|
onClick: onClickSave
|
|
81
84
|
}), imagesSection && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -15,6 +15,6 @@ var _variables = require("../../../global-files/variables");
|
|
|
15
15
|
|
|
16
16
|
var _templateObject;
|
|
17
17
|
|
|
18
|
-
var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: space-between;\n padding-bottom: 5px;\n border-bottom: 1px solid ", ";\n\n .input-name-header {\n overflow: auto;\n max-width: 40%;\n white-space: nowrap;\n }\n .status-asignation-info {\n display: flex;\n align-items: center;\n\n * + * {\n margin-left: 5px;\n }\n }\n\n & + * {\n margin-top: 4px;\n }\n"])), _variables.GlobalColors.s2);
|
|
18
|
+
var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: space-between;\n padding-bottom: 5px;\n border-bottom: 1px solid ", ";\n\n .input-name-header {\n overflow-x: auto;\n max-width: 40%;\n white-space: nowrap;\n height: 23px;\n line-height: 23px;\n text-overflow: initial;\n }\n .status-asignation-info {\n display: flex;\n align-items: center;\n\n * + * {\n margin-left: 5px;\n }\n }\n\n & + * {\n margin-top: 4px;\n }\n"])), _variables.GlobalColors.s2);
|
|
19
19
|
|
|
20
20
|
exports.Container = Container;
|
|
@@ -439,6 +439,11 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
439
439
|
modalViewTextArea = _useState78[0],
|
|
440
440
|
setModalViewTextArea = _useState78[1];
|
|
441
441
|
|
|
442
|
+
var _useState79 = (0, _react.useState)(null),
|
|
443
|
+
_useState80 = (0, _slicedToArray2.default)(_useState79, 2),
|
|
444
|
+
socketType = _useState80[0],
|
|
445
|
+
setSocketType = _useState80[1];
|
|
446
|
+
|
|
442
447
|
(0, _react.useEffect)(function () {
|
|
443
448
|
checkAll && setSelectedImages(images.values);
|
|
444
449
|
}, [checkAll]);
|
|
@@ -462,7 +467,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
462
467
|
|
|
463
468
|
setImages({
|
|
464
469
|
action: "init",
|
|
465
|
-
init: services[2]
|
|
470
|
+
init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2]
|
|
466
471
|
});
|
|
467
472
|
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);
|
|
468
473
|
setActiveRetailer(product.retailers ? product.retailers[0] : product.retailersAvailable[0]);
|
|
@@ -684,15 +689,9 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
684
689
|
}, [activeRetailer, services]);
|
|
685
690
|
|
|
686
691
|
var thumbs = function thumbs() {
|
|
687
|
-
var _images$
|
|
692
|
+
var _images$imageType, _images$imagePackagin, _images$values;
|
|
688
693
|
|
|
689
|
-
var imageInputs =
|
|
690
|
-
return {
|
|
691
|
-
value: e === null || e === void 0 ? void 0 : e.id,
|
|
692
|
-
name: e === null || e === void 0 ? void 0 : e.name,
|
|
693
|
-
required: e === null || e === void 0 ? void 0 : e.required
|
|
694
|
-
};
|
|
695
|
-
});
|
|
694
|
+
var imageInputs = socketType.slice();
|
|
696
695
|
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) {
|
|
697
696
|
return {
|
|
698
697
|
value: e === null || e === void 0 ? void 0 : e.id,
|
|
@@ -711,7 +710,8 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
711
710
|
image: image,
|
|
712
711
|
gridLayout: imageLayout,
|
|
713
712
|
id: "gallery-element-" + index,
|
|
714
|
-
index: index,
|
|
713
|
+
index: index + "-" + image.name,
|
|
714
|
+
number: index,
|
|
715
715
|
imageType: imageType,
|
|
716
716
|
imagePackagingType: imagePackagingType,
|
|
717
717
|
imageInputs: imageInputs,
|
|
@@ -722,6 +722,22 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
722
722
|
});
|
|
723
723
|
};
|
|
724
724
|
|
|
725
|
+
(0, _react.useEffect)(function () {
|
|
726
|
+
var _images$inputs;
|
|
727
|
+
|
|
728
|
+
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) {
|
|
729
|
+
return {
|
|
730
|
+
value: e === null || e === void 0 ? void 0 : e.id,
|
|
731
|
+
name: e === null || e === void 0 ? void 0 : e.name,
|
|
732
|
+
required: e === null || e === void 0 ? void 0 : e.required,
|
|
733
|
+
active: images === null || images === void 0 ? void 0 : images.values.some(function (value) {
|
|
734
|
+
return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
|
|
735
|
+
})
|
|
736
|
+
};
|
|
737
|
+
});
|
|
738
|
+
setSocketType(imageInputs);
|
|
739
|
+
}, [images]);
|
|
740
|
+
|
|
725
741
|
var saveDescriptions = /*#__PURE__*/function () {
|
|
726
742
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
727
743
|
var productTemp, dataObject;
|
|
@@ -950,7 +966,7 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
950
966
|
switch (_context9.prev = _context9.next) {
|
|
951
967
|
case 0:
|
|
952
968
|
if (!imagesUploaded) {
|
|
953
|
-
_context9.next =
|
|
969
|
+
_context9.next = 14;
|
|
954
970
|
break;
|
|
955
971
|
}
|
|
956
972
|
|
|
@@ -973,21 +989,22 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
973
989
|
|
|
974
990
|
case 6:
|
|
975
991
|
setMessage("Imágenes guardadas con éxito");
|
|
992
|
+
sessionStorage.removeItem("imagesList");
|
|
976
993
|
loadData();
|
|
977
|
-
_context9.next =
|
|
994
|
+
_context9.next = 14;
|
|
978
995
|
break;
|
|
979
996
|
|
|
980
|
-
case
|
|
981
|
-
_context9.prev =
|
|
997
|
+
case 11:
|
|
998
|
+
_context9.prev = 11;
|
|
982
999
|
_context9.t0 = _context9["catch"](3);
|
|
983
1000
|
console.log(_context9.t0);
|
|
984
1001
|
|
|
985
|
-
case
|
|
1002
|
+
case 14:
|
|
986
1003
|
case "end":
|
|
987
1004
|
return _context9.stop();
|
|
988
1005
|
}
|
|
989
1006
|
}
|
|
990
|
-
}, _callee9, null, [[3,
|
|
1007
|
+
}, _callee9, null, [[3, 11]]);
|
|
991
1008
|
})), [dataImages, imagesUploaded]);
|
|
992
1009
|
|
|
993
1010
|
var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {// const srv = servicesData.filter((serv) => serv.service === getConcept(tab));
|
|
@@ -1422,24 +1439,39 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
1422
1439
|
};
|
|
1423
1440
|
|
|
1424
1441
|
var deleteImages = function deleteImages() {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1442
|
+
setLoading(true);
|
|
1443
|
+
var imagesTemp = images;
|
|
1444
|
+
var values = images.values;
|
|
1445
|
+
var imgsInBack = [];
|
|
1446
|
+
selectedImages.forEach(function (selectedImg) {
|
|
1447
|
+
if (selectedImg.id) imgsInBack.push(selectedImg);
|
|
1448
|
+
});
|
|
1449
|
+
var imgsLeft = values.filter(function (value) {
|
|
1450
|
+
return selectedImages.indexOf(value) === -1;
|
|
1451
|
+
});
|
|
1452
|
+
imagesTemp.values = imgsLeft;
|
|
1429
1453
|
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
});
|
|
1454
|
+
if (imgsInBack.length > 0) {
|
|
1455
|
+
var data = {
|
|
1456
|
+
articleId: product.article.id_article,
|
|
1457
|
+
deleteImages: selectedImages
|
|
1458
|
+
};
|
|
1436
1459
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1460
|
+
try {
|
|
1461
|
+
_axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), data, {
|
|
1462
|
+
headers: {
|
|
1463
|
+
Authorization: token
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
} catch (err) {
|
|
1467
|
+
console.log(err);
|
|
1468
|
+
}
|
|
1440
1469
|
}
|
|
1441
1470
|
|
|
1471
|
+
sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
|
|
1472
|
+
loadData();
|
|
1442
1473
|
setMessage("");
|
|
1474
|
+
setComponentsArray([]);
|
|
1443
1475
|
};
|
|
1444
1476
|
|
|
1445
1477
|
var askToDeleteImages = function askToDeleteImages() {
|
|
@@ -1459,7 +1491,8 @@ var ProviderProductEdition = function ProviderProductEdition(_ref) {
|
|
|
1459
1491
|
buttonType: "general-button-default",
|
|
1460
1492
|
label: "Aceptar",
|
|
1461
1493
|
onClick: function onClick() {
|
|
1462
|
-
|
|
1494
|
+
setMessage("");
|
|
1495
|
+
deleteImages();
|
|
1463
1496
|
}
|
|
1464
1497
|
}, "3")]);
|
|
1465
1498
|
}
|
|
@@ -36,46 +36,61 @@ RetailerProductEditionDefault.args = {
|
|
|
36
36
|
category: 846,
|
|
37
37
|
version: 2,
|
|
38
38
|
productSelected: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
services: {
|
|
40
|
+
datasheets: 1,
|
|
41
|
+
descriptions: 1,
|
|
42
|
+
images: 1
|
|
43
|
+
},
|
|
44
|
+
orderId: 233,
|
|
45
|
+
status: "QF",
|
|
42
46
|
datasheet_status: "QF",
|
|
43
47
|
prio: "none",
|
|
44
48
|
version: 2,
|
|
45
|
-
description_status: "
|
|
46
|
-
images_status: "
|
|
47
|
-
brand: null,
|
|
48
|
-
missing: {
|
|
49
|
-
datasheet: 0,
|
|
50
|
-
descriptions: 0,
|
|
51
|
-
images: 0
|
|
52
|
-
},
|
|
49
|
+
description_status: "QF",
|
|
50
|
+
images_status: "QF",
|
|
53
51
|
article: {
|
|
54
|
-
|
|
52
|
+
id_article: 190965,
|
|
53
|
+
id_category: "697",
|
|
54
|
+
name: "Shampoo hidratante",
|
|
55
|
+
upc: "6545345",
|
|
56
|
+
timestamp: "2022-06-10T15:05:56.000Z",
|
|
57
|
+
id_user: 28,
|
|
58
|
+
status: "NULL",
|
|
59
|
+
active: 1,
|
|
60
|
+
company_id: 1,
|
|
55
61
|
company_name: "COMPANY DEV",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
country: "México",
|
|
63
|
+
id_order: 233,
|
|
64
|
+
id_datasheet_especialist: 54,
|
|
65
|
+
id_datasheet_facilitator: 52,
|
|
66
|
+
id_description_especialist: 54,
|
|
67
|
+
id_description_facilitator: 52,
|
|
68
|
+
id_images_especialist: 55,
|
|
69
|
+
id_images_facilitator: 53,
|
|
70
|
+
id_auditor: 30,
|
|
71
|
+
id_recepcionist: null,
|
|
72
|
+
category: "SALUD Y BELLEZA|CUIDADO DEL CABELLO|SHAMPOOS Y ACONDICIONADORES",
|
|
73
|
+
missingAttributes: null,
|
|
74
|
+
missingDescriptions: null,
|
|
75
|
+
missingImages: null
|
|
61
76
|
},
|
|
62
77
|
retailers: [{
|
|
63
|
-
id:
|
|
64
|
-
name: "Walmart
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
id: 4,
|
|
79
|
+
name: "Walmart Super y Superama",
|
|
80
|
+
country: "México",
|
|
81
|
+
id_region: 1,
|
|
82
|
+
active: 1,
|
|
83
|
+
percentage: 100
|
|
84
|
+
}, {
|
|
85
|
+
id: 26,
|
|
86
|
+
name: "Mercado Libre",
|
|
87
|
+
country: "México",
|
|
88
|
+
id_region: 1,
|
|
89
|
+
active: 1,
|
|
90
|
+
percentage: 100
|
|
75
91
|
}],
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
version_status: "IN_PROGRESS"
|
|
92
|
+
country: "México",
|
|
93
|
+
upc: "6545345"
|
|
79
94
|
},
|
|
80
95
|
location: {
|
|
81
96
|
product: {
|
|
@@ -84,22 +99,22 @@ RetailerProductEditionDefault.args = {
|
|
|
84
99
|
}
|
|
85
100
|
},
|
|
86
101
|
user: {
|
|
87
|
-
id_user:
|
|
88
|
-
name: "
|
|
102
|
+
id_user: 53,
|
|
103
|
+
name: "FACILITADOR ED PRUEBA",
|
|
89
104
|
last_name: "",
|
|
90
|
-
email: "
|
|
105
|
+
email: "arojas@contentoh.com",
|
|
91
106
|
position: null,
|
|
92
107
|
telephone: null,
|
|
93
108
|
country: null,
|
|
94
109
|
id_company: 2,
|
|
95
|
-
id_cognito: "
|
|
110
|
+
id_cognito: "c106e141-e221-49e8-a382-ce99385c6d88",
|
|
96
111
|
birth_Date: null,
|
|
97
112
|
about_me: null,
|
|
98
113
|
zip_code: null,
|
|
99
114
|
address: null,
|
|
100
115
|
job: null,
|
|
101
116
|
id_stripe: null,
|
|
102
|
-
id_role:
|
|
117
|
+
id_role: 5,
|
|
103
118
|
active: 1,
|
|
104
119
|
is_retailer: 0,
|
|
105
120
|
membership: {
|
|
@@ -113,6 +128,6 @@ RetailerProductEditionDefault.args = {
|
|
|
113
128
|
products_limit: "3",
|
|
114
129
|
type: "PyMES"
|
|
115
130
|
},
|
|
116
|
-
src: "https://content-management-profile.s3.amazonaws.com/id-
|
|
131
|
+
src: "https://content-management-profile.s3.amazonaws.com/id-53/53.png?1655161876316"
|
|
117
132
|
}
|
|
118
133
|
};
|
|
@@ -123,7 +123,7 @@ var myBucket = new _awsSdk.default.S3({
|
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
126
|
-
var _product$retailers, _product$
|
|
126
|
+
var _product$retailers, _product$services2, _datasheets$, _datasheets$$data, _product$article13;
|
|
127
127
|
|
|
128
128
|
var tabsSections = _ref.tabsSections,
|
|
129
129
|
_ref$productSelected = _ref.productSelected,
|
|
@@ -367,6 +367,11 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
367
367
|
statusArray = _useState64[0],
|
|
368
368
|
setStatusArray = _useState64[1];
|
|
369
369
|
|
|
370
|
+
var _useState65 = (0, _react.useState)(null),
|
|
371
|
+
_useState66 = (0, _slicedToArray2.default)(_useState65, 2),
|
|
372
|
+
socketType = _useState66[0],
|
|
373
|
+
setSocketType = _useState66[1];
|
|
374
|
+
|
|
370
375
|
(0, _react.useEffect)(function () {
|
|
371
376
|
checkAll && setSelectedImages(images.values);
|
|
372
377
|
}, [checkAll]);
|
|
@@ -390,7 +395,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
390
395
|
|
|
391
396
|
setImages({
|
|
392
397
|
action: "init",
|
|
393
|
-
init: services[2]
|
|
398
|
+
init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2]
|
|
394
399
|
});
|
|
395
400
|
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);
|
|
396
401
|
setActiveRetailer(product.retailers ? product.retailers[0] : product.retailersAvailable[0]);
|
|
@@ -424,7 +429,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
424
429
|
switch (_context3.prev = _context3.next) {
|
|
425
430
|
case 0:
|
|
426
431
|
_context3.next = 2;
|
|
427
|
-
return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_article, "&orderId=").concat(product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_order, "&end=true"));
|
|
432
|
+
return _axios.default.get("".concat(process.env.REACT_APP_SERVICES_ENDPOINT, "?articleId=").concat(product === null || product === void 0 ? void 0 : (_product$article3 = product.article) === null || _product$article3 === void 0 ? void 0 : _product$article3.id_article, "&orderId=").concat((product === null || product === void 0 ? void 0 : (_product$article4 = product.article) === null || _product$article4 === void 0 ? void 0 : _product$article4.id_order) || product.orderId, "&end=true"));
|
|
428
433
|
|
|
429
434
|
case 2:
|
|
430
435
|
servicesResponse = _context3.sent;
|
|
@@ -629,15 +634,9 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
629
634
|
}, [activeRetailer, services]);
|
|
630
635
|
|
|
631
636
|
var thumbs = function thumbs() {
|
|
632
|
-
var _images$
|
|
637
|
+
var _images$imageType, _images$imagePackagin, _images$values;
|
|
633
638
|
|
|
634
|
-
var imageInputs =
|
|
635
|
-
return {
|
|
636
|
-
value: e === null || e === void 0 ? void 0 : e.id,
|
|
637
|
-
name: e === null || e === void 0 ? void 0 : e.name,
|
|
638
|
-
required: e === null || e === void 0 ? void 0 : e.required
|
|
639
|
-
};
|
|
640
|
-
});
|
|
639
|
+
var imageInputs = socketType.slice();
|
|
641
640
|
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) {
|
|
642
641
|
return {
|
|
643
642
|
value: e === null || e === void 0 ? void 0 : e.id,
|
|
@@ -656,10 +655,12 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
656
655
|
image: image,
|
|
657
656
|
gridLayout: imageLayout,
|
|
658
657
|
id: "gallery-element-" + index,
|
|
659
|
-
index: index,
|
|
658
|
+
index: index + "-" + image.name,
|
|
659
|
+
number: index,
|
|
660
660
|
imageType: imageType,
|
|
661
661
|
imagePackagingType: imagePackagingType,
|
|
662
662
|
imageInputs: imageInputs,
|
|
663
|
+
setSocketType: setSocketType,
|
|
663
664
|
changeImage: setImages,
|
|
664
665
|
selectedImages: selectedImages,
|
|
665
666
|
setSelectedImages: setSelectedImages
|
|
@@ -776,6 +777,21 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
776
777
|
};
|
|
777
778
|
}();
|
|
778
779
|
|
|
780
|
+
(0, _react.useEffect)(function () {
|
|
781
|
+
var _images$inputs;
|
|
782
|
+
|
|
783
|
+
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) {
|
|
784
|
+
return {
|
|
785
|
+
value: e === null || e === void 0 ? void 0 : e.id,
|
|
786
|
+
name: e === null || e === void 0 ? void 0 : e.name,
|
|
787
|
+
required: e === null || e === void 0 ? void 0 : e.required,
|
|
788
|
+
active: images === null || images === void 0 ? void 0 : images.values.some(function (value) {
|
|
789
|
+
return (value === null || value === void 0 ? void 0 : value.image_id) === (e === null || e === void 0 ? void 0 : e.id);
|
|
790
|
+
})
|
|
791
|
+
};
|
|
792
|
+
});
|
|
793
|
+
setSocketType(imageInputs);
|
|
794
|
+
}, [images]);
|
|
779
795
|
var updateImages = (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
780
796
|
var _images$values2, _product$article10, _data$articleData, _data$articleData2, _data$updateImages;
|
|
781
797
|
|
|
@@ -900,7 +916,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
900
916
|
switch (_context9.prev = _context9.next) {
|
|
901
917
|
case 0:
|
|
902
918
|
if (!imagesUploaded) {
|
|
903
|
-
_context9.next =
|
|
919
|
+
_context9.next = 14;
|
|
904
920
|
break;
|
|
905
921
|
}
|
|
906
922
|
|
|
@@ -923,21 +939,22 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
923
939
|
|
|
924
940
|
case 6:
|
|
925
941
|
setMessage("Imágenes guardadas con éxito");
|
|
942
|
+
sessionStorage.removeItem("imagesList");
|
|
926
943
|
loadData();
|
|
927
|
-
_context9.next =
|
|
944
|
+
_context9.next = 14;
|
|
928
945
|
break;
|
|
929
946
|
|
|
930
|
-
case
|
|
931
|
-
_context9.prev =
|
|
947
|
+
case 11:
|
|
948
|
+
_context9.prev = 11;
|
|
932
949
|
_context9.t0 = _context9["catch"](3);
|
|
933
950
|
console.log(_context9.t0);
|
|
934
951
|
|
|
935
|
-
case
|
|
952
|
+
case 14:
|
|
936
953
|
case "end":
|
|
937
954
|
return _context9.stop();
|
|
938
955
|
}
|
|
939
956
|
}
|
|
940
|
-
}, _callee9, null, [[3,
|
|
957
|
+
}, _callee9, null, [[3, 11]]);
|
|
941
958
|
})), [dataImages, imagesUploaded]);
|
|
942
959
|
|
|
943
960
|
var evaluationFinished = function evaluationFinished(userId, tab, statusArray) {
|
|
@@ -990,8 +1007,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
990
1007
|
};
|
|
991
1008
|
|
|
992
1009
|
var approveRejectButtons = function approveRejectButtons(action) {
|
|
993
|
-
var concept = getConcept(activeTab);
|
|
994
|
-
concept = action ? action : concept;
|
|
1010
|
+
var concept = getConcept(action || activeTab);
|
|
995
1011
|
|
|
996
1012
|
var _servicesData$filter = servicesData.filter(function (srv) {
|
|
997
1013
|
return srv.id_retailer === (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && srv.service === concept;
|
|
@@ -1150,24 +1166,9 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1150
1166
|
}();
|
|
1151
1167
|
|
|
1152
1168
|
var userAssigned = function userAssigned(tab, rol) {
|
|
1153
|
-
var concept =
|
|
1154
|
-
|
|
1155
|
-
switch (tab) {
|
|
1156
|
-
case "Ficha técnica":
|
|
1157
|
-
concept = "datasheet";
|
|
1158
|
-
break;
|
|
1159
|
-
|
|
1160
|
-
case "Imágenes":
|
|
1161
|
-
concept = "images";
|
|
1162
|
-
break;
|
|
1163
|
-
|
|
1164
|
-
default:
|
|
1165
|
-
concept = "description";
|
|
1166
|
-
break;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
+
var concept = getConcept(activeTab);
|
|
1169
1170
|
var allowedRoles = [1, 4, 5, 6, 7, 8];
|
|
1170
|
-
var validUser = allowedRoles.
|
|
1171
|
+
var validUser = allowedRoles.includes(user === null || user === void 0 ? void 0 : user.id_role);
|
|
1171
1172
|
|
|
1172
1173
|
if (!rol) {
|
|
1173
1174
|
switch (user.id_role) {
|
|
@@ -1458,24 +1459,39 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1458
1459
|
};
|
|
1459
1460
|
|
|
1460
1461
|
var deleteImages = function deleteImages() {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1462
|
+
setLoading(true);
|
|
1463
|
+
var imagesTemp = images;
|
|
1464
|
+
var values = images.values;
|
|
1465
|
+
var imgsInBack = [];
|
|
1466
|
+
selectedImages.forEach(function (selectedImg) {
|
|
1467
|
+
if (selectedImg.id) imgsInBack.push(selectedImg);
|
|
1468
|
+
});
|
|
1469
|
+
var imgsLeft = values.filter(function (value) {
|
|
1470
|
+
return selectedImages.indexOf(value) === -1;
|
|
1471
|
+
});
|
|
1472
|
+
imagesTemp.values = imgsLeft;
|
|
1465
1473
|
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
});
|
|
1474
|
+
if (imgsInBack.length > 0) {
|
|
1475
|
+
var data = {
|
|
1476
|
+
articleId: product.article.id_article,
|
|
1477
|
+
deleteImages: selectedImages
|
|
1478
|
+
};
|
|
1472
1479
|
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1480
|
+
try {
|
|
1481
|
+
_axios.default.put("".concat(process.env.REACT_APP_ARTICLE_DATA_ENDPOINT, "?image=true&version=").concat(version), data, {
|
|
1482
|
+
headers: {
|
|
1483
|
+
Authorization: token
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
} catch (err) {
|
|
1487
|
+
console.log(err);
|
|
1488
|
+
}
|
|
1476
1489
|
}
|
|
1477
1490
|
|
|
1491
|
+
sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
|
|
1492
|
+
loadData();
|
|
1478
1493
|
setMessage("");
|
|
1494
|
+
setComponentsArray([]);
|
|
1479
1495
|
};
|
|
1480
1496
|
|
|
1481
1497
|
var askToDeleteImages = function askToDeleteImages() {
|
|
@@ -1495,7 +1511,8 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1495
1511
|
buttonType: "general-button-default",
|
|
1496
1512
|
label: "Aceptar",
|
|
1497
1513
|
onClick: function onClick() {
|
|
1498
|
-
|
|
1514
|
+
setMessage("");
|
|
1515
|
+
deleteImages();
|
|
1499
1516
|
}
|
|
1500
1517
|
}, "3")]);
|
|
1501
1518
|
}
|
|
@@ -1599,19 +1616,17 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1599
1616
|
isRetailer: isRetailer,
|
|
1600
1617
|
showSaveButton: true,
|
|
1601
1618
|
onClickSave: function onClickSave() {
|
|
1602
|
-
var _product$services2, _product$services3, _product$services4;
|
|
1603
|
-
|
|
1604
1619
|
switch (activeTab) {
|
|
1605
1620
|
case "Descripción":
|
|
1606
|
-
(product === null || product === void 0 ? void 0 :
|
|
1621
|
+
(product === null || product === void 0 ? void 0 : product.description_status) !== "NS" && saveDescriptions();
|
|
1607
1622
|
break;
|
|
1608
1623
|
|
|
1609
1624
|
case "Ficha técnica":
|
|
1610
|
-
(product === null || product === void 0 ? void 0 :
|
|
1625
|
+
(product === null || product === void 0 ? void 0 : product.datasheet_status) !== "NS" && saveDatasheets();
|
|
1611
1626
|
break;
|
|
1612
1627
|
|
|
1613
1628
|
case "Imágenes":
|
|
1614
|
-
(product === null || product === void 0 ? void 0 :
|
|
1629
|
+
(product === null || product === void 0 ? void 0 : product.images_status) !== "NS" && updateImages();
|
|
1615
1630
|
break;
|
|
1616
1631
|
|
|
1617
1632
|
default:
|
|
@@ -1621,7 +1636,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
|
|
|
1621
1636
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
1622
1637
|
className: "services-information-container " + (imageLayout && activeTab === "Imágenes" ? "image-services" : ""),
|
|
1623
1638
|
children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Loading.Loading, {}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
1624
|
-
children: [!imageLayout && activeTab === "Imágenes" && (product === null || product === void 0 ? void 0 : (_product$
|
|
1639
|
+
children: [!imageLayout && activeTab === "Imágenes" && (product === null || product === void 0 ? void 0 : (_product$services2 = product.services) === null || _product$services2 === void 0 ? void 0 : _product$services2.images) === 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GalleryHeader.GalleryHeader, {
|
|
1625
1640
|
setSelectedImages: setSelectedImages,
|
|
1626
1641
|
checkAll: checkAll,
|
|
1627
1642
|
setCheckAll: setCheckAll
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ export const GalleryElement = ({
|
|
|
12
12
|
gridLayout = false,
|
|
13
13
|
id = "chk-default",
|
|
14
14
|
label,
|
|
15
|
-
|
|
15
|
+
number,
|
|
16
16
|
imageInputs,
|
|
17
17
|
imageType,
|
|
18
18
|
imagePackagingType,
|
|
@@ -20,6 +20,7 @@ export const GalleryElement = ({
|
|
|
20
20
|
selectedImages,
|
|
21
21
|
setSelectedImages,
|
|
22
22
|
setCheckAll,
|
|
23
|
+
setSocketType,
|
|
23
24
|
}) => {
|
|
24
25
|
const [statusValidation, setStatusValidation] = useState(validation);
|
|
25
26
|
const [showValidationPanel, setShowValidationPanel] = useState(false);
|
|
@@ -76,14 +77,16 @@ export const GalleryElement = ({
|
|
|
76
77
|
<Select
|
|
77
78
|
width="100%"
|
|
78
79
|
placeholder="Tipo de toma"
|
|
79
|
-
options={imageInputs
|
|
80
|
+
options={imageInputs?.filter(
|
|
81
|
+
(img) => img.value === image.image_id || !img.active
|
|
82
|
+
)}
|
|
80
83
|
valueSelected={image.image_id}
|
|
81
84
|
onChange={(e) => {
|
|
82
85
|
changeImage({
|
|
83
86
|
action: "changeImageInfo",
|
|
84
87
|
attribute: "image_id",
|
|
85
88
|
value: +e.target.value,
|
|
86
|
-
index:
|
|
89
|
+
index: number,
|
|
87
90
|
});
|
|
88
91
|
}}
|
|
89
92
|
/>
|
|
@@ -97,7 +100,7 @@ export const GalleryElement = ({
|
|
|
97
100
|
action: "changeImageInfo",
|
|
98
101
|
attribute: "image_type",
|
|
99
102
|
value: +e.target.value,
|
|
100
|
-
index:
|
|
103
|
+
index: number,
|
|
101
104
|
});
|
|
102
105
|
}}
|
|
103
106
|
/>
|
|
@@ -111,7 +114,7 @@ export const GalleryElement = ({
|
|
|
111
114
|
action: "changeImageInfo",
|
|
112
115
|
attribute: "packing_type",
|
|
113
116
|
value: +e.target.value,
|
|
114
|
-
index:
|
|
117
|
+
index: number,
|
|
115
118
|
});
|
|
116
119
|
}}
|
|
117
120
|
/>
|
|
@@ -8,9 +8,12 @@ export const Container = styled.div`
|
|
|
8
8
|
border-bottom: 1px solid ${GlobalColors.s2};
|
|
9
9
|
|
|
10
10
|
.input-name-header {
|
|
11
|
-
overflow: auto;
|
|
11
|
+
overflow-x: auto;
|
|
12
12
|
max-width: 40%;
|
|
13
13
|
white-space: nowrap;
|
|
14
|
+
height: 23px;
|
|
15
|
+
line-height: 23px;
|
|
16
|
+
text-overflow: initial;
|
|
14
17
|
}
|
|
15
18
|
.status-asignation-info {
|
|
16
19
|
display: flex;
|
|
@@ -192,6 +192,7 @@ export const ProviderProductEdition = ({
|
|
|
192
192
|
img: face,
|
|
193
193
|
});
|
|
194
194
|
const [modalViewTextArea, setModalViewTextArea] = useState(false);
|
|
195
|
+
const [socketType, setSocketType] = useState(null);
|
|
195
196
|
|
|
196
197
|
useEffect(() => {
|
|
197
198
|
checkAll && setSelectedImages(images.values);
|
|
@@ -210,7 +211,7 @@ export const ProviderProductEdition = ({
|
|
|
210
211
|
//setActiveRetailer(product?.retailers[0]);
|
|
211
212
|
setImages({
|
|
212
213
|
action: "init",
|
|
213
|
-
init: services[2],
|
|
214
|
+
init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2],
|
|
214
215
|
});
|
|
215
216
|
if (services[2]?.values?.length > 0) setActiveImage(0);
|
|
216
217
|
|
|
@@ -355,11 +356,7 @@ export const ProviderProductEdition = ({
|
|
|
355
356
|
}, [activeRetailer, services]);
|
|
356
357
|
|
|
357
358
|
const thumbs = () => {
|
|
358
|
-
const imageInputs =
|
|
359
|
-
value: e?.id,
|
|
360
|
-
name: e?.name,
|
|
361
|
-
required: e?.required,
|
|
362
|
-
}));
|
|
359
|
+
const imageInputs = socketType.slice();
|
|
363
360
|
const imageType = images?.imageType?.map((e) => ({
|
|
364
361
|
value: e?.id,
|
|
365
362
|
name: e?.name,
|
|
@@ -375,7 +372,8 @@ export const ProviderProductEdition = ({
|
|
|
375
372
|
image={image}
|
|
376
373
|
gridLayout={imageLayout}
|
|
377
374
|
id={"gallery-element-" + index}
|
|
378
|
-
index={index}
|
|
375
|
+
index={index + "-" + image.name}
|
|
376
|
+
number={index}
|
|
379
377
|
imageType={imageType}
|
|
380
378
|
imagePackagingType={imagePackagingType}
|
|
381
379
|
imageInputs={imageInputs}
|
|
@@ -386,6 +384,16 @@ export const ProviderProductEdition = ({
|
|
|
386
384
|
));
|
|
387
385
|
};
|
|
388
386
|
|
|
387
|
+
useEffect(() => {
|
|
388
|
+
const imageInputs = images?.inputs?.map((e) => ({
|
|
389
|
+
value: e?.id,
|
|
390
|
+
name: e?.name,
|
|
391
|
+
required: e?.required,
|
|
392
|
+
active: images?.values.some((value) => value?.image_id === e?.id),
|
|
393
|
+
}));
|
|
394
|
+
setSocketType(imageInputs);
|
|
395
|
+
}, [images]);
|
|
396
|
+
|
|
389
397
|
const saveDescriptions = async () => {
|
|
390
398
|
setLoading(true);
|
|
391
399
|
const productTemp = product;
|
|
@@ -548,6 +556,7 @@ export const ProviderProductEdition = ({
|
|
|
548
556
|
}
|
|
549
557
|
);
|
|
550
558
|
setMessage("Imágenes guardadas con éxito");
|
|
559
|
+
sessionStorage.removeItem("imagesList");
|
|
551
560
|
loadData();
|
|
552
561
|
} catch (error) {
|
|
553
562
|
console.log(error);
|
|
@@ -940,23 +949,42 @@ export const ProviderProductEdition = ({
|
|
|
940
949
|
};
|
|
941
950
|
|
|
942
951
|
const deleteImages = () => {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
952
|
+
setLoading(true);
|
|
953
|
+
const imagesTemp = images;
|
|
954
|
+
const { values } = images;
|
|
955
|
+
const imgsInBack = [];
|
|
956
|
+
|
|
957
|
+
selectedImages.forEach((selectedImg) => {
|
|
958
|
+
if (selectedImg.id) imgsInBack.push(selectedImg);
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
const imgsLeft = values.filter(
|
|
962
|
+
(value) => selectedImages.indexOf(value) === -1
|
|
963
|
+
);
|
|
964
|
+
|
|
965
|
+
imagesTemp.values = imgsLeft;
|
|
966
|
+
|
|
967
|
+
if (imgsInBack.length > 0) {
|
|
968
|
+
const data = {
|
|
969
|
+
articleId: product.article.id_article,
|
|
970
|
+
deleteImages: selectedImages,
|
|
971
|
+
};
|
|
972
|
+
try {
|
|
973
|
+
axios.put(
|
|
974
|
+
`${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
|
|
975
|
+
data,
|
|
976
|
+
{
|
|
977
|
+
headers: { Authorization: token },
|
|
978
|
+
}
|
|
979
|
+
);
|
|
980
|
+
} catch (err) {
|
|
981
|
+
console.log(err);
|
|
982
|
+
}
|
|
958
983
|
}
|
|
984
|
+
sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
|
|
985
|
+
loadData();
|
|
959
986
|
setMessage("");
|
|
987
|
+
setComponentsArray([]);
|
|
960
988
|
};
|
|
961
989
|
|
|
962
990
|
const askToDeleteImages = () => {
|
|
@@ -979,7 +1007,10 @@ export const ProviderProductEdition = ({
|
|
|
979
1007
|
key={"3"}
|
|
980
1008
|
buttonType="general-button-default"
|
|
981
1009
|
label={"Aceptar"}
|
|
982
|
-
onClick={() =>
|
|
1010
|
+
onClick={() => {
|
|
1011
|
+
setMessage("");
|
|
1012
|
+
deleteImages();
|
|
1013
|
+
}}
|
|
983
1014
|
/>,
|
|
984
1015
|
]);
|
|
985
1016
|
}
|
|
@@ -21,71 +21,86 @@ RetailerProductEditionDefault.args = {
|
|
|
21
21
|
category: 846,
|
|
22
22
|
version: 2,
|
|
23
23
|
productSelected: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
services: {
|
|
25
|
+
datasheets: 1,
|
|
26
|
+
descriptions: 1,
|
|
27
|
+
images: 1,
|
|
28
|
+
},
|
|
29
|
+
orderId: 233,
|
|
30
|
+
status: "QF",
|
|
27
31
|
datasheet_status: "QF",
|
|
28
32
|
prio: "none",
|
|
29
33
|
version: 2,
|
|
30
|
-
description_status: "
|
|
31
|
-
images_status: "
|
|
32
|
-
brand: null,
|
|
33
|
-
missing: {
|
|
34
|
-
datasheet: 0,
|
|
35
|
-
descriptions: 0,
|
|
36
|
-
images: 0,
|
|
37
|
-
},
|
|
34
|
+
description_status: "QF",
|
|
35
|
+
images_status: "QF",
|
|
38
36
|
article: {
|
|
39
|
-
|
|
37
|
+
id_article: 190965,
|
|
38
|
+
id_category: "697",
|
|
39
|
+
name: "Shampoo hidratante",
|
|
40
|
+
upc: "6545345",
|
|
41
|
+
timestamp: "2022-06-10T15:05:56.000Z",
|
|
42
|
+
id_user: 28,
|
|
43
|
+
status: "NULL",
|
|
44
|
+
active: 1,
|
|
45
|
+
company_id: 1,
|
|
40
46
|
company_name: "COMPANY DEV",
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
country: "México",
|
|
48
|
+
id_order: 233,
|
|
49
|
+
id_datasheet_especialist: 54,
|
|
50
|
+
id_datasheet_facilitator: 52,
|
|
51
|
+
id_description_especialist: 54,
|
|
52
|
+
id_description_facilitator: 52,
|
|
53
|
+
id_images_especialist: 55,
|
|
54
|
+
id_images_facilitator: 53,
|
|
55
|
+
id_auditor: 30,
|
|
56
|
+
id_recepcionist: null,
|
|
57
|
+
category:
|
|
58
|
+
"SALUD Y BELLEZA|CUIDADO DEL CABELLO|SHAMPOOS Y ACONDICIONADORES",
|
|
59
|
+
missingAttributes: null,
|
|
60
|
+
missingDescriptions: null,
|
|
61
|
+
missingImages: null,
|
|
46
62
|
},
|
|
47
63
|
retailers: [
|
|
48
64
|
{
|
|
49
|
-
id:
|
|
50
|
-
name: "Walmart
|
|
65
|
+
id: 4,
|
|
66
|
+
name: "Walmart Super y Superama",
|
|
67
|
+
country: "México",
|
|
68
|
+
id_region: 1,
|
|
69
|
+
active: 1,
|
|
70
|
+
percentage: 100,
|
|
51
71
|
},
|
|
52
|
-
],
|
|
53
|
-
services: {
|
|
54
|
-
datasheets: 1,
|
|
55
|
-
descriptions: 1,
|
|
56
|
-
images: 1,
|
|
57
|
-
},
|
|
58
|
-
checked: false,
|
|
59
|
-
retailersAvailable: [
|
|
60
72
|
{
|
|
61
|
-
id:
|
|
62
|
-
name: "
|
|
73
|
+
id: 26,
|
|
74
|
+
name: "Mercado Libre",
|
|
75
|
+
country: "México",
|
|
76
|
+
id_region: 1,
|
|
77
|
+
active: 1,
|
|
78
|
+
percentage: 100,
|
|
63
79
|
},
|
|
64
80
|
],
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
version_status: "IN_PROGRESS",
|
|
81
|
+
country: "México",
|
|
82
|
+
upc: "6545345",
|
|
68
83
|
},
|
|
69
84
|
location: {
|
|
70
85
|
product: { articleId: 109485, versionId: 3 },
|
|
71
86
|
},
|
|
72
87
|
user: {
|
|
73
|
-
id_user:
|
|
74
|
-
name: "
|
|
88
|
+
id_user: 53,
|
|
89
|
+
name: "FACILITADOR ED PRUEBA",
|
|
75
90
|
last_name: "",
|
|
76
|
-
email: "
|
|
91
|
+
email: "arojas@contentoh.com",
|
|
77
92
|
position: null,
|
|
78
93
|
telephone: null,
|
|
79
94
|
country: null,
|
|
80
95
|
id_company: 2,
|
|
81
|
-
id_cognito: "
|
|
96
|
+
id_cognito: "c106e141-e221-49e8-a382-ce99385c6d88",
|
|
82
97
|
birth_Date: null,
|
|
83
98
|
about_me: null,
|
|
84
99
|
zip_code: null,
|
|
85
100
|
address: null,
|
|
86
101
|
job: null,
|
|
87
102
|
id_stripe: null,
|
|
88
|
-
id_role:
|
|
103
|
+
id_role: 5,
|
|
89
104
|
active: 1,
|
|
90
105
|
is_retailer: 0,
|
|
91
106
|
membership: {
|
|
@@ -99,6 +114,6 @@ RetailerProductEditionDefault.args = {
|
|
|
99
114
|
products_limit: "3",
|
|
100
115
|
type: "PyMES",
|
|
101
116
|
},
|
|
102
|
-
src: "https://content-management-profile.s3.amazonaws.com/id-
|
|
117
|
+
src: "https://content-management-profile.s3.amazonaws.com/id-53/53.png?1655161876316",
|
|
103
118
|
},
|
|
104
119
|
};
|
|
@@ -150,6 +150,7 @@ export const RetailerProductEdition = ({
|
|
|
150
150
|
const [loading, setLoading] = useState(true);
|
|
151
151
|
const [retailerStatus, setRetailerStatus] = useState("-");
|
|
152
152
|
const [statusArray, setStatusArray] = useState([]);
|
|
153
|
+
const [socketType, setSocketType] = useState(null);
|
|
153
154
|
|
|
154
155
|
useEffect(() => {
|
|
155
156
|
checkAll && setSelectedImages(images.values);
|
|
@@ -167,7 +168,7 @@ export const RetailerProductEdition = ({
|
|
|
167
168
|
//setActiveRetailer(product?.retailers[0]);
|
|
168
169
|
setImages({
|
|
169
170
|
action: "init",
|
|
170
|
-
init: services[2],
|
|
171
|
+
init: JSON.parse(sessionStorage.getItem("imagesList")) || services[2],
|
|
171
172
|
});
|
|
172
173
|
if (services[2]?.values?.length > 0) setActiveImage(0);
|
|
173
174
|
|
|
@@ -181,7 +182,9 @@ export const RetailerProductEdition = ({
|
|
|
181
182
|
|
|
182
183
|
const getServices = async () => {
|
|
183
184
|
const servicesResponse = await axios.get(
|
|
184
|
-
`${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${
|
|
185
|
+
`${process.env.REACT_APP_SERVICES_ENDPOINT}?articleId=${
|
|
186
|
+
product?.article?.id_article
|
|
187
|
+
}&orderId=${product?.article?.id_order || product.orderId}&end=true`
|
|
185
188
|
);
|
|
186
189
|
const parsedResponse = JSON.parse(servicesResponse?.data?.body).data;
|
|
187
190
|
setServicesData(parsedResponse);
|
|
@@ -337,11 +340,7 @@ export const RetailerProductEdition = ({
|
|
|
337
340
|
}, [activeRetailer, services]);
|
|
338
341
|
|
|
339
342
|
const thumbs = () => {
|
|
340
|
-
const imageInputs =
|
|
341
|
-
value: e?.id,
|
|
342
|
-
name: e?.name,
|
|
343
|
-
required: e?.required,
|
|
344
|
-
}));
|
|
343
|
+
const imageInputs = socketType.slice();
|
|
345
344
|
const imageType = images?.imageType?.map((e) => ({
|
|
346
345
|
value: e?.id,
|
|
347
346
|
name: e?.name,
|
|
@@ -357,10 +356,12 @@ export const RetailerProductEdition = ({
|
|
|
357
356
|
image={image}
|
|
358
357
|
gridLayout={imageLayout}
|
|
359
358
|
id={"gallery-element-" + index}
|
|
360
|
-
index={index}
|
|
359
|
+
index={index + "-" + image.name}
|
|
360
|
+
number={index}
|
|
361
361
|
imageType={imageType}
|
|
362
362
|
imagePackagingType={imagePackagingType}
|
|
363
363
|
imageInputs={imageInputs}
|
|
364
|
+
setSocketType={setSocketType}
|
|
364
365
|
changeImage={setImages}
|
|
365
366
|
selectedImages={selectedImages}
|
|
366
367
|
setSelectedImages={setSelectedImages}
|
|
@@ -429,6 +430,16 @@ export const RetailerProductEdition = ({
|
|
|
429
430
|
}
|
|
430
431
|
};
|
|
431
432
|
|
|
433
|
+
useEffect(() => {
|
|
434
|
+
const imageInputs = images?.inputs?.map((e) => ({
|
|
435
|
+
value: e?.id,
|
|
436
|
+
name: e?.name,
|
|
437
|
+
required: e?.required,
|
|
438
|
+
active: images?.values.some((value) => value?.image_id === e?.id),
|
|
439
|
+
}));
|
|
440
|
+
setSocketType(imageInputs);
|
|
441
|
+
}, [images]);
|
|
442
|
+
|
|
432
443
|
const updateImages = useCallback(async () => {
|
|
433
444
|
const imagesList = images?.values?.slice();
|
|
434
445
|
const imagesListTemp = imagesList?.reduce((acc, image) => {
|
|
@@ -531,6 +542,7 @@ export const RetailerProductEdition = ({
|
|
|
531
542
|
}
|
|
532
543
|
);
|
|
533
544
|
setMessage("Imágenes guardadas con éxito");
|
|
545
|
+
sessionStorage.removeItem("imagesList");
|
|
534
546
|
loadData();
|
|
535
547
|
} catch (error) {
|
|
536
548
|
console.log(error);
|
|
@@ -587,8 +599,7 @@ export const RetailerProductEdition = ({
|
|
|
587
599
|
};
|
|
588
600
|
|
|
589
601
|
const approveRejectButtons = (action) => {
|
|
590
|
-
let concept = getConcept(activeTab);
|
|
591
|
-
concept = action ? action : concept;
|
|
602
|
+
let concept = getConcept(action || activeTab);
|
|
592
603
|
|
|
593
604
|
const [retailerStatus] = servicesData.filter(
|
|
594
605
|
(srv) => srv.id_retailer === activeRetailer?.id && srv.service === concept
|
|
@@ -721,22 +732,10 @@ export const RetailerProductEdition = ({
|
|
|
721
732
|
};
|
|
722
733
|
|
|
723
734
|
const userAssigned = (tab, rol) => {
|
|
724
|
-
let concept =
|
|
725
|
-
switch (tab) {
|
|
726
|
-
case "Ficha técnica":
|
|
727
|
-
concept = "datasheet";
|
|
728
|
-
break;
|
|
729
|
-
case "Imágenes":
|
|
730
|
-
concept = "images";
|
|
731
|
-
break;
|
|
732
|
-
|
|
733
|
-
default:
|
|
734
|
-
concept = "description";
|
|
735
|
-
break;
|
|
736
|
-
}
|
|
735
|
+
let concept = getConcept(activeTab);
|
|
737
736
|
|
|
738
737
|
const allowedRoles = [1, 4, 5, 6, 7, 8];
|
|
739
|
-
const validUser = allowedRoles.
|
|
738
|
+
const validUser = allowedRoles.includes(user?.id_role);
|
|
740
739
|
|
|
741
740
|
if (!rol) {
|
|
742
741
|
switch (user.id_role) {
|
|
@@ -983,23 +982,42 @@ export const RetailerProductEdition = ({
|
|
|
983
982
|
};
|
|
984
983
|
|
|
985
984
|
const deleteImages = () => {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
985
|
+
setLoading(true);
|
|
986
|
+
const imagesTemp = images;
|
|
987
|
+
const { values } = images;
|
|
988
|
+
const imgsInBack = [];
|
|
989
|
+
|
|
990
|
+
selectedImages.forEach((selectedImg) => {
|
|
991
|
+
if (selectedImg.id) imgsInBack.push(selectedImg);
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
const imgsLeft = values.filter(
|
|
995
|
+
(value) => selectedImages.indexOf(value) === -1
|
|
996
|
+
);
|
|
997
|
+
|
|
998
|
+
imagesTemp.values = imgsLeft;
|
|
999
|
+
|
|
1000
|
+
if (imgsInBack.length > 0) {
|
|
1001
|
+
const data = {
|
|
1002
|
+
articleId: product.article.id_article,
|
|
1003
|
+
deleteImages: selectedImages,
|
|
1004
|
+
};
|
|
1005
|
+
try {
|
|
1006
|
+
axios.put(
|
|
1007
|
+
`${process.env.REACT_APP_ARTICLE_DATA_ENDPOINT}?image=true&version=${version}`,
|
|
1008
|
+
data,
|
|
1009
|
+
{
|
|
1010
|
+
headers: { Authorization: token },
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1013
|
+
} catch (err) {
|
|
1014
|
+
console.log(err);
|
|
1015
|
+
}
|
|
1001
1016
|
}
|
|
1017
|
+
sessionStorage.setItem("imagesList", JSON.stringify(imagesTemp));
|
|
1018
|
+
loadData();
|
|
1002
1019
|
setMessage("");
|
|
1020
|
+
setComponentsArray([]);
|
|
1003
1021
|
};
|
|
1004
1022
|
|
|
1005
1023
|
const askToDeleteImages = () => {
|
|
@@ -1022,7 +1040,10 @@ export const RetailerProductEdition = ({
|
|
|
1022
1040
|
key={"3"}
|
|
1023
1041
|
buttonType="general-button-default"
|
|
1024
1042
|
label={"Aceptar"}
|
|
1025
|
-
onClick={() =>
|
|
1043
|
+
onClick={() => {
|
|
1044
|
+
setMessage("");
|
|
1045
|
+
deleteImages();
|
|
1046
|
+
}}
|
|
1026
1047
|
/>,
|
|
1027
1048
|
]);
|
|
1028
1049
|
}
|
|
@@ -1127,13 +1148,13 @@ export const RetailerProductEdition = ({
|
|
|
1127
1148
|
onClickSave={() => {
|
|
1128
1149
|
switch (activeTab) {
|
|
1129
1150
|
case "Descripción":
|
|
1130
|
-
product?.
|
|
1151
|
+
product?.description_status !== "NS" && saveDescriptions();
|
|
1131
1152
|
break;
|
|
1132
1153
|
case "Ficha técnica":
|
|
1133
|
-
product?.
|
|
1154
|
+
product?.datasheet_status !== "NS" && saveDatasheets();
|
|
1134
1155
|
break;
|
|
1135
1156
|
case "Imágenes":
|
|
1136
|
-
product?.
|
|
1157
|
+
product?.images_status !== "NS" && updateImages();
|
|
1137
1158
|
break;
|
|
1138
1159
|
|
|
1139
1160
|
default:
|