contentoh-components-library 21.6.1 → 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.
Files changed (27) hide show
  1. package/dist/components/atoms/ProgressBar/index.js +1 -1
  2. package/dist/components/atoms/ProgressBar/styles.js +4 -4
  3. package/dist/components/atoms/Status/index.js +16 -1
  4. package/dist/components/atoms/Status/styles.js +1 -1
  5. package/dist/components/organisms/ChangeStatusModal/index.js +166 -53
  6. package/dist/components/organisms/ChangeStatusModal/styles.js +12 -8
  7. package/dist/components/pages/ProviderProductEdition/context/provider-product-edition.context.js +3 -1
  8. package/dist/components/pages/ProviderProductEdition/index.js +65 -36
  9. package/dist/components/pages/ProviderProductEdition/utils.js +3 -1
  10. package/dist/components/pages/RetailerProductEdition/context/reducers/product.js +11 -19
  11. package/dist/components/pages/RetailerProductEdition/index.js +16 -10
  12. package/dist/components/pages/RetailerProductEdition/utils.js +1 -1
  13. package/dist/global-files/statusDictionary.js +36 -1
  14. package/package.json +1 -1
  15. package/src/components/atoms/ProgressBar/index.js +2 -6
  16. package/src/components/atoms/ProgressBar/styles.js +4 -58
  17. package/src/components/atoms/Status/index.js +11 -3
  18. package/src/components/atoms/Status/styles.js +113 -0
  19. package/src/components/organisms/ChangeStatusModal/index.jsx +103 -29
  20. package/src/components/organisms/ChangeStatusModal/styles.js +20 -0
  21. package/src/components/pages/ProviderProductEdition/context/provider-product-edition.context.jsx +1 -0
  22. package/src/components/pages/ProviderProductEdition/index.js +40 -14
  23. package/src/components/pages/ProviderProductEdition/utils.js +5 -1
  24. package/src/components/pages/RetailerProductEdition/context/reducers/product.js +4 -20
  25. package/src/components/pages/RetailerProductEdition/index.js +20 -16
  26. package/src/components/pages/RetailerProductEdition/utils.js +1 -1
  27. 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 = 26;
404
+ _context2.next = 30;
383
405
  break;
384
406
 
385
- case 22:
386
- _context2.prev = 22;
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 26:
395
- _context2.prev = 26;
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(26);
422
+ return _context2.finish(30);
401
423
 
402
- case 29:
424
+ case 33:
403
425
  case "end":
404
426
  return _context2.stop();
405
427
  }
406
428
  }
407
- }, _callee2, null, [[1, 22, 26, 29]]);
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$product10, _state$active_retaile2;
835
+ var _state$product$id_ord, _state$active_retaile2, _state$product$status, _state$product$status2, _state$product10;
814
836
 
815
- var concept, articleId, orderId, sectionStatusKey, evalStatus, data, retailerId, _newStatuses$newStatu, _state$services_data, res, newStatuses, serviceStatus, updatedProduct, updatedServicesData;
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
- sectionStatusKey = "".concat(concept, "_status");
829
- evalStatus = state.product[sectionStatusKey] || ((_state$product10 = state.product) === null || _state$product10 === void 0 ? void 0 : _state$product10.version_status);
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
- retailerId = (_state$active_retaile2 = state.active_retailer) === null || _state$active_retaile2 === void 0 ? void 0 : _state$active_retaile2.id_retailer;
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 = 14;
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 14:
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: (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))))
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"](8);
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, [[8, 24, 28, 31]]);
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 data = {};
1165
- data = (0, _objectSpread4.default)((0, _objectSpread4.default)({}, dataGeneral), {}, {
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: state.product.statusByRetailer[id_retailer][service]
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 = 8;
1205
+ _context5.next = 9;
1178
1206
  return Promise.all(evaluationArray);
1179
1207
 
1180
- case 8:
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 = 23;
1250
+ _context5.next = 24;
1222
1251
  break;
1223
1252
 
1224
- case 19:
1225
- _context5.prev = 19;
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 23:
1239
- _context5.prev = 23;
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(23);
1274
+ return _context5.finish(24);
1246
1275
 
1247
- case 27:
1276
+ case 28:
1248
1277
  case "end":
1249
1278
  return _context5.stop();
1250
1279
  }
1251
1280
  }
