contentoh-components-library 21.4.115 → 21.4.116

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.
@@ -31,10 +31,6 @@ var _Modal = require("../Modal");
31
31
 
32
32
  var _axios = _interopRequireDefault(require("axios"));
33
33
 
34
- var _checkv = _interopRequireDefault(require("../../../assets/images/Icons/checkv2.svg"));
35
-
36
- var _material = require("@mui/material");
37
-
38
34
  var _jsxRuntime = require("react/jsx-runtime");
39
35
 
40
36
  var DragAndDropPhases = function DragAndDropPhases(_ref) {
@@ -55,38 +51,47 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
55
51
  tempListPhases = _useState6[0],
56
52
  setTempListPhases = _useState6[1];
57
53
 
58
- var _useState7 = (0, _react.useState)(""),
54
+ var _useState7 = (0, _react.useState)(),
59
55
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
60
- newPhaseName = _useState8[0],
61
- setNewPhaseName = _useState8[1];
56
+ search = _useState8[0],
57
+ setSearch = _useState8[1];
62
58
 
63
59
  var _useState9 = (0, _react.useState)(""),
64
60
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
65
- inputValue = _useState10[0],
66
- setInputValue = _useState10[1];
61
+ newPhaseName = _useState10[0],
62
+ setNewPhaseName = _useState10[1];
67
63
 
68
- var _useState11 = (0, _react.useState)({
64
+ var _useState11 = (0, _react.useState)(""),
65
+ _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
66
+ inputValue = _useState12[0],
67
+ setInputValue = _useState12[1];
68
+
69
+ var _useState13 = (0, _react.useState)({
69
70
  show: false,
70
71
  title: "Actualización completa",
71
72
  message: "",
72
73
  icon: "success"
73
74
  }),
74
- _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
75
- modalData = _useState12[0],
76
- setModalData = _useState12[1];
75
+ _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
76
+ modalData = _useState14[0],
77
+ setModalData = _useState14[1];
77
78
 
79
+ var newPhaseNameRef = (0, _react.useRef)("");
78
80
  (0, _react.useEffect)(function () {
79
81
  return loadData();
80
82
  }, []);
81
- var newPhaseNameRef = (0, _react.useRef)("");
82
- (0, _react.useEffect)(function () {
83
- newPhaseNameRef.current = newPhaseName;
84
- }, [newPhaseName]);
85
83
  (0, _react.useEffect)(function () {
86
84
  setNewPhaseName(function (prev) {
87
85
  return prev + inputValue;
88
86
  });
89
87
  }, [inputValue]);
88
+ (0, _react.useEffect)(function () {
89
+ newPhaseNameRef.current = search;
90
+ }, [newPhaseName]);
91
+
92
+ var handleInputChange = function handleInputChange(e) {
93
+ setInputValue(e.target.value);
94
+ };
90
95
 
91
96
  var onDragStart = function onDragStart(e, id) {
92
97
  e.dataTransfer.effectAllowed = "move";
@@ -119,7 +124,6 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
119
124
  switch (_context.prev = _context.next) {
120
125
  case 0:
121
126
  _context.prev = 0;
122
- console.log("listPhases:", listPhases);
123
127
  updateData = {
124
128
  updateReferencesOfNodes: listPhases.map(function (phase) {
125
129
  return {
@@ -133,31 +137,30 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
133
137
  Authorization: token
134
138
  }
135
139
  };
136
- console.log("updateData:", updateData);
137
- _context.next = 6;
140
+ _context.next = 4;
138
141
  return _axios.default.post("".concat(process.env.REACT_APP_PHASES_ENDPOINT, "/update"), updateData, {
139
142
  headers: {
140
143
  Authorization: token
141
144
  }
142
145
  });
143
146
 
144
- case 6:
147
+ case 4:
145
148
  response = _context.sent;
146
- console.log("Update response:", response.data);
147
- _context.next = 13;
149
+ console.log("Update response:", response.body.data);
150
+ _context.next = 11;
148
151
  break;
149
152
 
150
- case 10:
151
- _context.prev = 10;
153
+ case 8:
154
+ _context.prev = 8;
152
155
  _context.t0 = _context["catch"](0);
153
156
  console.error("Error al actualizar fases", _context.t0);
154
157
 
155
- case 13:
158
+ case 11:
156
159
  case "end":
157
160
  return _context.stop();
158
161
  }
159
162
  }
160
- }, _callee, null, [[0, 10]]);
163
+ }, _callee, null, [[0, 8]]);
161
164
  }));
162
165
 
163
166
  return function updatePhases() {
@@ -165,12 +168,8 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
165
168
  };
166
169
  }();
