contentoh-components-library 21.4.100 → 21.4.101

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.
@@ -58,7 +58,11 @@ var Phase = function Phase(_ref) {
58
58
  nextPhase = _ref.nextPhase,
59
59
  groups = _ref.groups,
60
60
  onDeletePhase = _ref.onDeletePhase,
61
- token = _ref.token;
61
+ token = _ref.token,
62
+ _ref$showMenu = _ref.showMenu,
63
+ showMenu = _ref$showMenu === void 0 ? true : _ref$showMenu,
64
+ _ref$showButtonChip = _ref.showButtonChip,
65
+ showButtonChip = _ref$showButtonChip === void 0 ? true : _ref$showButtonChip;
62
66
 
63
67
  var _useState = (0, _react.useState)([]),
64
68
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -501,43 +505,45 @@ var Phase = function Phase(_ref) {
501
505
  children: phase.phaseName
502
506
  }, phase.phaseId);
503
507
  })
504
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
505
- id: "basic-button",
506
- "aria-controls": open ? "basic-menu" : undefined,
507
- "aria-haspopup": "true",
508
- "aria-expanded": open ? "true" : undefined,
509
- onClick: function onClick(e) {
510
- return handleClick(e);
511
- },
512
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
513
- src: _options.default,
514
- alt: ""
515
- })
516
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Menu, {
517
- id: "basic-menu",
518
- anchorEl: anchorEl,
519
- open: open,
520
- onClose: handleClose,
521
- MenuListProps: {
522
- "aria-labelledby": "basic-button"
523
- },
524
- sx: {
525
- ul: {
526
- paddingTop: "0px",
527
- paddingBottom: "0px"
528
- }
529
- },
530
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
531
- onClick: function onClick() {
532
- return onDeletePhase(id);
508
+ }), showMenu && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
509
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
510
+ id: "basic-button",
511
+ "aria-controls": open ? "basic-menu" : undefined,
512
+ "aria-haspopup": "true",
513
+ "aria-expanded": open ? "true" : undefined,
514
+ onClick: function onClick(e) {
515
+ return handleClick(e);
516
+ },
517
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
518
+ src: _options.default,
519
+ alt: ""
520
+ })
521
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Menu, {
522
+ id: "basic-menu",
523
+ anchorEl: anchorEl,
524
+ open: open,
525
+ onClose: handleClose,
526
+ MenuListProps: {
527
+ "aria-labelledby": "basic-button"
533
528
  },
534
529
  sx: {
535
- fontSize: "12px",
536
- color: "#262626",
537
- minHeight: "auto"
530
+ ul: {
531
+ paddingTop: "0px",
532
+ paddingBottom: "0px"
533
+ }
538
534
  },
539
- children: "Eliminar Fase"
540
- })
535
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
536
+ onClick: function onClick() {
537
+ return onDeletePhase(id);
538
+ },
539
+ sx: {
540
+ fontSize: "12px",
541
+ color: "#262626",
542
+ minHeight: "auto"
543
+ },
544
+ children: "Eliminar Fase"
545
+ })
546
+ })]
541
547
  })]
542
548
  })
543
549
  })]
@@ -550,7 +556,7 @@ var Phase = function Phase(_ref) {
550
556
  return handleChipDelete(phaseId, chip);
551
557
  }
552
558
  }, chip.id);
553
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupSelect.GroupSelect, {
559
+ }), showButtonChip && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupSelect.GroupSelect, {
554
560
  options: groups.filter(function (group) {
555
561
  return group.groupActive === 0;
556
562
  }).map(function (group) {
@@ -176,41 +176,39 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
176
176
  while (1) {
177
177
  switch (_context2.prev = _context2.next) {
178
178
  case 0:
179
- console.log("fase nueva", phaseName);
180
- _context2.prev = 1;
179
+ _context2.prev = 0;
181
180
  body = {
182
181
  name: phaseName,
183
182
  retailerGroupsIds: [],
184
183
  nextPhaseId: null
185
184
  };
186
- _context2.next = 5;
185
+ _context2.next = 4;
187
186
  return _axios.default.post("".concat(process.env.REACT_APP_PHASES_ENDPOINT, "/create"), body, {
188
187
  headers: {
189
188
  Authorization: token
190
189
  }
191
190
  });
192
191
 
193
- case 5:
192
+ case 4:
194
193
  response = _context2.sent;
195
- console.log("body", body);
196
194
  createdPhase = response.data.body;
197
195
  console.log(createdPhase);
198
196
  setInputValue("");
199
197
  loadData();
200
- _context2.next = 16;
198
+ _context2.next = 14;
201
199
  break;
202
200
 
203
- case 13:
204
- _context2.prev = 13;
205
- _context2.t0 = _context2["catch"](1);
201
+ case 11:
202
+ _context2.prev = 11;
203
+ _context2.t0 = _context2["catch"](0);
206
204
  console.error("Error al agregar fase:", _context2.t0);
207
205
 
208
- case 16:
206
+ case 14:
209
207
  case "end":
210
208
  return _context2.stop();
211
209
  }
212
210
  }
213
- }, _callee2, null, [[1, 13]]);
211
+ }, _callee2, null, [[0, 11]]);
214
212
  }));
