contentoh-components-library 21.4.116 → 21.4.117

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.
@@ -24,7 +24,8 @@ var _jsxRuntime = require("react/jsx-runtime");
24
24
  var CustomChip = function CustomChip(_ref) {
25
25
  var key = _ref.key,
26
26
  label = _ref.label,
27
- onDelete = _ref.onDelete;
27
+ onDelete = _ref.onDelete,
28
+ showDelete = _ref.showDelete;
28
29
 
29
30
  var _useState = (0, _react.useState)(false),
30
31
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -44,19 +45,23 @@ var CustomChip = function CustomChip(_ref) {
44
45
  onDelete: onDelete,
45
46
  onMouseEnter: handleMouseEnter,
46
47
  onMouseLeave: handleMouseLeave,
47
- deleteIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DeleteForeverOutlined.default, {
48
+ deleteIcon: showDelete ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_DeleteForeverOutlined.default, {
48
49
  sx: {
49
50
  color: "#B64545!important",
50
51
  fontSize: "14px!important",
51
52
  cursor: "pointer"
52
53
  }
54
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_DeleteForeverOutlined.default, {
55
+ sx: {
56
+ display: "none"
57
+ }
53
58
  }),
54
59
  style: {
55
60
  height: "30px",
56
61
  borderRadius: "5px",
57
62
  background: "transparent",
58
- border: "1px solid ".concat(isHovered ? "#B64545" : "#F0F0F0"),
59
- color: "".concat(isHovered ? "#B64545" : "#707070")
63
+ border: "1px solid ".concat(showDelete && isHovered ? "#B64545" : "#F0F0F0"),
64
+ color: "".concat(showDelete && isHovered ? "#B64545" : "#707070")
60
65
  }
61
66
  }, key);
62
67
  };
@@ -450,30 +450,53 @@ var Phase = function Phase(_ref) {
450
450
  }; //eliminar chip
451
451
 
452
452
 
453
- var handleChipDelete = function handleChipDelete(phaseId, chipToRemove) {
454
- setGroupsSelected(function (prevGroups) {
455
- return prevGroups.filter(function (chip) {
456
- return chip.id !== chipToRemove.id;
457
- });
458
- });
459
- setChips(function (prevChips) {
460
- return prevChips.filter(function (chip) {
461
- return chip.id !== chipToRemove.id;
462
- });
463
- });
464
- deleteGroup(phaseId, chipToRemove.id);
465
- }; //eliminar grupo de fase
453
+ var handleChipDelete = /*#__PURE__*/function () {
454
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(phaseId, chipToRemove) {
455
+ return _regenerator.default.wrap(function _callee6$(_context7) {
456
+ while (1) {
457
+ switch (_context7.prev = _context7.next) {
458
+ case 0:
459
+ setGroupsSelected(function (prevGroups) {
460
+ return prevGroups.filter(function (chip) {
461
+ return chip.id !== chipToRemove.id;
462
+ });
463
+ });
464
+ setChips(function (prevChips) {
465
+ return prevChips.filter(function (chip) {
466
+ return chip.id !== chipToRemove.id;
467
+ });
468
+ });
469
+ setTempChips(function (prevChips) {
470
+ return prevChips.filter(function (chip) {
471
+ return chip.id !== chipToRemove.id;
472
+ });
473
+ });
474
+ _context7.next = 5;
475
+ return deleteGroup(phaseId, chipToRemove.id);
476
+
477
+ case 5:
478
+ case "end":
479
+ return _context7.stop();
480
+ }
481
+ }
482
+ }, _callee6);
483
+ }));
484
+
485
+ return function handleChipDelete(_x6, _x7) {
486
+ return _ref7.apply(this, arguments);
487
+ };
488
+ }(); //eliminar grupo de fase
466
489
 
467
490
 