167
170
 
168
- var handleInputChange = function handleInputChange(e) {
169
- setInputValue(e.target.value);
170
- };
171
-
172
171
  var addPhase = /*#__PURE__*/function () {
173
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(phaseName) {
172
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(search) {
174
173
  var body, response, createdPhase;
175
174
  return _regenerator.default.wrap(function _callee2$(_context2) {
176
175
  while (1) {
@@ -178,7 +177,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
178
177
  case 0:
179
178
  _context2.prev = 0;
180
179
  body = {
181
- name: phaseName,
180
+ name: search,
182
181
  retailerGroupsIds: [],
183
182
  nextPhaseId: null
184
183
  };
@@ -193,22 +192,23 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
193
192
  response = _context2.sent;
194
193
  createdPhase = response.data.body;
195
194
  console.log(createdPhase);
195
+ setSearch();
196
196
  setInputValue("");
197
197
  loadData();
198
- _context2.next = 14;
198
+ _context2.next = 15;
199
199
  break;
200
200
 
201
- case 11:
202
- _context2.prev = 11;
201
+ case 12:
202
+ _context2.prev = 12;
203
203
  _context2.t0 = _context2["catch"](0);
204
204
  console.error("Error al agregar fase:", _context2.t0);
205
205
 
206
- case 14:
206
+ case 15:
207
207
  case "end":
208
208
  return _context2.stop();
209
209
  }
210
210
  }
211
- }, _callee2, null, [[0, 11]]);
211
+ }, _callee2, null, [[0, 12]]);
212
212
  }));
213
213
 
214
214
  return function addPhase(_x) {
@@ -224,9 +224,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
224
224
  switch (_context3.prev = _context3.next) {
225
225
  case 0:
226
226
  _context3.prev = 0;
227
- console.log("Lista de fases actualizada", phases);
228
- console.log("fase a eliminar", id);
229
- _context3.next = 5;
227
+ _context3.next = 3;
230
228
  return _axios.default.post("".concat(process.env.REACT_APP_PHASES_ENDPOINT, "/delete"), {
231
229
  updateReferencesOfNodes: phases,
232
230
  deletePhase: id
@@ -236,23 +234,23 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
236
234
  }
237
235
  });
238
236
 
239
- case 5:
237
+ case 3:
240
238
  response = _context3.sent;
241
239
  loadData();
242
- _context3.next = 12;
240
+ _context3.next = 10;
243
241
  break;
244
242
 
245
- case 9:
246
- _context3.prev = 9;
243
+ case 7:
244
+ _context3.prev = 7;
247
245
  _context3.t0 = _context3["catch"](0);
248
246
  console.error("Error al eliminar fase:", _context3.t0);
249
247
 
250
- case 12:
248
+ case 10:
251
249
  case "end":
252
250
  return _context3.stop();
253
251
  }
254
252
  }
255
- }, _callee3, null, [[0, 9]]);
253
+ }, _callee3, null, [[0, 7]]);
256
254
  }));
257
255
 
258
256
  return function deletePhase(_x2, _x3) {
@@ -286,7 +284,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
286
284
  show: false
287
285
  });
288
286
  });
289
- handleSavePhase();
287
+ handleSavePhase(search);
290
288
  }
291
289
  }, "btn-Guardar")],
292
290
  customComponent: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -294,12 +292,14 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
294
292
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("p", {
295
293
  children: ["Las fases nuevas siempre se agregan al final.", /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), "Puedes ordenar las fases arrastr\xE1ndolas."]
296
294
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
295
+ type: "text",
297
296
  className: "input-phases",
298
- placeholder: "Nombre de fase",
299
- value: inputValue,
300
297
  onChange: function onChange(e) {
301
- return handleInputChange(e);
302
- }
298
+ setSearch(e.target.value);
299
+ handleInputChange(e);
300
+ },
301
+ value: search,
302
+ placeholder: "Nombre de fase"
303
303
  })]
304
304
  })
305
305
  });
@@ -321,8 +321,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
321
321
  _context4.next = 3;
322
322
  return _axios.default.post("".concat(process.env.REACT_APP_PHASES_ENDPOINT, "/get"), {}, {
323
323
  headers: {
324
- Authorization: token // Authorization: sessionStorage.getItem("jwt"),
325
-
324
+ Authorization: token
326
325
  }
327
326
  });
328
327
 
@@ -354,23 +353,22 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
354
353
  groupsAssigned: groupsAssigned
355
354
  });
356
355
  });
357
- console.table("fases Array", phasesDataArray);
358
356
  setListPhases(phasesDataArray);
359
357
  setTempListPhases(phasesDataArray);
