contentoh-components-library 21.6.0 → 21.6.11
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/ProgressBar/index.js +1 -1
- package/dist/components/atoms/ProgressBar/styles.js +4 -4
- package/dist/components/atoms/Status/index.js +16 -1
- package/dist/components/atoms/Status/styles.js +1 -1
- package/dist/components/organisms/ChangeStatusModal/index.js +166 -53
- package/dist/components/organisms/ChangeStatusModal/styles.js +12 -8
- package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +3 -1
- package/dist/components/pages/ProviderProductEdition/index.js +65 -36
- package/dist/components/pages/ProviderProductEdition/utils.js +3 -1
- package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +11 -19
- package/dist/components/pages/RetailerProductEdition/index.js +16 -10
- package/dist/components/pages/RetailerProductEdition/utils.js +1 -1
- package/dist/contexts/AiProductEdition.js +34 -22
- package/dist/global-files/statusDictionary.js +36 -1
- package/package.json +1 -1
- package/src/components/atoms/ProgressBar/index.js +2 -6
- package/src/components/atoms/ProgressBar/styles.js +4 -58
- package/src/components/atoms/Status/index.js +11 -3
- package/src/components/atoms/Status/styles.js +113 -0
- package/src/components/organisms/ChangeStatusModal/index.jsx +103 -29
- package/src/components/organisms/ChangeStatusModal/styles.js +20 -0
- package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +1 -0
- package/src/components/pages/ProviderProductEdition/index.js +40 -14
- package/src/components/pages/ProviderProductEdition/utils.js +5 -1
- package/src/components/pages/RetailerProductEdition/context/reducers/product.js +4 -20
- package/src/components/pages/RetailerProductEdition/index.js +20 -16
- package/src/components/pages/RetailerProductEdition/utils.js +1 -1
- package/src/contexts/AiProductEdition.jsx +22 -13
- package/src/global-files/statusDictionary.js +31 -1
|
@@ -31,6 +31,8 @@ var _providerProductEdition = require("./context/provider-product-edition.contex
|
|
|
31
31
|
|
|
32
32
|
var _utils = require("./utils");
|
|
33
33
|
|
|
34
|
+
var _statusDictionary = require("../../../global-files/statusDictionary");
|
|
35
|
+
|
|
34
36
|
var _data = require("../../../global-files/data");
|
|
35
37
|
|
|
36
38
|
var _customHooks = require("../../../global-files/customHooks");
|
|
@@ -288,7 +290,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
288
290
|
|
|
289
291
|
var fetchData = /*#__PURE__*/function () {
|
|
290
292
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
291
|
-
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;
|
|
293
|
+
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, getServiceMinorStatus, imagesMinorStatus, descriptionMinorStatus, datasheetMinorStatus;
|
|
292
294
|
|
|
293
295
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
294
296
|
while (1) {
|
|
@@ -348,10 +350,30 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
348
350
|
acc[id_retailer][service] = status;
|
|
349
351
|
return acc;
|
|
350
352
|
}, {});
|
|
353
|
+
|
|
354
|
+
getServiceMinorStatus = function getServiceMinorStatus(serviceName) {
|
|
355
|
+
var records = servicesDataRes.filter(function (s) {
|
|
356
|
+
return s.service === serviceName;
|
|
357
|
+
});
|
|
358
|
+
return records.length > 0 ? (0, _statusDictionary.getMinorStatus)(records.map(function (s) {
|
|
359
|
+
return s.status;
|
|
360
|
+
})) : undefined;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
imagesMinorStatus = getServiceMinorStatus("images");
|
|
364
|
+
descriptionMinorStatus = getServiceMinorStatus("description");
|
|
365
|
+
datasheetMinorStatus = getServiceMinorStatus("datasheet");
|
|
351
366
|
dispatch({
|
|
352
367
|
type: "SET_PRODUCT",
|
|
353
|
-
payload: (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
|
|
354
|
-
statusByRetailer: updatedStatusByRetailer
|
|
368
|
+
payload: (0, _objectSpread4.default)((0, _objectSpread4.default)((0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
|
|
369
|
+
statusByRetailer: updatedStatusByRetailer,
|
|
370
|
+
status: (0, _statusDictionary.getMinorStatusFromRetailerMap)(updatedStatusByRetailer)
|
|
371
|
+
}, imagesMinorStatus !== undefined && {
|
|
372
|
+
images_status: imagesMinorStatus
|
|
373
|
+
}), descriptionMinorStatus !== undefined && {
|
|
374
|
+
description_status: descriptionMinorStatus
|
|
375
|
+
}), datasheetMinorStatus !== undefined && {
|
|
376
|
+
datasheet_status: datasheetMinorStatus
|
|
355
377
|
})
|
|
356
378
|
});
|
|
357
379
|
dispatch({
|
|
@@ -379,11 +401,11 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
379
401
|
return rId === id_retailer;
|
|
380
402
|
})
|
|
381
403
|
});
|
|
382
|
-
_context2.next =
|
|
404
|
+
_context2.next = 30;
|
|
383
405
|
break;
|
|
384
406
|
|
|
385
|
-
case
|
|
386
|
-
_context2.prev =
|
|
407
|
+
case 26:
|
|
408
|
+
_context2.prev = 26;
|
|
387
409
|
_context2.t0 = _context2["catch"](1);
|
|
388
410
|
console.error("Error fetching data:", _context2.t0);
|
|
389
411
|
dispatch({
|
|
@@ -391,20 +413,20 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
391
413
|
payload: _context2.t0
|
|
392
414
|
});
|
|
393
415
|
|
|
394
|
-
case
|
|
395
|
-
_context2.prev =
|
|
416
|
+
case 30:
|
|
417
|
+
_context2.prev = 30;
|
|
396
418
|
dispatch({
|
|
397
419
|
type: "SET_LOADING",
|
|
398
420
|
payload: false
|
|
399
421
|
});
|
|
400
|
-
return _context2.finish(
|
|
422
|
+
return _context2.finish(30);
|
|
401
423
|
|
|
402
|
-
case
|
|
424
|
+
case 33:
|
|
403
425
|
case "end":
|
|
404
426
|
return _context2.stop();
|
|
405
427
|
}
|
|
406
428
|
}
|
|
407
|
-
}, _callee2, null, [[1,
|
|
429
|
+
}, _callee2, null, [[1, 26, 30, 33]]);
|
|
408
430
|
}));
|
|
409
431
|
|
|
410
432
|
return function fetchData() {
|
|
@@ -810,9 +832,9 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
810
832
|
|
|
811
833
|
var sendEvaluation = /*#__PURE__*/function () {
|
|
812
834
|
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(result) {
|
|
813
|
-
var _state$product$id_ord, _state$
|
|
835
|
+
var _state$product$id_ord, _state$active_retaile2, _state$product$status, _state$product$status2, _state$product10;
|
|
814
836
|
|
|
815
|
-
var concept, articleId, orderId,
|
|
837
|
+
var concept, articleId, orderId, retailerId, evalStatus, data, _newStatuses$newStatu, _state$services_data, res, newStatuses, serviceStatus, updatedStatusByRetailer, updatedProduct, updatedServicesData;
|
|
816
838
|
|
|
817
839
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
818
840
|
while (1) {
|
|
@@ -825,16 +847,15 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
825
847
|
concept = (0, _utils.getConceptByTab)(state.active_tab);
|
|
826
848
|
articleId = state.product.id_article;
|
|
827
849
|
orderId = (_state$product$id_ord = state.product.id_order) !== null && _state$product$id_ord !== void 0 ? _state$product$id_ord : state.product.orderId;
|
|
828
|
-
|
|
829
|
-
evalStatus = state.product[
|
|
850
|
+
retailerId = (_state$active_retaile2 = state.active_retailer) === null || _state$active_retaile2 === void 0 ? void 0 : _state$active_retaile2.id_retailer;
|
|
851
|
+
evalStatus = ((_state$product$status = state.product.statusByRetailer) === null || _state$product$status === void 0 ? void 0 : (_state$product$status2 = _state$product$status[retailerId]) === null || _state$product$status2 === void 0 ? void 0 : _state$product$status2[concept]) || state.product["".concat(concept, "_status")] || ((_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.version_status);
|
|
830
852
|
data = {
|
|
831
853
|
articleId: articleId,
|
|
832
854
|
orderId: orderId,
|
|
833
855
|
concept: concept,
|
|
834
856
|
evalStatus: evalStatus
|
|
835
857
|
};
|
|
836
|
-
|
|
837
|
-
_context3.prev = 8;
|
|
858
|
+
_context3.prev = 7;
|
|
838
859
|
|
|
839
860
|
if (!result) {
|
|
840
861
|
_context3.next = 22;
|
|
@@ -843,20 +864,22 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
843
864
|
|
|
844
865
|
data.result = result;
|
|
845
866
|
data.retailerId = retailerId;
|
|
846
|
-
_context3.next =
|
|
867
|
+
_context3.next = 13;
|
|
847
868
|
return _axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
|
|
848
869
|
headers: {
|
|
849
870
|
Authorization: token
|
|
850
871
|
}
|
|
851
872
|
});
|
|
852
873
|
|
|
853
|
-
case
|
|
874
|
+
case 13:
|
|
854
875
|
res = _context3.sent;
|
|
855
876
|
newStatuses = JSON.parse(res.data.body);
|
|
856
877
|
serviceStatus = newStatuses.newServiceStatus[articleId]["".concat(concept, "Status")]; // Actualizar el producto con los nuevos estados
|
|
857
878
|
|
|
879
|
+
updatedStatusByRetailer = (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))));
|
|
858
880
|
updatedProduct = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
|
|
859
|
-
statusByRetailer:
|
|
881
|
+
statusByRetailer: updatedStatusByRetailer,
|
|
882
|
+
status: (0, _statusDictionary.getMinorStatus)(Object.values(updatedStatusByRetailer).flatMap(Object.values))
|
|
860
883
|
});
|
|
861
884
|
updatedServicesData = (_state$services_data = state.services_data) === null || _state$services_data === void 0 ? void 0 : _state$services_data.map(function (service) {
|
|
862
885
|
var _newStatuses$newStatu2;
|
|
@@ -891,7 +914,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
891
914
|
|
|
892
915
|
case 24:
|
|
893
916
|
_context3.prev = 24;
|
|
894
|
-
_context3.t0 = _context3["catch"](
|
|
917
|
+
_context3.t0 = _context3["catch"](7);
|
|
895
918
|
console.error("Error sending evaluation:", _context3.t0);
|
|
896
919
|
dispatch({
|
|
897
920
|
type: "SET_MODAL",
|
|
@@ -916,7 +939,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
916
939
|
return _context3.stop();
|
|
917
940
|
}
|
|
918
941
|
}
|
|
919
|
-
}, _callee3, null, [[
|
|
942
|
+
}, _callee3, null, [[7, 24, 28, 31]]);
|
|
920
943
|
}));
|
|
921
944
|
|
|
922
945
|
return function sendEvaluation(_x2) {
|
|
@@ -1138,7 +1161,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1138
1161
|
|
|
1139
1162
|
var handleOnEvaluateAll = /*#__PURE__*/function () {
|
|
1140
1163
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(result) {
|
|
1141
|
-
var _state$product$id_ord2, _state$services_data2, evaluationArray, conceptArray, dataGeneral, userType, status, updatedStatusByRetailer, updatedProduct;
|
|
1164
|
+
var _state$product$id_ord2, _state$services_data2, evaluationArray, conceptArray, dataGeneral, isProvider, userType, status, updatedStatusByRetailer, updatedProduct;
|
|
1142
1165
|
|
|
1143
1166
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
1144
1167
|
while (1) {
|
|
@@ -1158,14 +1181,19 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1158
1181
|
isAproved: result === "A"
|
|
1159
1182
|
}; // Crear todas las evaluaciones para cada servicio y retailer
|
|
1160
1183
|
|
|
1184
|
+
isProvider = !user.is_retailer;
|
|
1161
1185
|
(_state$services_data2 = state.services_data) === null || _state$services_data2 === void 0 ? void 0 : _state$services_data2.forEach(function (ret) {
|
|
1186
|
+
var _state$product$status3;
|
|
1187
|
+
|
|
1162
1188
|
var service = ret.service,
|
|
1163
1189
|
id_retailer = ret.id_retailer;
|
|
1164
|
-
var
|
|
1165
|
-
|
|
1190
|
+
var currentEvalStatus = (_state$product$status3 = state.product.statusByRetailer[id_retailer]) === null || _state$product$status3 === void 0 ? void 0 : _state$product$status3[service];
|
|
1191
|
+
if (isProvider && currentEvalStatus !== _statusDictionary.STATUS_DICTIONARY.AA.status) return;
|
|
1192
|
+
if (!isProvider && currentEvalStatus !== _statusDictionary.STATUS_DICTIONARY.AP.status) return;
|
|
1193
|
+
var data = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, dataGeneral), {}, {
|
|
1166
1194
|
concept: service,
|
|
1167
1195
|
retailerId: id_retailer,
|
|
1168
|
-
evalStatus:
|
|
1196
|
+
evalStatus: currentEvalStatus
|
|
1169
1197
|
});
|
|
1170
1198
|
evaluationArray.push(_axios.default.put("".concat(process.env.REACT_APP_EVALUATION_ENDPOINT), data, {
|
|
1171
1199
|
headers: {
|
|
@@ -1174,10 +1202,10 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1174
1202
|
}));
|
|
1175
1203
|
}); // Ejecutar todas las evaluaciones
|
|
1176
1204
|
|
|
1177
|
-
_context5.next =
|
|
1205
|
+
_context5.next = 9;
|
|
1178
1206
|
return Promise.all(evaluationArray);
|
|
1179
1207
|
|
|
1180
|
-
case
|
|
1208
|
+
case 9:
|
|
1181
1209
|
userType = user.is_retailer === 1 ? "CA" : "P";
|
|
1182
1210
|
status = "".concat(result).concat(userType); // Actualizar el statusByRetailer para todos los retailers y conceptos
|
|
1183
1211
|
|
|
@@ -1192,6 +1220,7 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1192
1220
|
|
|
1193
1221
|
updatedProduct = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, state.product), {}, {
|
|
1194
1222
|
article_status: status,
|
|
1223
|
+
status: (0, _statusDictionary.getMinorStatus)(Object.values(updatedStatusByRetailer).flatMap(Object.values)),
|
|
1195
1224
|
datasheet_status: state.product.datasheet_status === "NA" ? "NA" : status,
|
|
1196
1225
|
description_status: state.product.description_status === "NA" ? "NA" : status,
|
|
1197
1226
|
images_status: state.product.images_status === "NA" ? "NA" : status,
|
|
@@ -1218,11 +1247,11 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1218
1247
|
image: _genericModalCheck.default
|
|
1219
1248
|
}
|
|
1220
1249
|
});
|
|
1221
|
-
_context5.next =
|
|
1250
|
+
_context5.next = 24;
|
|
1222
1251
|
break;
|
|
1223
1252
|
|
|
1224
|
-
case
|
|
1225
|
-
_context5.prev =
|
|
1253
|
+
case 20:
|
|
1254
|
+
_context5.prev = 20;
|
|
1226
1255
|
_context5.t0 = _context5["catch"](1);
|
|
1227
1256
|
console.error("Error evaluating all:", _context5.t0);
|
|
1228
1257
|
dispatch({
|
|
@@ -1235,21 +1264,21 @@ var ProviderProductEditionView = function ProviderProductEditionView(_ref) {
|
|
|
1235
1264
|
}
|
|
1236
1265
|
});
|
|
1237
1266
|
|
|
1238
|
-
case
|
|
1239
|
-
_context5.prev =
|
|
1267
|
+
case 24:
|
|
1268
|
+
_context5.prev = 24;
|
|
1240
1269
|
dispatch({
|
|
1241
1270
|
type: "SET_SAVING",
|
|
1242
1271
|
payload: false
|
|
1243
1272
|
});
|
|
1244
1273
|
setRejectAll(false);
|
|
1245
|
-
return _context5.finish(
|
|
1274
|
+
return _context5.finish(24);
|
|
1246
1275
|
|
|
1247
|
-
case
|
|
1276
|
+
case 28:
|
|
1248
1277
|
case "end":
|
|
1249
1278
|
return _context5.stop();
|
|
1250
1279
|
}
|
|
1251
1280
|
}
|
|
1252
|
-
}, _callee5, null, [[1,
|
|
1281
|
+
}, _callee5, null, [[1, 20, 24, 28]]);
|
|
1253
1282
|
}));
|
|
1254
1283
|
|
|
1255
1284
|
return function handleOnEvaluateAll(_x4) {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.normalizeProduct = exports.getConceptByTab = void 0;
|
|
7
7
|
|
|
8
|
+
var _statusDictionary = require("../../../global-files/statusDictionary");
|
|
9
|
+
|
|
8
10
|
var normalizeProduct = function normalizeProduct(product) {
|
|
9
11
|
// Handle case where product might be wrapped in a product property
|
|
10
12
|
var productData = product.product || product;
|
|
@@ -43,7 +45,7 @@ var normalizeProduct = function normalizeProduct(product) {
|
|
|
43
45
|
version: productData.version || 0,
|
|
44
46
|
// from tasks
|
|
45
47
|
id_order: productData.orderId || 0,
|
|
46
|
-
status: productData.status || null,
|
|
48
|
+
status: productData.statusByRetailer ? (0, _statusDictionary.getMinorStatusFromRetailerMap)(productData.statusByRetailer) : productData.status || null,
|
|
47
49
|
datasheet_status: productData.datasheet_status || null,
|
|
48
50
|
description_status: productData.description_status || null,
|
|
49
51
|
images_status: productData.images_status || null,
|
|
@@ -5,7 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.PRODUCT_ACTIONS = void 0;
|
|
9
|
+
exports.getMinorStatusFromRetailer = getMinorStatusFromRetailer;
|
|
10
|
+
exports.productReducer = exports.productInitialState = void 0;
|
|
9
11
|
|
|
10
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
11
13
|
|
|
@@ -49,7 +51,7 @@ var productReducer = function productReducer(state, action) {
|
|
|
49
51
|
|
|
50
52
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state), {}, {
|
|
51
53
|
product: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, state.product), {}, {
|
|
52
|
-
status: getMinorStatus(action.payload.map(function (status) {
|
|
54
|
+
status: (0, _statusDictionary.getMinorStatus)(action.payload.map(function (status) {
|
|
53
55
|
return status === null || status === void 0 ? void 0 : status.status;
|
|
54
56
|
})),
|
|
55
57
|
description_status: ((_action$payload$find = action.payload.find(function (status) {
|
|
@@ -102,24 +104,14 @@ var productReducer = function productReducer(state, action) {
|
|
|
102
104
|
return null;
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
|
-
};
|
|
107
|
+
}; // Wrapper for array format: [{ status: "AS" }, ...]
|
|
108
|
+
|
|
106
109
|
|
|
107
110
|
exports.productReducer = productReducer;
|
|
108
111
|
|
|
109
|
-
function
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
console.log({
|
|
115
|
-
servicesStatus: servicesStatus
|
|
116
|
-
});
|
|
117
|
-
var winner = servicesStatus.reduce(function (minor, current) {
|
|
118
|
-
var currentObj = typeof current === "string" ? _statusDictionary.STATUS_DICTIONARY[current] : current;
|
|
119
|
-
var minorObj = typeof minor === "string" ? _statusDictionary.STATUS_DICTIONARY[minor] : minor;
|
|
120
|
-
if (!currentObj || typeof currentObj.weight === "undefined") return minor;
|
|
121
|
-
if (!minorObj || typeof minorObj.weight === "undefined") return current;
|
|
122
|
-
return currentObj.weight < minorObj.weight ? currentObj : minorObj;
|
|
123
|
-
}, servicesStatus[0] || _statusDictionary.STATUS_DICTIONARY.NS);
|
|
124
|
-
return (winner === null || winner === void 0 ? void 0 : winner.status) || ((_STATUS_DICTIONARY$NS = _statusDictionary.STATUS_DICTIONARY.NS) === null || _STATUS_DICTIONARY$NS === void 0 ? void 0 : _STATUS_DICTIONARY$NS.status);
|
|
112
|
+
function getMinorStatusFromRetailer() {
|
|
113
|
+
var statusByRetailer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
114
|
+
return (0, _statusDictionary.getMinorStatus)(statusByRetailer.map(function (s) {
|
|
115
|
+
return s === null || s === void 0 ? void 0 : s.status;
|
|
116
|
+
}));
|
|
125
117
|
}
|
|
@@ -31,6 +31,8 @@ var _fileSaver = require("file-saver");
|
|
|
31
31
|
|
|
32
32
|
var _providerProductEdition = require("./context/provider-product-edition.context");
|
|
33
33
|
|
|
34
|
+
var _product = require("./context/reducers/product");
|
|
35
|
+
|
|
34
36
|
var _utils = require("./utils");
|
|
35
37
|
|
|
36
38
|
var _data = require("../../../global-files/data");
|
|
@@ -95,7 +97,12 @@ var _material = require("@mui/material");
|
|
|
95
97
|
|
|
96
98
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
97
99
|
|
|
98
|
-
var allowedAccountsToViewChangeStatus = ["mperez@contentoh.com", "gmorales@contentoh.com", "rvega@contentoh.com", "amora@contentoh.com",
|
|
100
|
+
var allowedAccountsToViewChangeStatus = ["mperez@contentoh.com", "gmorales@contentoh.com", "rvega@contentoh.com", "amora@contentoh.com", //PRODUCT DEV ACCOUNTS
|
|
101
|
+
"oparra@contentoh.com", "zsegura@contentoh.com", "oserna@contentoh.com", "jalvarado@contentoh.com", //DEV ACCOUNTS
|
|
102
|
+
"kikije1467@mtlcz.com", //IMÁGENES
|
|
103
|
+
"karafe3218@mom2kid.com", //TEXTOS
|
|
104
|
+
"ladiboh785@mi166.com" //QA
|
|
105
|
+
];
|
|
99
106
|
|
|
100
107
|
var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
101
108
|
var _location$state, _location$state2, _state$active_retaile4, _state$active_retaile5, _state$images_values$2, _state$images_values10, _state$images_values11, _state$product8, _state$active_retaile6, _state$active_retaile7, _state$active_retaile8, _state$active_retaile9, _state$product9, _state$product10, _state$product11, _state$datasheets_inp, _state$datasheets_inp2, _state$product12, _state$images_values12, _state$comment;
|
|
@@ -994,7 +1001,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
|
994
1001
|
var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(result) {
|
|
995
1002
|
var _state$product$id_ord, _state$active_retaile3;
|
|
996
1003
|
|
|
997
|
-
var concept, articleId, orderId, sectionStatusKey, evalStatus, retailerId, data, res, message, icon, activeTab, newStatuses, serviceStatus, articleStatus, updatedStatusByRetailer, updatedProduct, specialistDone, _objectSpread2, _state$services_data2, _JSON$parse2, newStatus, newOrderStatus, newArticleStatus, _articleStatus, _updatedProduct, updatedServicesData, sessionProduct, _objectSpread3, productInSession, updatedProductInSession;
|
|
1004
|
+
var concept, articleId, orderId, sectionStatusKey, evalStatus, retailerId, data, res, message, icon, activeTab, newStatuses, serviceStatus, articleStatus, updatedStatusByRetailer, updatedProduct, specialistDone, _objectSpread2, _state$services_data2, _JSON$parse2, newStatus, newOrderStatus, newArticleStatus, _articleStatus, updatedStatusByRetailerForSend, _updatedProduct, updatedServicesData, sessionProduct, _objectSpread3, productInSession, updatedProductInSession;
|
|
998
1005
|
|
|
999
1006
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
1000
1007
|
while (1) {
|
|
@@ -1057,10 +1064,8 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
|
1057
1064
|
}) : item;
|
|
1058
1065
|
});
|
|
1059
1066
|
updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, {
|
|
1060
|
-
statusByRetailer: updatedStatusByRetailer
|
|
1061
|
-
|
|
1062
|
-
// article_status: articleStatus
|
|
1063
|
-
|
|
1067
|
+
statusByRetailer: updatedStatusByRetailer,
|
|
1068
|
+
status: (0, _product.getMinorStatusFromRetailer)(updatedStatusByRetailer)
|
|
1064
1069
|
});
|
|
1065
1070
|
dispatch({
|
|
1066
1071
|
type: "SET_PRODUCT",
|
|
@@ -1131,7 +1136,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
|
1131
1136
|
// };
|
|
1132
1137
|
// await sendMessage(messageData);
|
|
1133
1138
|
|
|
1134
|
-
|
|
1139
|
+
updatedStatusByRetailerForSend = state.product.statusByRetailer.map(function (item) {
|
|
1135
1140
|
if (item.retailer_id === retailerId && item.service === concept) {
|
|
1136
1141
|
return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, item), {}, {
|
|
1137
1142
|
status: newStatus
|
|
@@ -1139,7 +1144,8 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
|
1139
1144
|
}
|
|
1140
1145
|
|
|
1141
1146
|
return item;
|
|
1142
|
-
})
|
|
1147
|
+
});
|
|
1148
|
+
_updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, (_objectSpread2 = {}, (0, _defineProperty2.default)(_objectSpread2, "".concat(concept, "_status"), newStatus), (0, _defineProperty2.default)(_objectSpread2, "statusByRetailer", updatedStatusByRetailerForSend), (0, _defineProperty2.default)(_objectSpread2, "status", (0, _product.getMinorStatusFromRetailer)(updatedStatusByRetailerForSend)), _objectSpread2)); //Actualizamos el services_data en el servicio específico del retailer actual
|
|
1143
1149
|
|
|
1144
1150
|
updatedServicesData = (_state$services_data2 = state.services_data) === null || _state$services_data2 === void 0 ? void 0 : _state$services_data2.map(function (service) {
|
|
1145
1151
|
return (0, _objectSpread5.default)((0, _objectSpread5.default)({}, service), {}, {
|
|
@@ -1268,7 +1274,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
|
1268
1274
|
var retailer_service = ret.service,
|
|
1269
1275
|
id_retailer = ret.id_retailer,
|
|
1270
1276
|
status_retailer_service = ret.status;
|
|
1271
|
-
var lastStatusLevel = status_retailer_service.replace(/.*\//, "");
|
|
1277
|
+
var lastStatusLevel = status_retailer_service === null || status_retailer_service === void 0 ? void 0 : status_retailer_service.replace(/.*\//, "");
|
|
1272
1278
|
|
|
1273
1279
|
if (conceptArray.includes(retailer_service) && statusArray !== null && statusArray !== void 0 && statusArray.includes(lastStatusLevel)) {
|
|
1274
1280
|
var data = {
|
|
@@ -1300,7 +1306,7 @@ var RetailerProductEditionView = function RetailerProductEditionView(_ref) {
|
|
|
1300
1306
|
|
|
1301
1307
|
updatedProduct = (0, _objectSpread5.default)((0, _objectSpread5.default)({}, state.product), {}, {
|
|
1302
1308
|
article_status: status,
|
|
1303
|
-
status:
|
|
1309
|
+
status: (0, _product.getMinorStatusFromRetailer)(updatedStatusByRetailer),
|
|
1304
1310
|
datasheet_status: state.product.datasheet_status === "NA" ? "NA" : status,
|
|
1305
1311
|
description_status: state.product.description_status === "NA" ? "NA" : status,
|
|
1306
1312
|
images_status: state.product.images_status === "NA" ? "NA" : status,
|
|
@@ -161,7 +161,7 @@ var normalizeProduct = function normalizeProduct(product) {
|
|
|
161
161
|
percentages: productData.percentages || null,
|
|
162
162
|
summary: productData.summary || null,
|
|
163
163
|
version: productData.version || 0,
|
|
164
|
-
id_order: productData.orderId || 0,
|
|
164
|
+
id_order: productData.orderId || productData.id_order || 0,
|
|
165
165
|
status: productData.status || null,
|
|
166
166
|
datasheet_status: productData.datasheet_status || null,
|
|
167
167
|
description_status: productData.description_status || null,
|
|
@@ -91,40 +91,47 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
|
|
|
91
91
|
inputsUsingAi = _useState16[0],
|
|
92
92
|
setInputsUsingAi = _useState16[1];
|
|
93
93
|
|
|
94
|
-
var
|
|
95
|
-
var
|
|
94
|
+
var AI_MAX_CREDITS = 2;
|
|
95
|
+
var AI_RESET_MS = 24 * 60 * 60 * 1000;
|
|
96
96
|
var RATE_LIMIT_KEY = "ai_generation_limit_data";
|
|
97
97
|
|
|
98
|
-
var checkAndManageRateLimit = function checkAndManageRateLimit(
|
|
98
|
+
var checkAndManageRateLimit = function checkAndManageRateLimit(_ref2) {
|
|
99
|
+
var articleId = _ref2.articleId,
|
|
100
|
+
descriptionId = _ref2.descriptionId,
|
|
101
|
+
attributeId = _ref2.attributeId,
|
|
102
|
+
type = _ref2.type;
|
|
99
103
|
var now = Date.now();
|
|
100
104
|
var storedData = localStorage.getItem(RATE_LIMIT_KEY);
|
|
101
105
|
var allRateData = storedData ? JSON.parse(storedData) : {};
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
var idPart = descriptionId !== null && descriptionId !== void 0 ? descriptionId : attributeId;
|
|
107
|
+
var key = idPart ? "".concat(articleId, "_").concat(idPart, "_").concat(type) : "".concat(articleId);
|
|
108
|
+
var keyTimestamps = allRateData[key] || [];
|
|
109
|
+
keyTimestamps = keyTimestamps.filter(function (timestamp) {
|
|
110
|
+
return now - timestamp < AI_RESET_MS;
|
|
105
111
|
});
|
|
106
112
|
|
|
107
|
-
if (
|
|
108
|
-
allRateData[
|
|
113
|
+
if (keyTimestamps.length >= AI_MAX_CREDITS) {
|
|
114
|
+
allRateData[key] = keyTimestamps;
|
|
109
115
|
localStorage.setItem(RATE_LIMIT_KEY, JSON.stringify(allRateData));
|
|
110
116
|
return {
|
|
111
117
|
allowed: false,
|
|
112
|
-
message: "Has alcanzado el
|
|
118
|
+
message: idPart ? "Has alcanzado el límite de intentos para este atributo. Vuelve a intentarlo en 24 horas." : "Has alcanzado el límite de intentos para este producto. Vuelve a intentarlo en 24 horas."
|
|
113
119
|
};
|
|
114
|
-
}
|
|
120
|
+
} // Registramos el intento
|
|
115
121
|
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
|
|
123
|
+
keyTimestamps.push(now);
|
|
124
|
+
allRateData[key] = keyTimestamps;
|
|
118
125
|
localStorage.setItem(RATE_LIMIT_KEY, JSON.stringify(allRateData));
|
|
119
126
|
return {
|
|
120
127
|
allowed: true
|
|
121
128
|
};
|
|
122
129
|
};
|
|
123
130
|
|
|
124
|
-
function setCurrentSuggestionValue(
|
|
125
|
-
var inputId =
|
|
126
|
-
index =
|
|
127
|
-
value =
|
|
131
|
+
function setCurrentSuggestionValue(_ref3) {
|
|
132
|
+
var inputId = _ref3.inputId,
|
|
133
|
+
index = _ref3.index,
|
|
134
|
+
value = _ref3.value;
|
|
128
135
|
setCurrentSuggestion(function (prev) {
|
|
129
136
|
return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, prev), {}, (0, _defineProperty2.default)({}, inputId, {
|
|
130
137
|
index: index,
|
|
@@ -142,13 +149,13 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
|
|
|
142
149
|
}
|
|
143
150
|
|
|
144
151
|
function _regenerateProductSuggestions() {
|
|
145
|
-
_regenerateProductSuggestions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(
|
|
152
|
+
_regenerateProductSuggestions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref4) {
|
|
146
153
|
var inputName, currentValue, description, maxChar, type, articleId, versionId, descriptionId, attributeId, newSuggestions;
|
|
147
154
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
148
155
|
while (1) {
|
|
149
156
|
switch (_context.prev = _context.next) {
|
|
150
157
|
case 0:
|
|
151
|
-
inputName =
|
|
158
|
+
inputName = _ref4.inputName, currentValue = _ref4.currentValue, description = _ref4.description, maxChar = _ref4.maxChar, type = _ref4.type, articleId = _ref4.articleId, versionId = _ref4.versionId, descriptionId = _ref4.descriptionId, attributeId = _ref4.attributeId;
|
|
152
159
|
|
|
153
160
|
if (!(!description || !maxChar || !type)) {
|
|
154
161
|
_context.next = 3;
|
|
@@ -218,14 +225,14 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
|
|
|
218
225
|
|
|
219
226
|
|
|
220
227
|
function _generateProductSuggestions() {
|
|
221
|
-
_generateProductSuggestions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(
|
|
222
|
-
var
|
|
228
|
+
_generateProductSuggestions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref5) {
|
|
229
|
+
var _ref5$inputName, inputName, _ref5$currentValue, currentValue, _ref5$description, description, _ref5$maxChar, maxChar, _ref5$type, type, articleId, versionId, descriptionId, attributeId, _state$product, _JSON$parse, _JSON$parse2, _JSON$parse2$error, _JSON$parse$data, _JSON$parse3, rateLimitStatus, upc, productName, retailer, category, version, payload, _yield$axios$post, data, errorsRaw, errorMessage, results, _error$message;
|
|
223
230
|
|
|
224
231
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
225
232
|
while (1) {
|
|
226
233
|
switch (_context2.prev = _context2.next) {
|
|
227
234
|
case 0:
|
|
228
|
-
|
|
235
|
+
_ref5$inputName = _ref5.inputName, inputName = _ref5$inputName === void 0 ? "" : _ref5$inputName, _ref5$currentValue = _ref5.currentValue, currentValue = _ref5$currentValue === void 0 ? "" : _ref5$currentValue, _ref5$description = _ref5.description, description = _ref5$description === void 0 ? "" : _ref5$description, _ref5$maxChar = _ref5.maxChar, maxChar = _ref5$maxChar === void 0 ? 100 : _ref5$maxChar, _ref5$type = _ref5.type, type = _ref5$type === void 0 ? 'description' : _ref5$type, articleId = _ref5.articleId, versionId = _ref5.versionId, descriptionId = _ref5.descriptionId, attributeId = _ref5.attributeId;
|
|
229
236
|
_context2.prev = 1;
|
|
230
237
|
|
|
231
238
|
if (isAiAvailable) {
|
|
@@ -236,7 +243,12 @@ var AiProductEditionProvider = function AiProductEditionProvider(_ref) {
|
|
|
236
243
|
return _context2.abrupt("return");
|
|
237
244
|
|
|
238
245
|
case 4:
|
|
239
|
-
rateLimitStatus = checkAndManageRateLimit(
|
|
246
|
+
rateLimitStatus = checkAndManageRateLimit({
|
|
247
|
+
articleId: articleId,
|
|
248
|
+
descriptionId: descriptionId,
|
|
249
|
+
attributeId: attributeId,
|
|
250
|
+
type: type
|
|
251
|
+
});
|
|
240
252
|
|
|
241
253
|
if (rateLimitStatus.allowed) {
|
|
242
254
|
_context2.next = 7;
|
|
@@ -98,6 +98,41 @@ var STATUS_DICTIONARY = {
|
|
|
98
98
|
weight: 100
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
+
|
|
102
|
+
var resolveStatusObj = function resolveStatusObj(statusStr) {
|
|
103
|
+
if (!statusStr || typeof statusStr !== "string") return null;
|
|
104
|
+
if (STATUS_DICTIONARY[statusStr]) return STATUS_DICTIONARY[statusStr]; // Compound statuses like 'RA/AS' — use last segment for weight lookup
|
|
105
|
+
|
|
106
|
+
var parts = statusStr.split("/");
|
|
107
|
+
var lastPart = parts[parts.length - 1];
|
|
108
|
+
var dictEntry = STATUS_DICTIONARY[lastPart];
|
|
109
|
+
if (dictEntry) return {
|
|
110
|
+
status: statusStr,
|
|
111
|
+
name: statusStr,
|
|
112
|
+
weight: dictEntry.weight
|
|
113
|
+
};
|
|
114
|
+
return null;
|
|
115
|
+
}; // Returns the status string with the lowest weight from an array of status strings
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
var getMinorStatus = function getMinorStatus() {
|
|
119
|
+
var servicesStatus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
120
|
+
if (!servicesStatus || servicesStatus.length === 0) return STATUS_DICTIONARY.NS.status;
|
|
121
|
+
var winner = servicesStatus.reduce(function (minorObj, current) {
|
|
122
|
+
var currentObj = resolveStatusObj(typeof current === "string" ? current : current === null || current === void 0 ? void 0 : current.status);
|
|
123
|
+
if (!currentObj || typeof currentObj.weight === "undefined") return minorObj;
|
|
124
|
+
return currentObj.weight < minorObj.weight ? currentObj : minorObj;
|
|
125
|
+
}, STATUS_DICTIONARY.NS);
|
|
126
|
+
return (winner === null || winner === void 0 ? void 0 : winner.status) || STATUS_DICTIONARY.NS.status;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
var getMinorStatusFromRetailerMap = function getMinorStatusFromRetailerMap() {
|
|
130
|
+
var statusByRetailer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
131
|
+
return getMinorStatus(Object.values(statusByRetailer).flatMap(Object.values));
|
|
132
|
+
};
|
|
133
|
+
|
|
101
134
|
module.exports = {
|
|
102
|
-
STATUS_DICTIONARY: STATUS_DICTIONARY
|
|
135
|
+
STATUS_DICTIONARY: STATUS_DICTIONARY,
|
|
136
|
+
getMinorStatus: getMinorStatus,
|
|
137
|
+
getMinorStatusFromRetailerMap: getMinorStatusFromRetailerMap
|
|
103
138
|
};
|
package/package.json
CHANGED
|
@@ -43,12 +43,8 @@ export const ProgressBar = ({ percent, progressBarType, percentRequired }) => {
|
|
|
43
43
|
}
|
|
44
44
|
children={
|
|
45
45
|
!percent && percent != 0 ? null : (
|
|
46
|
-
<Container
|
|
47
|
-
{
|
|
48
|
-
<p>{
|
|
49
|
-
Math.round(percent)
|
|
50
|
-
}%</p>
|
|
51
|
-
}
|
|
46
|
+
<Container percentageRequired={Math.round(percent)}>
|
|
47
|
+
<p>{Math.round(percent)}%</p>
|
|
52
48
|
</Container>
|
|
53
49
|
)
|
|
54
50
|
}
|