468
491
  var deleteGroup = /*#__PURE__*/function () {
469
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(phaseId, groupId) {
492
+ var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(phaseId, groupId) {
470
493
  var response;
471
- return _regenerator.default.wrap(function _callee6$(_context7) {
494
+ return _regenerator.default.wrap(function _callee7$(_context8) {
472
495
  while (1) {
473
- switch (_context7.prev = _context7.next) {
496
+ switch (_context8.prev = _context8.next) {
474
497
  case 0:
475
- _context7.prev = 0;
476
- _context7.next = 3;
498
+ _context8.prev = 0;
499
+ _context8.next = 3;
477
500
  return _axios.default.post("".concat(process.env.REACT_APP_PHASES_ENDPOINT, "/delete"), {
478
501
  deleteGroupOfPhase: {
479
502
  phaseId: phaseId,
@@ -486,26 +509,32 @@ var Phase = function Phase(_ref) {
486
509
  });
487
510
 
488
511
  case 3:
489
- response = _context7.sent;
512
+ response = _context8.sent;
490
513
  console.log("grupo eliminado correctamente");
491
- _context7.next = 10;
514
+ loadData();
515
+ setTempChips(function (prevChips) {
516
+ return prevChips.filter(function (chip) {
517
+ return chip.id !== groupId;
518
+ });
519
+ });
520
+ _context8.next = 12;
492
521
  break;
493
522
 
494
- case 7:
495
- _context7.prev = 7;
496
- _context7.t0 = _context7["catch"](0);
497
- console.error("Error al eliminar grupo de fase:", _context7.t0);
523
+ case 9:
524
+ _context8.prev = 9;
525
+ _context8.t0 = _context8["catch"](0);
526
+ console.error("Error al eliminar grupo de fase:", _context8.t0);
498
527
 
499
- case 10:
528
+ case 12:
500
529
  case "end":
501
- return _context7.stop();
530
+ return _context8.stop();
502
531
  }
503
532
  }
504
- }, _callee6, null, [[0, 7]]);
533
+ }, _callee7, null, [[0, 9]]);
505
534
  }));
506
535
 
507
- return function deleteGroup(_x6, _x7) {
508
- return _ref7.apply(this, arguments);
536
+ return function deleteGroup(_x8, _x9) {
537
+ return _ref8.apply(this, arguments);
509
538
  };
510
539
  }();
511
540
 
@@ -612,7 +641,8 @@ var Phase = function Phase(_ref) {
612
641
  label: chip.label,
613
642
  onDelete: function onDelete() {
614
643
  return handleChipDelete(phaseId, chip);
615
- }
644
+ },
645
+ showDelete: showButtonChip
616
646
  }, chip.id);
617
647
  }), showButtonChip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_AddGroup.AddGroup, {
618
648
  id: "add-group-select-".concat(phaseId),
@@ -132,10 +132,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
132
132
  phaseId: phase.phaseId,
133
133
  nextPhaseIfApproved: phase.nextPhaseIfApproved
134
134
  };
135
- }),
136
- headers: {
137
- Authorization: token
138
- }
135
+ })
139
136
  };
140
137
  _context.next = 4;
141
138
  return _axios.default.post("".concat(process.env.REACT_APP_PHASES_ENDPOINT, "/update"), updateData, {
@@ -147,20 +144,21 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
147
144
  case 4:
148
145
  response = _context.sent;
149
146
  console.log("Update response:", response.body.data);
150
- _context.next = 11;
147
+ loadData();
148
+ _context.next = 12;
151
149
  break;
152
150
 
153
- case 8:
154
- _context.prev = 8;
151
+ case 9:
152
+ _context.prev = 9;
155
153
  _context.t0 = _context["catch"](0);
156
154
  console.error("Error al actualizar fases", _context.t0);
157
155
 
158
- case 11:
156
+ case 12:
159
157
  case "end":
160
158
  return _context.stop();
161
159
  }
162
160
  }
163
- }, _callee, null, [[0, 8]]);
161
+ }, _callee, null, [[0, 9]]);
164
162
  }));
165
163
 
166
164
  return function updatePhases() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.116",
