@iotready/nextjs-components-library 1.0.0-preview18 → 1.0.0-preview19

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.
@@ -60,7 +60,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
60
60
  moreData = usersList.users.length === pageSize;
61
61
  page++;
62
62
  }
63
- const userGroupsUserIds = usersGroup.map((ug) => ug.user.userId);
63
+ const userGroupsUserIds = usersGroup && usersGroup.map((ug) => ug.user.userId) || [];
64
64
  setUsersList(usersData.filter((user) => user.role === 'support' && !userGroupsUserIds.includes(user.uid)).map((user) => {
65
65
  const userName = user.name ? user.name.replace("/", " ") : "";
66
66
  return { label: `${userName} (${user.email})`, id: user.uid };
@@ -191,8 +191,8 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
191
191
  const devicesPatched = await handleAddDevicesToGroup(userInfo, selectedGroup, devicesToPatch);
192
192
  if (devicesPatched && devicesPatched.length > 0) {
193
193
  // get all members of the group
194
- const userIdsToAdd = usersGroup.map((ug) => ug.user.userId);
195
- if (userIdsToAdd.length > 0) {
194
+ const userIdsToAdd = usersGroup && usersGroup.map((ug) => ug.user.userId) || [];
195
+ if (userIdsToAdd && userIdsToAdd.length > 0) {
196
196
  for (const device of devicesToPatch) {
197
197
  // add members to devices managers
198
198
  await handleUpdateDevice(device.id, {
@@ -225,11 +225,11 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
225
225
  if (devicesPatched && devicesPatched.length > 0) {
226
226
  for (const device of devicesToPatch) {
227
227
  if (device.managers && device.managers.length > 0) {
228
- let managersToKeep = device.managers || [];
228
+ let managersToKeep = device.managers;
229
229
  for (const manager of device.managers) {
230
230
  // should check if device is present in other groups the user is member of
231
231
  const groupsData = await handleGetGroups({ role: 'support', uid: manager });
232
- const userGroupIds = groupsData.map((group) => group.id);
232
+ const userGroupIds = groupsData && groupsData.map((group) => group.id) || [];
233
233
  const found = device.groups && device.groups.some((gID) => userGroupIds.includes(gID));
234
234
  if (!found) {
235
235
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iotready/nextjs-components-library",
3
- "version": "1.0.0-preview18",
3
+ "version": "1.0.0-preview19",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc --project tsconfig.build.json && cp package.json dist/",