215
213
 
216
214
  return function addPhase(_x) {
@@ -412,21 +410,38 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
412
410
 
413
411
 
414
412
  var renderPhase = function renderPhase(phase, idx) {
415
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Phase.Phase, {
416
- id: idx,
417
- phaseId: phase.phaseId,
418
- phases: listPhases,
419
- phaseName: phase.phaseName,
420
- nextPhase: phase.nextPhaseIfApproved,
421
- groups: phase.groupsAssigned,
422
- onDeletePhase: function onDeletePhase() {
423
- return handleDeletePhase(phase.phaseId);
424
- } // onDragStart={(e) => onDragStart(e, idx)}
425
- // onDragOver={() => onDragOver(idx)}
426
- // onDragEnd={onDragEnd}
427
- ,
428
- token: token
429
- }, phase.phaseId);
413
+ if (phase.isInitialPhase === 1) {
414
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Phase.Phase, {
415
+ id: idx,
416
+ phaseId: phase.phaseId,
417
+ phases: listPhases,
418
+ phaseName: phase.phaseName,
419
+ nextPhase: phase.nextPhaseIfApproved,
420
+ groups: phase.groupsAssigned,
421
+ onDeletePhase: function onDeletePhase() {
422
+ return handleDeletePhase(phase.phaseId);
423
+ },
424
+ token: token,
425
+ showMenu: false,
426
+ showButtonChip: false
427
+ }, phase.phaseId);
428
+ } else {
429
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Phase.Phase, {
430
+ id: idx,
431
+ phaseId: phase.phaseId,
432
+ phases: listPhases,
433
+ phaseName: phase.phaseName,
434
+ nextPhase: phase.nextPhaseIfApproved,
435
+ groups: phase.groupsAssigned,
436
+ onDeletePhase: function onDeletePhase() {
437
+ return handleDeletePhase(phase.phaseId);
438
+ } // onDragStart={(e) => onDragStart(e, idx)}
439
+ // onDragOver={() => onDragOver(idx)}
440
+ // onDragEnd={onDragEnd}
441
+ ,
442
+ token: token
443
+ }, phase.phaseId);
444
+ }
430
445
  };
431
446
 
