contentoh-components-library 21.5.96 → 21.5.97
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.
|
@@ -243,16 +243,24 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
243
243
|
type: "SET_PRODUCT",
|
|
244
244
|
payload: productNormalized
|
|
245
245
|
});
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
246
|
+
|
|
247
|
+
if (productNormalized.categoryRetailerInOrder.length > 0 && productNormalized.statusByRetailer) {
|
|
248
|
+
dispatch({
|
|
249
|
+
type: "SET_ACTIVE_RETAILER",
|
|
250
|
+
payload: productNormalized.categoryRetailerInOrder[0]
|
|
251
|
+
});
|
|
252
|
+
var firstRetailerStatus = productNormalized.statusByRetailer[productNormalized.categoryRetailerInOrder[0].id_retailer];
|
|
253
|
+
var initialTab = firstRetailerStatus.description ? "Descripción" : firstRetailerStatus.datasheet ? "Ficha técnica" : firstRetailerStatus.images ? "Imágenes" : "Imágenes";
|
|
254
|
+
dispatch({
|
|
255
|
+
type: "SET_ACTIVE_TAB",
|
|
256
|
+
payload: initialTab
|
|
257
|
+
});
|
|
258
|
+
} else {
|
|
259
|
+
dispatch({
|
|
260
|
+
type: "SET_ACTIVE_RETAILER",
|
|
261
|
+
payload: productNormalized.categoryRetailer[0]
|
|
262
|
+
});
|
|
263
|
+
}
|
|
256
264
|
} catch (error) {
|
|
257
265
|
console.log("Error setting product data: ", error);
|
|
258
266
|
}
|
|
@@ -275,7 +283,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
275
283
|
|
|
276
284
|
var fetchData = /*#__PURE__*/function () {
|
|
277
285
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
278
|
-
var _JSON$parse$0$relatio, _JSON$parse, _JSON$parse$, _percentageRes$, data, headers, _yield$Promise$all, _yield$Promise$all2, services, percentageRes, servicesDataRes, percentages, orderMap, orderedValues, updatedStatusByRetailer;
|
|
286
|
+
var _JSON$parse$0$relatio, _JSON$parse, _JSON$parse$, _percentageRes$, _services$2$inputsByR, _services$2$values, data, headers, _yield$Promise$all, _yield$Promise$all2, services, percentageRes, servicesDataRes, percentages, orderMap, orderedValues, updatedStatusByRetailer;
|
|
279
287
|
|
|
280
288
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
281
289
|
while (1) {
|
|
@@ -315,11 +323,11 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
315
323
|
percentageRes = _yield$Promise$all2[1];
|
|
316
324
|
servicesDataRes = _yield$Promise$all2[2];
|
|
317
325
|
percentages = (_JSON$parse$0$relatio = (_JSON$parse = JSON.parse(percentageRes === null || percentageRes === void 0 ? void 0 : (_percentageRes$ = percentageRes[0]) === null || _percentageRes$ === void 0 ? void 0 : _percentageRes$.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 : [];
|
|
318
|
-
orderMap = services[2].inputsByRetailer.flat().reduce(function (acc, item) {
|
|
326
|
+
orderMap = (_services$2$inputsByR = services[2].inputsByRetailer) !== null && _services$2$inputsByR !== void 0 ? _services$2$inputsByR : [].flat().reduce(function (acc, item) {
|
|
319
327
|
acc[item.id_image] = item.order;
|
|
320
328
|
return acc;
|
|
321
329
|
}, {});
|
|
322
|
-
orderedValues = (0, _toConsumableArray2.default)(services[2].values).sort(function (a, b) {
|
|
330
|
+
orderedValues = (0, _toConsumableArray2.default)((_services$2$values = services[2].values) !== null && _services$2$values !== void 0 ? _services$2$values : []).sort(function (a, b) {
|
|
323
331
|
var _orderMap$a$image_id, _orderMap$b$image_id;
|
|
324
332
|
|
|
325
333
|
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;
|
|
@@ -454,30 +462,35 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
454
462
|
var _state$product8;
|
|
455
463
|
|
|
456
464
|
if (!((_state$product8 = state.product) !== null && _state$product8 !== void 0 && _state$product8.statusByRetailer)) return false;
|
|
457
|
-
var currentService = (0, _utils.getConceptByTab)(state.active_tab); // const currentStatus = state.product[`${currentService}_status`];
|
|
458
465
|
|
|
459
|
-
|
|
466
|
+
try {
|
|
467
|
+
var currentService = (0, _utils.getConceptByTab)(state.active_tab); // const currentStatus = state.product[`${currentService}_status`];
|
|
468
|
+
|
|
469
|
+
var currentRetailer = state.active_retailer.id_retailer; //Información del servicio de la cadena seleccionada
|
|
460
470
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
471
|
+
var _state$services_data$ = state.services_data.find(function (service) {
|
|
472
|
+
return service.service === currentService && service.id_retailer === currentRetailer;
|
|
473
|
+
}),
|
|
474
|
+
currentStatus = _state$services_data$.status;
|
|
465
475
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
476
|
+
var originTab = origin[state.active_tab];
|
|
477
|
+
var isRetailerUser = (user === null || user === void 0 ? void 0 : user.is_retailer) === 1;
|
|
478
|
+
var validStatuses = ["AA", "AP", "R", "CA", "RCA"];
|
|
479
|
+
if (!validStatuses.includes(currentStatus)) return false;
|
|
480
|
+
var validOrigins = ["RequestWithContentoh", "RequestWithoutContentoh", "Contentoh"];
|
|
481
|
+
if (!validOrigins.includes(originTab)) return false; // Retailer: solo AP
|
|
472
482
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
483
|
+
if (isRetailerUser) {
|
|
484
|
+
return currentStatus === "AP";
|
|
485
|
+
} // No retailer
|
|
476
486
|
|
|
477
487
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
488
|
+
var hasNoOrder = !state.product.id_order && !state.product.orderId;
|
|
489
|
+
var condition = originTab === "RequestWithoutContentoh" && (["R", "CA"].includes(currentStatus) || currentStatus === "RCA" && hasNoOrder) || ["RequestWithContentoh", "Contentoh"].includes(originTab) && currentStatus === "AA";
|
|
490
|
+
return condition;
|
|
491
|
+
} catch (error) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
481
494
|
};
|
|
482
495
|
|
|
483
496
|
var canShowSaveButton = function canShowSaveButton(version_status) {
|
|
@@ -498,7 +511,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
498
511
|
if (!statusByRetailer) return "-";
|
|
499
512
|
var currentService = (0, _utils.getConceptByTab)(state.active_tab);
|
|
500
513
|
var currentRetailer = state.active_retailer.id_retailer;
|
|
501
|
-
var currentStatus = statusByRetailer[currentRetailer][currentService] || "
|
|
514
|
+
var currentStatus = statusByRetailer[currentRetailer][currentService] || "N/S";
|
|
502
515
|
return currentStatus;
|
|
503
516
|
};
|
|
504
517
|
|
|
@@ -819,7 +832,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
819
832
|
_context3.prev = 8;
|
|
820
833
|
|
|
821
834
|
if (!result) {
|
|
822
|
-
_context3.next =
|
|
835
|
+
_context3.next = 22;
|
|
823
836
|
break;
|
|
824
837
|
}
|
|
825
838
|
|
|
@@ -835,13 +848,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
835
848
|
case 14:
|
|
836
849
|
res = _context3.sent;
|
|
837
850
|
newStatuses = JSON.parse(res.data.body);
|
|
838
|
-
serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")];
|
|
839
|
-
console.log({
|
|
840
|
-
product: state.product,
|
|
841
|
-
newStatuses: newStatuses,
|
|
842
|
-
serviceStatus: serviceStatus,
|
|
843
|
-
servicesData: state.services_data
|
|
844
|
-
}); // Actualizar el producto con los nuevos estados
|
|
851
|
+
serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")]; // Actualizar el producto con los nuevos estados
|
|
845
852
|
|
|
846
853
|
updatedProduct = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
|
|
847
854
|
statusByRetailer: (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product.statusByRetailer), {}, (0, _defineProperty2.default)({}, retailerId, (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product.statusByRetailer[retailerId]), {}, (0, _defineProperty2.default)({}, concept, (_newStatuses$newStatu = newStatuses === null || newStatuses === void 0 ? void 0 : newStatuses.newStatus) !== null && _newStatuses$newStatu !== void 0 ? _newStatuses$newStatu : serviceStatus))))
|
|
@@ -873,12 +880,12 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
873
880
|
}
|
|
874
881
|
});
|
|
875
882
|
|
|
876
|
-
case
|
|
877
|
-
_context3.next =
|
|
883
|
+
case 22:
|
|
884
|
+
_context3.next = 28;
|
|
878
885
|
break;
|
|
879
886
|
|
|
880
|
-
case
|
|
881
|
-
_context3.prev =
|
|
887
|
+
case 24:
|
|
888
|
+
_context3.prev = 24;
|
|
882
889
|
_context3.t0 = _context3["catch"](8);
|
|
883
890
|
console.error("Error sending evaluation:", _context3.t0);
|
|
884
891
|
dispatch({
|
|
@@ -891,20 +898,20 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
891
898
|
}
|
|
892
899
|
});
|
|
893
900
|
|
|
894
|
-
case
|
|
895
|
-
_context3.prev =
|
|
901
|
+
case 28:
|
|
902
|
+
_context3.prev = 28;
|
|
896
903
|
dispatch({
|
|
897
904
|
type: "SET_SAVING",
|
|
898
905
|
payload: false
|
|
899
906
|
});
|
|
900
|
-
return _context3.finish(
|
|
907
|
+
return _context3.finish(28);
|
|
901
908
|
|
|
902
|
-
case
|
|
909
|
+
case 31:
|
|
903
910
|
case "end":
|
|
904
911
|
return _context3.stop();
|
|
905
912
|
}
|
|
906
913
|
}
|
|
907
|
-
}, _callee3, null, [[8,
|
|
914
|
+
}, _callee3, null, [[8, 24, 28, 31]]);
|
|
908
915
|
}));
|
|
909
916
|
|
|
910
917
|
return function sendEvaluation(_x2) {
|
package/package.json
CHANGED
|
@@ -153,26 +153,35 @@ const ProviderProductEditionView = ({
|
|
|
153
153
|
type: "SET_PRODUCT",
|
|
154
154
|
payload: productNormalized,
|
|
155
155
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
if (
|
|
157
|
+
productNormalized.categoryRetailerInOrder.length > 0 &&
|
|
158
|
+
productNormalized.statusByRetailer
|
|
159
|
+
) {
|
|
160
|
+
dispatch({
|
|
161
|
+
type: "SET_ACTIVE_RETAILER",
|
|
162
|
+
payload: productNormalized.categoryRetailerInOrder[0],
|
|
163
|
+
});
|
|
164
|
+
const firstRetailerStatus =
|
|
165
|
+
productNormalized.statusByRetailer[
|
|
166
|
+
productNormalized.categoryRetailerInOrder[0].id_retailer
|
|
167
|
+
];
|
|
168
|
+
const initialTab = firstRetailerStatus.description
|
|
169
|
+
? "Descripción"
|
|
170
|
+
: firstRetailerStatus.datasheet
|
|
171
|
+
? "Ficha técnica"
|
|
172
|
+
: firstRetailerStatus.images
|
|
173
|
+
? "Imágenes"
|
|
174
|
+
: "Imágenes";
|
|
175
|
+
dispatch({
|
|
176
|
+
type: "SET_ACTIVE_TAB",
|
|
177
|
+
payload: initialTab,
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
dispatch({
|
|
181
|
+
type: "SET_ACTIVE_RETAILER",
|
|
182
|
+
payload: productNormalized.categoryRetailer[0],
|
|
183
|
+
});
|
|
184
|
+
}
|
|
176
185
|
} catch (error) {
|
|
177
186
|
console.log("Error setting product data: ", error);
|
|
178
187
|
}
|
|
@@ -216,7 +225,7 @@ const ProviderProductEditionView = ({
|
|
|
216
225
|
id_category,
|
|
217
226
|
version,
|
|
218
227
|
token,
|
|
219
|
-
id_retailer
|
|
228
|
+
id_retailer,
|
|
220
229
|
),
|
|
221
230
|
getPercentage({ data, headers }),
|
|
222
231
|
getServicesData({
|
|
@@ -230,14 +239,14 @@ const ProviderProductEditionView = ({
|
|
|
230
239
|
const percentages =
|
|
231
240
|
JSON.parse(percentageRes?.[0]?.body)?.[0]?.relations ?? [];
|
|
232
241
|
|
|
233
|
-
const orderMap =
|
|
234
|
-
.
|
|
235
|
-
.reduce((acc, item) => {
|
|
242
|
+
const orderMap =
|
|
243
|
+
services[2].inputsByRetailer ??
|
|
244
|
+
[].flat().reduce((acc, item) => {
|
|
236
245
|
acc[item.id_image] = item.order;
|
|
237
246
|
return acc;
|
|
238
247
|
}, {});
|
|
239
248
|
|
|
240
|
-
const orderedValues = [...services[2].values].sort((a, b) => {
|
|
249
|
+
const orderedValues = [...(services[2].values ?? [])].sort((a, b) => {
|
|
241
250
|
const orderA = orderMap[a.image_id] ?? Number.MAX_SAFE_INTEGER;
|
|
242
251
|
const orderB = orderMap[b.image_id] ?? Number.MAX_SAFE_INTEGER;
|
|
243
252
|
|
|
@@ -368,40 +377,41 @@ const ProviderProductEditionView = ({
|
|
|
368
377
|
const canShowValidationButtons = () => {
|
|
369
378
|
if (!state.product?.statusByRetailer) return false;
|
|
370
379
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
(
|
|
378
|
-
service
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
try {
|
|
381
|
+
const currentService = getConceptByTab(state.active_tab);
|
|
382
|
+
// const currentStatus = state.product[`${currentService}_status`];
|
|
383
|
+
const currentRetailer = state.active_retailer.id_retailer;
|
|
384
|
+
|
|
385
|
+
//Información del servicio de la cadena seleccionada
|
|
386
|
+
const { status: currentStatus } = state.services_data.find(
|
|
387
|
+
(service) =>
|
|
388
|
+
service.service === currentService &&
|
|
389
|
+
service.id_retailer === currentRetailer,
|
|
390
|
+
);
|
|
381
391
|
|
|
382
|
-
|
|
383
|
-
|
|
392
|
+
const originTab = origin[state.active_tab];
|
|
393
|
+
const isRetailerUser = user?.is_retailer === 1;
|
|
384
394
|
|
|
385
|
-
|
|
386
|
-
|
|
395
|
+
const validStatuses = ["AA", "AP", "R", "CA", "RCA"];
|
|
396
|
+
if (!validStatuses.includes(currentStatus)) return false;
|
|
387
397
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
398
|
+
const validOrigins = [
|
|
399
|
+
"RequestWithContentoh",
|
|
400
|
+
"RequestWithoutContentoh",
|
|
401
|
+
"Contentoh",
|
|
402
|
+
];
|
|
393
403
|
|
|
394
|
-
|
|
404
|
+
if (!validOrigins.includes(originTab)) return false;
|
|
395
405
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
406
|
+
// Retailer: solo AP
|
|
407
|
+
if (isRetailerUser) {
|
|
408
|
+
return currentStatus === "AP";
|
|
409
|
+
}
|
|
400
410
|
|
|
401
|
-
|
|
402
|
-
|
|
411
|
+
// No retailer
|
|
412
|
+
const hasNoOrder = !state.product.id_order && !state.product.orderId;
|
|
403
413
|
|
|
404
|
-
|
|
414
|
+
const condition =
|
|
405
415
|
(
|
|
406
416
|
originTab === "RequestWithoutContentoh" && (
|
|
407
417
|
["R", "CA"].includes(currentStatus) || (currentStatus === "RCA" && hasNoOrder)
|
|
@@ -411,7 +421,10 @@ const ProviderProductEditionView = ({
|
|
|
411
421
|
["RequestWithContentoh", "Contentoh"].includes(originTab) && currentStatus === "AA"
|
|
412
422
|
)
|
|
413
423
|
|
|
414
|
-
|
|
424
|
+
return condition;
|
|
425
|
+
} catch (error) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
415
428
|
};
|
|
416
429
|
|
|
417
430
|
const canShowSaveButton = (version_status) => {
|
|
@@ -434,7 +447,7 @@ const ProviderProductEditionView = ({
|
|
|
434
447
|
const currentRetailer = state.active_retailer.id_retailer;
|
|
435
448
|
|
|
436
449
|
const currentStatus =
|
|
437
|
-
statusByRetailer[currentRetailer][currentService] || "
|
|
450
|
+
statusByRetailer[currentRetailer][currentService] || "N/S";
|
|
438
451
|
return currentStatus;
|
|
439
452
|
};
|
|
440
453
|
|
|
@@ -444,7 +457,7 @@ const ProviderProductEditionView = ({
|
|
|
444
457
|
name: e?.name,
|
|
445
458
|
required: e?.required,
|
|
446
459
|
active: state.images_values?.values?.some(
|
|
447
|
-
(value) => value?.image_id === e?.id
|
|
460
|
+
(value) => value?.image_id === e?.id,
|
|
448
461
|
),
|
|
449
462
|
}));
|
|
450
463
|
const imageType = state.images_values?.imageType?.map((e) => ({
|
|
@@ -455,7 +468,7 @@ const ProviderProductEditionView = ({
|
|
|
455
468
|
(e) => ({
|
|
456
469
|
value: e?.id,
|
|
457
470
|
name: e?.name,
|
|
458
|
-
})
|
|
471
|
+
}),
|
|
459
472
|
);
|
|
460
473
|
|
|
461
474
|
return state.images_values?.values?.map((image, index) => (
|
|
@@ -711,14 +724,13 @@ const ProviderProductEditionView = ({
|
|
|
711
724
|
headers: {
|
|
712
725
|
Authorization: token,
|
|
713
726
|
},
|
|
714
|
-
}
|
|
727
|
+
},
|
|
715
728
|
);
|
|
716
729
|
|
|
717
730
|
const newStatuses = JSON.parse(res.data.body);
|
|
718
731
|
const serviceStatus =
|
|
719
732
|
newStatuses.newServiceStatus[articleId][`${concept}Status`];
|
|
720
|
-
|
|
721
|
-
console.log({product: state.product, newStatuses, serviceStatus, servicesData: state.services_data});
|
|
733
|
+
|
|
722
734
|
|
|
723
735
|
// Actualizar el producto con los nuevos estados
|
|
724
736
|
const updatedProduct = {
|
|
@@ -732,9 +744,12 @@ const ProviderProductEditionView = ({
|
|
|
732
744
|
},
|
|
733
745
|
};
|
|
734
746
|
|
|
735
|
-
const updatedServicesData = state.services_data?.map(service => ({
|
|
747
|
+
const updatedServicesData = state.services_data?.map((service) => ({
|
|
736
748
|
...service,
|
|
737
|
-
status:
|
|
749
|
+
status:
|
|
750
|
+
service?.id_retailer === retailerId && service?.service === concept
|
|
751
|
+
? newStatuses?.newStatus ?? serviceStatus
|
|
752
|
+
: service?.status,
|
|
738
753
|
}));
|
|
739
754
|
|
|
740
755
|
dispatch({ type: "SET_SERVICES_DATA", payload: updatedServicesData });
|