360
- _context4.next = 15;
358
+ _context4.next = 14;
361
359
  break;
362
360
 
363
- case 12:
364
- _context4.prev = 12;
361
+ case 11:
362
+ _context4.prev = 11;
365
363
  _context4.t0 = _context4["catch"](0);
366
364
  console.error("Error al obtener fases:", _context4.t0);
367
365
 
368
- case 15:
366
+ case 14:
369
367
  case "end":
370
368
  return _context4.stop();
371
369
  }
372
370
  }
373
- }, _callee4, null, [[0, 12]]);
371
+ }, _callee4, null, [[0, 11]]);
374
372
  }));
375
373
 
376
374
  return function loadData() {
@@ -403,11 +401,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
403
401
  }, "btn-Aceptar")]
404
402
  });
405
403
  deletePhase(id, filteredPhases);
406
- }; // useEffect(() => {
407
- // updatePhases();
408
- // setModalData((prev) => ({ ...prev, show: false }));
409
- // }, [listPhases]);
410
-
404
+ };
411
405
 
412
406
  var renderPhase = function renderPhase(phase, idx) {
413
407
  if (phase.isInitialPhase === 1) {
@@ -476,6 +470,7 @@ var DragAndDropPhases = function DragAndDropPhases(_ref) {
476
470
  }
477
471
  }, "btn-Aceptar")]
478
472
  });
473
+ loadData();
479
474
  }
480
475
  }, "btn-Guardar")]
481
476
  }), listPhases.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.115",
3
+ "version": "21.4.116",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -1,6 +1,6 @@
1
1
  import { Container } from "./styles";
2
2
 