432
447
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.100",
3
+ "version": "21.4.101",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -26,6 +26,8 @@ export const Phase = ({
26
26
  groups,
27
27
  onDeletePhase,
28
28
  token,
29
+ showMenu=true,
30
+ showButtonChip=true,
29
31
  }) => {
30
32
  const [selectedValue, setSelectedValue] = useState([]);
31
33
  const [chips, setChips] = useState([]);
@@ -276,20 +278,20 @@ export const Phase = ({
276
278
  <div className="phase-sel">
277
279
  <p className="text-phase">Siguiente Fase </p>
278
280
  <Select
279
- value={
280
- selectedValue.length > 0
281
- ? selectedValue[0]
282
- : nextPhaseState
283
- ? nextPhaseState
284
- : ""
285
- }
286
- placeholder={`Fase`}
287
- onChange={(e) => {
288
- const selectedPhase = phases.find(
289
- (phase) => phase.phaseName === e.target.value
290
- );
291
- setSelectedValue(selectedPhase ? [selectedPhase.phaseId] : []);
292
- }}
281
+ value={
282
+ selectedValue.length > 0
283
+ ? selectedValue[0]
284
+ : nextPhaseState
285
+ ? nextPhaseState
286
+ : ""
287
+ }
288
+ placeholder={`Fase`}
289
+ onChange={(e) => {
290
+ const selectedPhase = phases.find(
291
+ (phase) => phase.phaseName === e.target.value
292
+ );
293
+ setSelectedValue(selectedPhase ? [selectedPhase.phaseId] : []);
294
+ }}
293
295
  sx={{
294
296
  minWidth: "100px",
295
297
  height: "24px",
@@ -319,37 +321,45 @@ export const Phase = ({
319
321
  </MenuItem>
320
322
  ))}
321
323
  </Select>
322
- <Button
323
- id="basic-button"
324
- aria-controls={open ? "basic-menu" : undefined}
325
- aria-haspopup="true"
326
- aria-expanded={open ? "true" : undefined}
327
- onClick={(e) => handleClick(e)}
328
- >
329
- <img src={options} alt="" />
330
- </Button>
331
- <Menu
332
- id="basic-menu"
333
- anchorEl={anchorEl}
334
- open={open}
335
- onClose={handleClose}
336
- MenuListProps={{
337
- "aria-labelledby": "basic-button",
338
- }}
339
- sx={{
340
- ul: {
341
- paddingTop: "0px",
342
- paddingBottom: "0px",
343
- },
344
- }}
345
- >
346
- <MenuItem
347
- onClick={() => onDeletePhase(id)}
348
- sx={{ fontSize: "12px", color: "#262626", minHeight: "auto" }}
349
- >
350
- Eliminar Fase
351
- </MenuItem>
352
- </Menu>
324
+ {showMenu && (
325
+ <>
326
+ <Button
327
+ id="basic-button"
328
+ aria-controls={open ? "basic-menu" : undefined}
329
+ aria-haspopup="true"
330
+ aria-expanded={open ? "true" : undefined}
331
+ onClick={(e) => handleClick(e)}
332
+ >
333
+ <img src={options} alt="" />
334
+ </Button>
335
+ <Menu
336
+ id="basic-menu"
337
+ anchorEl={anchorEl}
338
+ open={open}
339
+ onClose={handleClose}
340
+ MenuListProps={{
341
+ "aria-labelledby": "basic-button",
342
+ }}
343
+ sx={{
344
+ ul: {
345
+ paddingTop: "0px",
346
+ paddingBottom: "0px",
347
+ },
348
+ }}
349
+ >
350
+ <MenuItem
351
+ onClick={() => onDeletePhase(id)}
352
+ sx={{
353
+ fontSize: "12px",
354
+ color: "#262626",
355
+ minHeight: "auto",
356
+ }}
357
+ >
358
+ Eliminar Fase
359
+ </MenuItem>
360
+ </Menu>
361
+ </>
362
+ )}
353
363
  </div>
354
364
  </div>
355
365
  </div>
@@ -361,8 +371,8 @@ export const Phase = ({
361
371
  onDelete={() => handleChipDelete(phaseId, chip)}
362
372
  />
363
373
  ))}
364
-
365
- <GroupSelect
374
+
375
+ {showButtonChip && <GroupSelect
366
376
  options={groups
367
377
  .filter((group) => group.groupActive === 0)
368
378
  .map((group) => ({
@@ -377,9 +387,10 @@ export const Phase = ({
377
387
  defaultOption={"Todos los grupos"}
378
388
  parameterArray={groupsSelected}
379
389
  setParameterArray={setGroupsSelected}
380
- onClickItem={()=>{
381
- handleGroupSelect()}}
382
- />
390
+ onClickItem={() => {
391
+ handleGroupSelect();
392
+ }}
393
+ />}
383
394
  </div>
384
395
  <Modal
385
396
  {...modalData}
@@ -93,7 +93,6 @@ export const DragAndDropPhases = ({ token}) => {
93
93
  };
94
94
 
95
95
  const addPhase = async(phaseName) => {
96
- console.log("fase nueva", phaseName);
97
96
  try {
98
97
  const body = {
99
98
  name: phaseName,
@@ -109,7 +108,6 @@ export const DragAndDropPhases = ({ token}) => {
109
108
  },
110
109
  }
111
110
  );
112
- console.log("body", body)
113
111
  const createdPhase = response.data.body;
114
112
  console.log(createdPhase)
115
113
  setInputValue("");
@@ -258,22 +256,41 @@ const handleDeletePhase = (id) => {
258
256
  // }, [listPhases]);
259
257
 
260
258
  const renderPhase = (phase, idx) => {
261
- return (
262
- <Phase
263
- key={phase.phaseId}
264
- id={idx}
265
- phaseId={phase.phaseId}
266
- phases={listPhases}
267
- phaseName={phase.phaseName}
268
- nextPhase={phase.nextPhaseIfApproved}
269
- groups={phase.groupsAssigned}
270
- onDeletePhase={() => handleDeletePhase(phase.phaseId)}
271
- // onDragStart={(e) => onDragStart(e, idx)}
272
- // onDragOver={() => onDragOver(idx)}
273
- // onDragEnd={onDragEnd}
274
- token={token}
275
- />
276
- );
259
+ if (phase.isInitialPhase===1){
260
+ return (
261
+ <Phase
262
+ key={phase.phaseId}
263
+ id={idx}
264
+ phaseId={phase.phaseId}
265
+ phases={listPhases}
266
+ phaseName={phase.phaseName}
267
+ nextPhase={phase.nextPhaseIfApproved}
268
+ groups={phase.groupsAssigned}
269
+ onDeletePhase={() => handleDeletePhase(phase.phaseId)}
270
+ token={token}
271
+ showMenu={false}
272
+ showButtonChip={false}
273
+ />
274
+ );
275
+ }else{
276
+ return (
277
+ <Phase
278
+ key={phase.phaseId}
279
+ id={idx}
280
+ phaseId={phase.phaseId}
281
+ phases={listPhases}
282
+ phaseName={phase.phaseName}
283
+ nextPhase={phase.nextPhaseIfApproved}
284
+ groups={phase.groupsAssigned}
285
+ onDeletePhase={() => handleDeletePhase(phase.phaseId)}
286
+ // onDragStart={(e) => onDragStart(e, idx)}
287
+ // onDragOver={() => onDragOver(idx)}
288
+ // onDragEnd={onDragEnd}
289
+ token={token}
290
+ />
291
+ );
292
+ }
293
+
277
294
  };
278
295
 
279
296