contentoh-components-library 21.4.118 → 21.4.119

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.
@@ -34,17 +34,13 @@ MultiselectDefault.args = {
34
34
  "userName": "Flujo Dos",
35
35
  "userEmail": "cadenaradioshackflujouno@allfreemail.net",
36
36
  "groups": [{
37
- "groupId": "Sin id",
38
- "groupName": "No tiene grupo asignado",
39
- "userContentGroup": 0
40
- }, {
41
37
  "groupId": 60,
42
38
  "groupName": "Compras",
43
39
  "userContentGroup": 1
44
40
  }, {
45
41
  "groupId": 65,
46
42
  "groupName": "Jefe Comercial",
47
- "userContentGroup": 1
43
+ "userContentGroup": 0
48
44
  }, {
49
45
  "groupId": 66,
50
46
  "groupName": "Planogramas",
@@ -215,6 +211,93 @@ MultiselectDefault.args = {
215
211
  "groupName": "Datos Maestros",
216
212
  "userContentGroup": 0
217
213
  }]
214
+ }, {
215
+ "idUser": 390,
216
+ "userName": "Impuestos",
217
+ "userEmail": "impuestos@allfreemail.net",
218
+ "groups": [{
219
+ "groupId": 67,
220
+ "groupName": "Impuestos",
221
+ "userContentGroup": 1
222
+ }, {
223
+ "groupId": 60,
224
+ "groupName": "Compras",
225
+ "userContentGroup": 0
226
+ }, {
227
+ "groupId": 65,
228
+ "groupName": "Jefe Comercial",
229
+ "userContentGroup": 0
230
+ }, {
231
+ "groupId": 66,
232
+ "groupName": "Planogramas",
233
+ "userContentGroup": 0
234
+ }, {
235
+ "groupId": 68,
236
+ "groupName": "eCommerce",
237
+ "userContentGroup": 0
238
+ }, {
239
+ "groupId": 69,
240
+ "groupName": "Datos Maestros",
241
+ "userContentGroup": 0
242
+ }]
243
+ }, {
244
+ "idUser": 391,
245
+ "userName": "Ecommerce",
246
+ "userEmail": "ecommerce@allfreemail.net",
247
+ "groups": [{
248
+ "groupId": 68,
249
+ "groupName": "eCommerce",
250
+ "userContentGroup": 1
251
+ }, {
252
+ "groupId": 60,
253
+ "groupName": "Compras",
254
+ "userContentGroup": 0
255
+ }, {
256
+ "groupId": 65,
257
+ "groupName": "Jefe Comercial",
258
+ "userContentGroup": 0
259
+ }, {
260
+ "groupId": 66,
261
+ "groupName": "Planogramas",
262
+ "userContentGroup": 0
263
+ }, {
264
+ "groupId": 67,
265
+ "groupName": "Impuestos",
266
+ "userContentGroup": 0
267
+ }, {
268
+ "groupId": 69,
269
+ "groupName": "Datos Maestros",
270
+ "userContentGroup": 0
271
+ }]
272
+ }, {
273
+ "idUser": 392,
274
+ "userName": "Datos",
275
+ "userEmail": "datosmaestros@allfreemail.net",
276
+ "groups": [{
277
+ "groupId": 69,
278
+ "groupName": "Datos Maestros",
279
+ "userContentGroup": 1
280
+ }, {
281
+ "groupId": 60,
282
+ "groupName": "Compras",
283
+ "userContentGroup": 0
284
+ }, {
285
+ "groupId": 65,
286
+ "groupName": "Jefe Comercial",
287
+ "userContentGroup": 0
288
+ }, {
289
+ "groupId": 66,
290
+ "groupName": "Planogramas",
291
+ "userContentGroup": 0
292
+ }, {
293
+ "groupId": 67,
294
+ "groupName": "Impuestos",
295
+ "userContentGroup": 0
296
+ }, {
297
+ "groupId": 68,
298
+ "groupName": "eCommerce",
299
+ "userContentGroup": 0
300
+ }]
218
301
  }],
219
302
  userId: 380
220
303
  };
@@ -180,7 +180,14 @@ var Multiselect = function Multiselect(_ref) {
180
180
  }).map(function (group) {
181
181
  return group.groupId;
182
182
  });
