contentoh-components-library 21.4.91 → 21.4.93

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.
@@ -57,34 +57,45 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
57
57
 
58
58
  var _useState7 = (0, _react.useState)(""),
59
59
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
60
- inputValue = _useState8[0],
61
- setInputValue = _useState8[1];
60
+ newPhaseName = _useState8[0],
61
+ setNewPhaseName = _useState8[1];
62
62
 
63
- var _useState9 = (0, _react.useState)({
63
+ var _useState9 = (0, _react.useState)(""),
64
+ _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
65
+ inputValue = _useState10[0],
66
+ setInputValue = _useState10[1];
67
+
68
+ var _useState11 = (0, _react.useState)({
64
69
  show: false,
65
70
  title: "Actualización completa",
66
71
  message: "",
67
72
  icon: "success"
68
73
  }),
69
- _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
70
- modalData = _useState10[0],
71
- setModalData = _useState10[1];
74
+ _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
75
+ modalData = _useState12[0],
76
+ setModalData = _useState12[1];
72
77
 
73
78
  (0, _react.useEffect)(function () {
74
79
  return loadData();
75
80
  }, []);
81
+ var newPhaseNameRef = (0, _react.useRef)("");
82
+ (0, _react.useEffect)(function () {
83
+ newPhaseNameRef.current = newPhaseName;
84
+ }, [newPhaseName]);
76
85
  (0, _react.useEffect)(function () {
77
- console.log(inputValue);
86
+ setNewPhaseName(function (prev) {
87
+ return prev + inputValue;
88
+ });
78
89
  }, [inputValue]);
79
90
 
80
- var _onDragStart = function onDragStart(e, id) {
91
+ var onDragStart = function onDragStart(e, id) {
81
92
  e.dataTransfer.effectAllowed = "move";
82
93
  e.dataTransfer.setData("text/html", e.target.parentNode);
83
94
  e.dataTransfer.setDragImage(e.target.parentNode, 20, 20);
84
95
  setDraggedItem(id);
85
96
  };
86
97
 
87
- var _onDragOver = function onDragOver(index) {
98
+ var onDragOver = function onDragOver(index) {
88
99
  var draggedIdx = tempListPhases.findIndex(function (phase) {
89
100
  return phase.phaseId === draggedItem;
90
101
  });
@@ -98,8 +109,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
98
109
 
99
110
  var onDragEnd = function onDragEnd() {
100
111
  setDraggedItem(null);
101
- }; // useEffect(() => {console.log("nuevo",newPhaseName)},[newPhaseName]);
102
-
112
+ };
103
113
 
104
114
  var updatePhases = /*#__PURE__*/function () {
105
115
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
@@ -155,15 +165,11 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
155
165
  };
156
166
  }();
157
167
 
158
- var handleInputChange = function handleInputChange(value) {
159
- setInputValue(function (prevInputValue) {
160
- var newValue = prevInputValue + value;
161
- console.log("currentInputValue", newValue);
162
- return newValue;
163
- });
168
+ var handleInputChange = function handleInputChange(e) {
169
+ setInputValue(e.target.value);
164
170
  };
165
171
 
166
- var AddPhase = /*#__PURE__*/function () {
172
+ var addPhase = /*#__PURE__*/function () {
167
173
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(phaseName) {
168
174
  var body, response, createdPhase;
169
175
  return _regenerator.default.wrap(function _callee2$(_context2) {
@@ -186,26 +192,28 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
186
192
 
187
193
  case 5:
188
194
  response = _context2.sent;
195
+ console.log("body", body);
189
196
  createdPhase = response.data.body;
190
197
  console.log(createdPhase);
191
198
  setInputValue("");
192
- _context2.next = 14;
199
+ loadData();
200
+ _context2.next = 16;
193
201
  break;
194
202
 
195
- case 11:
196
- _context2.prev = 11;
203
+ case 13:
204
+ _context2.prev = 13;
197
205
  _context2.t0 = _context2["catch"](1);
198
206
  console.error("Error al agregar fase:", _context2.t0);
199
207
 
200
- case 14:
208
+ case 16:
201
209
  case "end":
202
210
  return _context2.stop();
203
211
  }
204
212
  }
205
- }, _callee2, null, [[1, 11]]);
213
+ }, _callee2, null, [[1, 13]]);
206
214
  }));
207
215
 
208
- return function AddPhase(_x) {
216
+ return function addPhase(_x) {
209
217
  return _ref3.apply(this, arguments);
210
218
  };
211
219
  }();
@@ -280,10 +288,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
280
288
  show: false
281
289
  });
282
290
  });
283
- setInputValue(function (prevInputValue) {
284
- AddPhase(prevInputValue);
285
- return prevInputValue;
286
- });
291
+ handleSavePhase();
287
292
  }
288
293
  }, "btn-Guardar")],
289
294
  customComponent: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -295,13 +300,18 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
295
300
  placeholder: "Nombre de fase",
296
301
  value: inputValue,
297
302
  onChange: function onChange(e) {
298
- return handleInputChange(e.target.value);
303
+ return handleInputChange(e);
299
304
  }
300
305
  })]
301
306
  })
302
307
  });
303
308
  };
304
309
 
