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