183
- updateGroup(groupIds);
183
+
184
+ if (groupIds.length > 0) {
185
+ // Llamada a la función de actualización si hay grupos seleccionados
186
+ updateGroup(groupIds);
187
+ } else {
188
+ // Llamada a la función de eliminación si no hay grupos seleccionados
189
+ deleteGroup([userId]);
190
+ }
184
191
  };
185
192
  }; //actualiza los grupos seleccionados
186
193
 
@@ -243,6 +250,52 @@ var Multiselect = function Multiselect(_ref) {
243
250
  return function updateGroup(_x) {
244
251
  return _ref3.apply(this, arguments);
245
252
  };
253
+ }(); //Elimina todos los grupos de usuarios seleccionados
254
+
255
+
256
+ var deleteGroup = /*#__PURE__*/function () {
257
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(userIds) {
258
+ var body, response;
259
+ return _regenerator.default.wrap(function _callee2$(_context2) {
260
+ while (1) {
261
+ switch (_context2.prev = _context2.next) {
262
+ case 0:
263
+ _context2.prev = 0;
264
+ body = {
265
+ userIds: userIds,
266
+ groupsIds: []
267
+ };
268
+ _context2.next = 4;
269
+ return _axios.default.post("".concat(process.env.REACT_APP_USERS_ONBOARDING_ENDPOINT, "/delete"), body, {
270
+ headers: {
271
+ Authorization: sessionStorage.getItem("jwt")
272
+ }
273
+ });
274
+
275
+ case 4:
276
+ response = _context2.sent;
277
+ console.log("borrado correctamente", response.data.body);
278
+ loadUserGroups();
279
+ _context2.next = 13;
280
+ break;
281
+
282
+ case 9:
283
+ _context2.prev = 9;
284
+ _context2.t0 = _context2["catch"](0);
285
+ console.error("Error al cambiar grupos de usuarios:", _context2.t0);
286
+ setLoading(false);
287
+
288
+ case 13:
289
+ case "end":
290
+ return _context2.stop();
291
+ }
292
+ }
293
+ }, _callee2, null, [[0, 9]]);
294
+ }));
295
+
296
+ return function deleteGroup(_x2) {
297
+ return _ref4.apply(this, arguments);
298
+ };
246
299
  }();
247
300
 