310
+ var handleSavePhase = function handleSavePhase() {
311
+ addPhase(newPhaseNameRef.current);
312
+ setInputValue("");
313
+ };
314
+
305
315
  var loadData = /*#__PURE__*/function () {
306
316
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
307
317
  var response, phasesData, phasesDataArray;
@@ -404,22 +414,19 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
404
414
  var renderPhase = function renderPhase(phase, idx) {
405
415
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Phase.Phase, {
406
416
  id: idx,
417
+ phaseId: phase.phaseId,
407
418
  phases: listPhases,
408
419
  phaseName: phase.phaseName,
409
420
  nextPhase: phase.nextPhaseIfApproved,
410
421
  groups: phase.groupsAssigned,
411
422
  onDeletePhase: function onDeletePhase() {
412
423
  return handleDeletePhase(phase.phaseId);
413
- },
414
- onDragStart: function onDragStart(e) {
415
- return _onDragStart(e, idx);
416
- },
417
- onDragOver: function onDragOver() {
418
- return _onDragOver(idx);
419
- },
420
- onDragEnd: onDragEnd,
424
+ } // onDragStart={(e) => onDragStart(e, idx)}
425
+ // onDragOver={() => onDragOver(idx)}
426
+ // onDragEnd={onDragEnd}
427
+ ,
421
428
  token: token
422
- }, idx);
429
+ }, phase.phaseId);
423
430
  };
424
431
 
425
432
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
@@ -456,10 +463,15 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
456
463
  });
457
464
  }
458
465
  }, "btn-Guardar")]
459
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
466
+ }), listPhases.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
460
467
  children: listPhases.map(function (phase, idx) {
461
468
  return renderPhase(phase, idx);
462
469
  })
470
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
471
+ className: "no-phases-container",
472
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
473
+ children: "Parece que aun no tienes fases disponibles."
474
+ })
463
475
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Modal.Modal, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, modalData), {}, {
464
476
  onClickBtnDefault: function onClickBtnDefault() {
465
477
  return setModalData(function (prev) {
@@ -15,7 +15,7 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject, _templateObject2;
17
17
 
18
- var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\ndisplay:flex;\nflex-direction: column;\ngap:20px;\nwidth:100%;\nul{\n display:flex;\n flex-direction:column;\n width:100%;\n gap:10px;\n}\n .item{\n display:flex;\n width:100%;\n }\n .drag{\n width:100%;\n }\n .container-input-name{\n p{\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n margin-bottom:15px;\n }\n .input-phases{\n width:100%;\n height: 30px;\n padding: 8px 10px;\n border-radius: 5px;\n border: 1px solid ", ";\n ::placeholder {\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: #CBCBCB;\n }\n }\n }\n .modal-add-phase {\n .contentModal{\n min-width:310px;\n }\n header .label-title{\n text-align: left;\n }\n .container-buttons{\n justify-content: flex-end;\n }\n }\n"])), _variables.FontFamily.RobotoRegular, _variables.GlobalColors.gray, _variables.GlobalColors.gray_light, _variables.FontFamily.RobotoRegular);
18
+ var Container = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\ndisplay:flex;\nflex-direction: column;\ngap:20px;\nwidth:100%;\nul{\n display:flex;\n flex-direction:column;\n width:100%;\n gap:10px;\n}\n .item{\n display:flex;\n width:100%;\n }\n .drag{\n width:100%;\n }\n .container-input-name{\n p{\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: ", ";\n margin-bottom:15px;\n }\n .input-phases{\n width:100%;\n height: 30px;\n padding: 8px 10px;\n border-radius: 5px;\n border: 1px solid ", ";\n ::placeholder {\n font-family: ", ", sans-serif;\n font-size: 12px;\n font-weight: 400;\n line-height: 14px;\n letter-spacing: 0em;\n text-align: left;\n color: #CBCBCB;\n }\n }\n }\n .modal-add-phase {\n .contentModal{\n min-width:310px;\n }\n header .label-title{\n text-align: left;\n }\n .container-buttons{\n justify-content: flex-end;\n }\n }\n .no-phases-container {\n display: flex;\n flex-direction:column;\n gap:10px;\n align-items: center;\n border-radius:10px;\n border:1px solid ", ";\n padding:10px 15px;\n font-family:", ", sans-serif;\n font-size:12px;\n }\n"])), _variables.FontFamily.RobotoRegular, _variables.GlobalColors.gray, _variables.GlobalColors.gray_light, _variables.FontFamily.RobotoRegular, _variables.GlobalColors.gray_light, _variables.FontFamily.Roboto);
19
19
 
20
20
  exports.Container = Container;
21
21
 
@@ -843,7 +843,7 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
843
843
  setActivePercentage((_retailers$ = retailers[0]) === null || _retailers$ === void 0 ? void 0 : _retailers$.percentage);
844
844
  }, [percentages]);
845
845
  (0, _react.useEffect)(function () {
846
- //getInputsData(services, activeRetailer, setDatasheets, setDescriptions);
846
+ (0, _utils.getInputsData)(services, activeRetailer, setDatasheets, setDescriptions);
847
847
  auditableVersion && loadAuditableData();
848
848
  setActivePercentage(Math.round(activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.percentage, 0));
849
849
  (activeRetailer === null || activeRetailer === void 0 ? void 0 : activeRetailer.id) && setImages({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.91",
3
+ "version": "21.4.93",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -3,7 +3,7 @@ import { Container } from "./styles";
3
3
  import MuiChip from "@mui/material/Chip";
4
4
  import DeleteIcon from "@mui/icons-material/DeleteForeverOutlined";
5
5
 
6
- export const CustomChip = ({ label, onDelete }) => {
6
+ export const CustomChip = ({ key, label, onDelete }) => {
7
7
  const [isHovered, setIsHovered] = useState(false);
8
8
 
9
9
  const handleMouseEnter = () => {
@@ -16,6 +16,7 @@ export const CustomChip = ({ label, onDelete }) => {
16
16
 
17
17
  return (
18
18
  <MuiChip
19
+ key={key}
19
20
  label={label}
20
21
  onDelete={onDelete}
21
22
  onMouseEnter={handleMouseEnter}