3
- export const TabSection = ({ label, active, onClick }) => {
3
+ export const TabSection = ({ label, active, onClick}) => {
4
4
  return (
5
5
  <Container className={active && "active"} onClick={onClick}>
6
6
  <p>{label}</p>
@@ -0,0 +1,15 @@
1
+ import { AddGroup } from "./index";
2
+
3
+
4
+ export default {
5
+ title: "Components/molecules/AddGroup",
6
+ component: AddGroup,
7
+ };
8
+
9
+ const Template = (args) => <AddGroup {...args}/>;
10
+
11
+ export const AddGroupDefault = Template.bind({});
12
+
13
+ AddGroupDefault.args = {
14
+ image: bags,
15
+ };
@@ -0,0 +1,84 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import { Container } from "./styles.js";
3
+ import searchIcon from "../../../assets/images/Icons/search.svg";
4
+ import add from "../../../assets/images/Icons/addv2.svg";
5
+
6
+ export const AddGroup = ({
7
+ id,
8
+ items = [],
9
+ value = [],
10
+ defaultSearch = "",
11
+ defaultOption = "",
12
+ onChange,
13
+ placeholder = "",
14
+ }) => {
15
+ const [itemsSelected, setItemsSelected] = useState(value);
16
+ const [search, setSearch] = useState(defaultSearch);
17
+ const [containerVisible, setContainerVisible] = useState(false);
18
+ const itemsFiltered = (() => {
19
+ if (!search) return items;
20
+
21
+ return items.filter((item) =>
22
+ item.label.toLowerCase().includes(search.toLowerCase())
23
+ );
24
+ })();
25
+
26
+ useEffect(() => {
27
+ onChange && onChange(itemsSelected);
28
+ }, [itemsSelected]);
29
+
30
+ return (
31
+ <Container id={id}>
32
+ <button
33
+ className="custom-select"
34
+ onClick={() => setContainerVisible(!containerVisible)}
35
+ >
36
+ <img src={add} className="add-icon" alt="add icon" />
37
+ </button>
38
+ {containerVisible && (
39
+ <div className="container-def">
40
+ <div className="search-bar">
41
+ <img src={searchIcon} className="search-icon" alt="search icon" />
42
+ <input
43
+ type="text"
44
+ className="search"
45
+ onChange={(e) => {
46
+ setSearch(e.target.value);
47
+ }}
48
+ value={search}
49
+ placeholder={placeholder}
50
+ ></input>
51
+ </div>
52
+ <p className="default-option">{defaultOption}</p>
53
+ {itemsFiltered.map((item, i) => {
54
+ return (
55
+ <div className="container-options">
56
+ <div key={i} className="options">
57
+ <input
58
+ id="custom-check"
59
+ className="custom-check"
60
+ type="checkbox"
61
+ checked={itemsSelected.includes(item.value)}
62
+ onChange={(e) => {
63
+ setItemsSelected((prev) => {
64
+ const existItem = prev.find((e) => e === item.value);
65
+
66
+ if (existItem) {
67
+ return [...prev].filter((e) => e !== item.value);
68
+ }
69
+
70
+ return [...prev, item.value];
71
+ });
72
+ }}
73
+ />
74
+ <label htmlFor="" className="texto">
75
+ {item.label}
76
+ </label>
77
+ </div>
78
+ </div>
79
+ );
80
+ })}
81
+ </div>)}
82
+ </Container>
83
+ );
84
+ };
@@ -0,0 +1,141 @@
1
+ import styled from "styled-components";
2
+ import checked from "../../../assets/images/checkBox/checkverde.svg";
3
+
4
+ export const Container = styled.div`
5
+ .container-def {
6
+ margin-top: 10px;
7
+ box-shadow: 0px 2px 4px #00000040;
8
+ border-radius: 5px;
9
+ background-color: #fff;
10
+ padding-bottom: 10px;
11
+ position: absolute;
12
+ z-index: 10;
13
+ max-height: 500px;
14
+ overflow: auto;
15
+ }
16
+
17
+ .custom-select {
18
+ ont-family: RobotoRegular,sans-serif;
19
+ font-size: 12px;
20
+ display: -webkit-box;
21
+ display: -webkit-flex;
22
+ display: -ms-flexbox;
23
+ display: flex;
24
+ width: 30px;
25
+ height: 30px;
26
+ padding: 7px 7px;
27
+ -webkit-box-pack: justify;
28
+ -webkit-justify-content: space-between;
29
+ -ms-flex-pack: justify;
30
+ justify-content: space-between;
31
+ border-radius: 50px;
32
+ background-color: #fff;
33
+ border: 1px solid #E33AA9;
34
+ cursor: pointer;
35
+ }
36
+
37
+ .search-bar{
38
+ display: flex;
39
+ align-items: center;
40
+ padding: 0px 5px;
41
+ border-bottom: 1px solid #f0f0f0;
42
+ }
43
+
44
+ .search {
45
+ border: none;
46
+ height: 34px;
47
+ padding: 5px 10px;
48
+ color: #707070;
49
+ }
50
+ .search::placeholder {
51
+ display: inline;
52
+ color: #707070;
53
+ font-family: Avenir Next;
54
+ font-weight: 500;
55
+ font-size: 13px;
56
+ line-height: 15px;
57
+ }
58
+
59
+ .container-options {
60
+ padding: 5px;
61
+ }
62
+
63
+ .default-option {
64
+ cursor: pointer;
65
+ padding: 10px 10px 5px;
66
+ color: #817393;
67
+ font-family: Avenir Next;
68
+ font-weight: 500;
69
+ font-size: 13px;
70
+ line-height: 15px;
71
+ }
72
+
73
+ .options {
74
+ height: 24px;
75
+ gap: 10px;
76
+ display: flex;
77
+ align-items: center;
78
+ }
79
+
80
+ .custom-check {
81
+ border: 3px solid red;
82
+ background-color: #D9D9D9;
83
+ background-size: 100% 100%;
84
+ background-position: center;
85
+ background-repeat: no-repeat;
86
+ width: 300px;
87
+ height: 300px;
88
+ appearance: none;
89
+ display: inline-block;
90
+ vertical-align: middle;
91
+ background-origin: border-box;
92
+ padding: 0;
93
+ user-select: none;
94
+ flex-shrink: 0;
95
+ border-radius: 3px;
96
+ }
97
+
98
+ .custom-check {
99
+ cursor: pointer;
100
+ background-color: #D9D9D9;
101
+ width: 16px;
102
+ height: 16px;
103
+ appearance: none;
104
+ border: 1px solid #cbcbcb;
105
+ transition: background-color 0.3s ease-in-out;
106
+ }
107
+
108
+ .custom-check:checked {
109
+ background-color: #FFFFFF;
110
+ border: none;
111
+ background-image: url(${checked});
112
+ }
113
+
114
+ .custom-check:focus {
115
+ border-color: rgb(198, 198, 198);
116
+ }
117
+
118
+ .custom-check:disabled {
119
+ background-color: rgb(198, 198, 198);
120
+ background-image: none;
121
+ }
122
+
123
+ .custom-check:disabled:checked {
124
+ background-color: rgb(198, 198, 198);
125
+ background-image: url(${checked});
126
+ }
127
+
128
+ .texto {
129
+ display: inline;
130
+ color: #817393;
131
+ font-family: Avenir Next;
132
+ font-weight: 500;
133
+ font-size: 13px;
134
+ line-height: 15px;
135
+ }
136
+
137
+ .add-icon{
138
+ width:13px;
139
+ height: 13px;
140
+ }
141
+ `;