248
301
  (0, _react.useEffect)(function () {}, [selectValues]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.118",
3
+ "version": "21.4.119",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -21,11 +21,6 @@ MultiselectDefault.args = {
21
21
  "userName": "Flujo Dos",
22
22
  "userEmail": "cadenaradioshackflujouno@allfreemail.net",
23
23
  "groups": [
24
- {
25
- "groupId": "Sin id",
26
- "groupName": "No tiene grupo asignado",
27
- "userContentGroup": 0
28
- },
29
24
  {
30
25
  "groupId": 60,
31
26
  "groupName": "Compras",
@@ -34,7 +29,7 @@ MultiselectDefault.args = {
34
29
  {
35
30
  "groupId": 65,
36
31
  "groupName": "Jefe Comercial",
37
- "userContentGroup": 1
32
+ "userContentGroup": 0
38
33
  },
39
34
  {
40
35
  "groupId": 66,
@@ -252,6 +247,117 @@ MultiselectDefault.args = {
252
247
  "userContentGroup": 0
253
248
  }
254
249
  ]
250
+ },
251
+ {
252
+ "idUser": 390,
253
+ "userName": "Impuestos",
254
+ "userEmail": "impuestos@allfreemail.net",
255
+ "groups": [
256
+ {
257
+ "groupId": 67,
258
+ "groupName": "Impuestos",
259
+ "userContentGroup": 1
260
+ },
261
+ {
262
+ "groupId": 60,
263
+ "groupName": "Compras",
264
+ "userContentGroup": 0
265
+ },
266
+ {
267
+ "groupId": 65,
268
+ "groupName": "Jefe Comercial",
269
+ "userContentGroup": 0
270
+ },
271
+ {
272
+ "groupId": 66,
273
+ "groupName": "Planogramas",
274
+ "userContentGroup": 0
275
+ },
276
+ {
277
+ "groupId": 68,
278
+ "groupName": "eCommerce",
279
+ "userContentGroup": 0
280
+ },
281
+ {
282
+ "groupId": 69,
283
+ "groupName": "Datos Maestros",
284
+ "userContentGroup": 0
285
+ }
286
+ ]
287
+ },
288
+ {
289
+ "idUser": 391,
290
+ "userName": "Ecommerce",
291
+ "userEmail": "ecommerce@allfreemail.net",
292
+ "groups": [
293
+ {
294
+ "groupId": 68,
295
+ "groupName": "eCommerce",
296
+ "userContentGroup": 1
297
+ },
298
+ {
299
+ "groupId": 60,
300
+ "groupName": "Compras",
301
+ "userContentGroup": 0
302
+ },
303
+ {
304
+ "groupId": 65,
305
+ "groupName": "Jefe Comercial",
306
+ "userContentGroup": 0
307
+ },
308
+ {
309
+ "groupId": 66,
310
+ "groupName": "Planogramas",
311
+ "userContentGroup": 0
312
+ },
313
+ {
314
+ "groupId": 67,
315
+ "groupName": "Impuestos",
316
+ "userContentGroup": 0
317
+ },
318
+ {
319
+ "groupId": 69,
320
+ "groupName": "Datos Maestros",
321
+ "userContentGroup": 0
322
+ }
323
+ ]
324
+ },
325
+ {
326
+ "idUser": 392,
327
+ "userName": "Datos",
328
+ "userEmail": "datosmaestros@allfreemail.net",
329
+ "groups": [
330
+ {
331
+ "groupId": 69,
332
+ "groupName": "Datos Maestros",
333
+ "userContentGroup": 1
334
+ },
335
+ {
336
+ "groupId": 60,
337
+ "groupName": "Compras",
338
+ "userContentGroup": 0
339
+ },
340
+ {
341
+ "groupId": 65,
342
+ "groupName": "Jefe Comercial",
343
+ "userContentGroup": 0
344
+ },
345
+ {
346
+ "groupId": 66,
347
+ "groupName": "Planogramas",
348
+ "userContentGroup": 0
349
+ },
350
+ {
351
+ "groupId": 67,
352
+ "groupName": "Impuestos",
353
+ "userContentGroup": 0
354
+ },
355
+ {
356
+ "groupId": 68,
357
+ "groupName": "eCommerce",
358
+ "userContentGroup": 0
359
+ }
360
+ ]
255
361
  }
256
362
  ],
257
363
  userId:380,
@@ -109,7 +109,13 @@ const loadUserGroups = (updatedValues) => {
109
109
  }));
110
110
 
111
111
  const groupIds = updatedValues.filter((group) => group.userContentGroup === 1).map((group) => group.groupId);
112
- updateGroup(groupIds);
112
+ if (groupIds.length > 0) {
113
+ // Llamada a la función de actualización si hay grupos seleccionados
114
+ updateGroup(groupIds);
115
+ } else {
116
+ // Llamada a la función de eliminación si no hay grupos seleccionados
117
+ deleteGroup([userId]);
118
+ }
113
119
  };
114
120
 
115
121
 
@@ -155,6 +161,30 @@ const loadUserGroups = (updatedValues) => {
155
161
  }
156
162
  };
157
163
 
164
+ //Elimina todos los grupos de usuarios seleccionados
165
+ const deleteGroup = async (userIds) => {
166
+ try {
167
+ const body = {
168
+ userIds,
169
+ groupsIds: [],
170
+ };
171
+ const response = await axios.post(
172
+ `${process.env.REACT_APP_USERS_ONBOARDING_ENDPOINT}/delete`,
173
+ body,
174
+ {
175
+ headers: {
176
+ Authorization: sessionStorage.getItem("jwt"),
177
+ },
178
+ }
179
+ );
180
+ console.log("borrado correctamente", response.data.body);
181
+ loadUserGroups();
182
+ } catch (error) {
183
+ console.error("Error al cambiar grupos de usuarios:", error);
184
+ setLoading(false);
185
+ }
186
+ };
187
+
158
188
  useEffect(() => {}, [selectValues]);
159
189
 
160
190
  useEffect(() => {