3
+ "version": "21.4.117",
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 = ({ key, label, onDelete }) => {
6
+ export const CustomChip = ({ key, label, onDelete, showDelete }) => {
7
7
  const [isHovered, setIsHovered] = useState(false);
8
8
 
9
9
  const handleMouseEnter = () => {
@@ -21,15 +21,13 @@ export const CustomChip = ({ key, label, onDelete }) => {
21
21
  onDelete={onDelete}
22
22
  onMouseEnter={handleMouseEnter}
23
23
  onMouseLeave={handleMouseLeave}
24
- deleteIcon={
25
- <DeleteIcon sx={{color:"#B64545!important",fontSize:"14px!important",cursor:"pointer",}}/>
26
- }
24
+ deleteIcon={showDelete ? <DeleteIcon sx={{color:"#B64545!important",fontSize:"14px!important",cursor:"pointer",}}/> : <DeleteIcon sx={{display:"none"}}/> }
27
25
  style={{
28
26
  height:"30px",
29
27
  borderRadius: "5px",
30
28
  background: "transparent",
31
- border: `1px solid ${isHovered ? "#B64545" : "#F0F0F0"}`,
32
- color: `${isHovered ? "#B64545" : "#707070"}`,
29
+ border: `1px solid ${showDelete && isHovered ? "#B64545" : "#F0F0F0"}`,
30
+ color: `${showDelete && isHovered ? "#B64545" : "#707070"}`,
33
31
  }}
34
32
  />
35
33
  );
@@ -214,14 +214,17 @@ export const Phase = ({
214
214
  };
215
215
 
216
216
  //eliminar chip
217
- const handleChipDelete = (phaseId, chipToRemove) => {
217
+ const handleChipDelete = async(phaseId, chipToRemove) => {
218
218
  setGroupsSelected((prevGroups) =>
219
219
  prevGroups.filter((chip) => chip.id !== chipToRemove.id)
220
220
  );
221
221
  setChips((prevChips) =>
222
222
  prevChips.filter((chip) => chip.id !== chipToRemove.id)
223
223
  );
224
- deleteGroup(phaseId, chipToRemove.id);
224
+ setTempChips((prevChips) =>
225
+ prevChips.filter((chip) => chip.id !== chipToRemove.id)
226
+ );
227
+ await deleteGroup(phaseId, chipToRemove.id);
225
228
  };
226
229
 
227
230
  //eliminar grupo de fase
@@ -242,6 +245,10 @@ export const Phase = ({
242
245
  }
243
246
  );
244
247
  console.log("grupo eliminado correctamente");
248
+ loadData();
249
+ setTempChips((prevChips) =>
250
+ prevChips.filter((chip) => chip.id !== groupId)
251
+ );
245
252
  } catch (error) {
246
253
  console.error("Error al eliminar grupo de fase:", error);
247
254
  }
@@ -355,6 +362,7 @@ export const Phase = ({
355
362
  key={chip.id}
356
363
  label={chip.label}
357
364
  onDelete={() => handleChipDelete(phaseId, chip)}
365
+ showDelete={showButtonChip}
358
366
  />
359
367
  ))}
360
368
  {showButtonChip && <AddGroup
@@ -68,10 +68,7 @@ export const DragAndDropPhases = ({ token }) => {
68
68
  isInitialPhase: phase.isInitialPhase,
69
69
  phaseId: phase.phaseId,
70
70
  nextPhaseIfApproved: phase.nextPhaseIfApproved,
71
- })),
72
- headers: {
73
- Authorization: token,
74
- },
71
+ }))
75
72
  };
76
73
 
77
74
  const response = await axios.post(
@@ -84,6 +81,7 @@ export const DragAndDropPhases = ({ token }) => {
84
81
  }
85
82
  );
86
83
  console.log("Update response:", response.body.data);
84
+ loadData();
87
85
  } catch (error) {
88
86
  console.error("Error al actualizar fases", error);
89
87
  }