1252
- }, _callee5, null, [[1, 19, 23, 27]]);
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.productReducer = exports.productInitialState = exports.PRODUCT_ACTIONS = void 0;
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 getMinorStatus() {
110
- var _STATUS_DICTIONARY$NS;
111
-
112
- var servicesStatus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
113
- if (!servicesStatus || servicesStatus.length === 0) return _statusDictionary.STATUS_DICTIONARY.NS.name;
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", "oparra@contentoh.com", "zsegura@contentoh.com", "oserna@contentoh.com", "jalvarado@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 // version_status: articleStatus,
1061
- // status: articleStatus,
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
- _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) {
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
- })), _objectSpread2)); //Actualizamos el services_data en el servicio específico del retailer actual
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: 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,
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.6.1",
3
+ "version": "21.6.11",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -43,12 +43,8 @@ export const ProgressBar = ({ percent, progressBarType, percentRequired }) => {
43
43
  }
44
44
  children={
45
45
  !percent && percent != 0 ? null : (
46
- <Container className={`status-${progressBarType}`}>
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
  }
@@ -2,7 +2,8 @@ import styled from "styled-components";
2
2
  import { FontFamily, GlobalColors } from "../../../global-files/variables";
3
3
 
4
4
  export const Container = styled.div`
5
- background-color: ${GlobalColors.s3};
5
+ background-color: ${(props) =>
6
+ props.percentageRequired >= 100 ? GlobalColors.color_pink : GlobalColors.s3};
6
7
  width: fit-content;
7
8
  height: 27px;
8
9
  padding: 4px;
@@ -11,62 +12,7 @@ export const Container = styled.div`
11
12
  font-weight: 600;
12
13
  font-size: 14px;
13
14
  line-height: 19px;
14
- color: ${(backgroundColor) =>
15
- backgroundColor === "s2" || backgroundColor === "s1"
16
- ? GlobalColors.s4
17
- : GlobalColors.white};
18
-
19
- &.status-CA,
20
- &.status-IE {
21
- background-color: ${GlobalColors.in_progress};
22
- }
23
-
24
- &.status-R,
25
- &.status-AS,
26
- &.status-PA {
27
- background-color: ${GlobalColors.reception};
28
- }
29
-
30
- &.status-AA,
31
- &.status-AP,
32
- &.status-ACA,
33
- &.status-AC {
34
- background-color: ${GlobalColors.finished};
35
- }
36
-
37
- &.status-RA,
38
- &.status-RC,
39
- &.status-RP,
40
- &.status-RCA {
41
- background-color: ${GlobalColors.rejected_status};
42
- }
43
-
44
- &.status-Dat,
45
- &.status-Dsc,
46
- &.status-Imgs {
47
- background-color: ${GlobalColors.s4};
48
- }
49
-
50
- &.status-Ex {
51
- background-color: ${GlobalColors.exported};
52
- }
53
-
54
- &.status-DDI {
55
- background-color: ${GlobalColors.original_purpura};
56
- }
57
-
58
- &.status-GLD {
59
- background-color: ${GlobalColors.in_progress};
60
- }
61
-
62
- &.status-TAB {
63
- background-color: ${GlobalColors.deep_gray};
64
- }
65
-
66
- &.status-Pt {
67
- background-color: ${GlobalColors.s2};
68
- color: ${GlobalColors.s4};
69
- }
15
+ color: ${GlobalColors.white};
70
16
  `;
71
17
  export const ContainerIcon = styled.div`
72
18
  cursor: pointer;
@@ -89,6 +35,6 @@ export const ContainerIcon = styled.div`
89
35
  ${(props) => (props.percentageRequired < 100 ? 0 : 1)},
90
36
  "wght" 400, "GRAD" 0, "opsz" 48;
91
37
  color: ${(props) =>
92
- props.percentageRequired < 100 ? "#d4d1d7" : "#e33aa9"};
38
+ props.percentageRequired < 100 ? "#d4d1d7" : GlobalColors.color_pink};
93
39
  }
94
40
  `;
@@ -1,11 +1,19 @@
1
1
  import { Container } from "./styles";
2
+ import { STATUS_DICTIONARY } from "../../../global-files/statusDictionary";
3
+
4
+ const getStatusName = (statusType) => {
5
+ if (!statusType) return null;
6
+ const parts = statusType.split("/");
7
+ const names = parts.map((key) => STATUS_DICTIONARY[key]?.name).filter(Boolean);
8
+ return names.length > 0 ? names.join(" / ") : null;
9
+ };
2
10
 
3
11
  export const Status = ({ statusType, ovalForm }) => {
12
+ const tooltipLabel = getStatusName(statusType);
4
13
  return (
5
14
  <Container
6
- className={`status-${statusType?.replace(/\/.*/, "")} ${
7
- ovalForm && "oval-form"
8
- }`}
15
+ className={`status-${statusType?.replace(/\/.*/, "")} ${ovalForm ? "oval-form" : ""}`}
16
+ data-tooltip={tooltipLabel}
9
17
  >
10
18
  <p>{statusType ?? "NS"}</p>
11
19
  </Container>