@iotready/nextjs-components-library 1.0.0-preview4 → 1.0.0-preview41

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.
Files changed (42) hide show
  1. package/assets/translations/en.json +92 -0
  2. package/assets/translations/index.d.ts +95 -0
  3. package/assets/translations/index.js +4 -0
  4. package/assets/translations/it.json +92 -0
  5. package/assets/translations/scripts/export.js +74 -0
  6. package/assets/translations/scripts/import.js +66 -0
  7. package/components/accounts/AccountMenu.d.ts +2 -1
  8. package/components/accounts/AccountMenu.js +2 -2
  9. package/components/accounts/AccountProfile.d.ts +2 -1
  10. package/components/accounts/AccountProfile.js +15 -15
  11. package/components/charts/TrendChart.d.ts +28 -6
  12. package/components/charts/TrendChart.js +555 -149
  13. package/components/groups/GroupUpdate.d.ts +9 -10
  14. package/components/groups/GroupUpdate.js +21 -38
  15. package/components/groups/GroupsDevices.d.ts +22 -17
  16. package/components/groups/GroupsDevices.js +165 -110
  17. package/components/groups/Map.d.ts +5 -9
  18. package/components/groups/Map.js +2 -2
  19. package/components/settings/DynamicMenu.d.ts +1 -0
  20. package/components/settings/DynamicMenu.js +2 -1
  21. package/components/users/UserUpdate.d.ts +2 -1
  22. package/components/users/UserUpdate.js +2 -2
  23. package/components/users/UsersDataGrid.d.ts +11 -3
  24. package/components/users/UsersDataGrid.js +49 -32
  25. package/package.json +8 -4
  26. package/server-actions/annotations.d.ts +4 -0
  27. package/server-actions/annotations.js +12 -0
  28. package/server-actions/groups.d.ts +16 -16
  29. package/server-actions/groups.js +157 -72
  30. package/server-actions/index.d.ts +1 -0
  31. package/server-actions/index.js +1 -0
  32. package/server-actions/influx.d.ts +17 -13
  33. package/server-actions/influx.js +207 -98
  34. package/server-actions/trackle.d.ts +10 -4
  35. package/server-actions/trackle.js +59 -38
  36. package/server-actions/types.d.ts +16 -0
  37. package/server-actions/types.js +6 -0
  38. package/types/device.d.ts +19 -0
  39. package/types/device.js +1 -0
  40. package/types/index.d.ts +1 -0
  41. package/types/index.js +1 -0
  42. package/types/user.d.ts +2 -0
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Box, CircularProgress, Autocomplete, TextField, Input, IconButton, Button, Card, CardContent, CardHeader, Modal, Typography, Stack, Tab } from "@mui/material";
4
- import { cloneElement, isValidElement, useEffect, useMemo, useState } from "react";
4
+ import { cloneElement, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
5
5
  import AddIcon from '@mui/icons-material/Add';
6
6
  import PlaylistAddIcon from '@mui/icons-material/PlaylistAdd';
7
7
  import EditIcon from '@mui/icons-material/Edit';
@@ -10,60 +10,51 @@ import ReadMoreIcon from '@mui/icons-material/ReadMore';
10
10
  import PlaylistRemoveIcon from '@mui/icons-material/PlaylistRemove';
11
11
  import CloseIcon from '@mui/icons-material/Close';
12
12
  import { LoadingButton, TabContext, TabList, TabPanel } from "@mui/lab";
13
- import { DataGrid, GridToolbar } from "@mui/x-data-grid";
13
+ import { DataGrid, GridToolbar, GridToolbarExport, GridToolbarFilterButton, GridToolbarQuickFilter } from "@mui/x-data-grid";
14
14
  import GroupUpdate from "./GroupUpdate";
15
15
  import BackIcon from '@mui/icons-material/ArrowBack';
16
16
  import dynamic from "next/dynamic";
17
17
  import { ThemeProvider } from '@mui/material/styles';
18
- const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, handleRemoveUserFromGroup, handleGetGroups, handleGetUsersGroup, handleGetDevices, handleUpdateDevice, handleGetPositions, handleAddDevicesToGroup, handleRemoveDevicesFromGroup, handleCreateGroup, handleDeleteGroup, handleUpdateGroup, group = 'all', columnsArray = [], containerDataGrid = 'Card', props = {}, propsDatagrid = {}, loadingComponent = _jsx(CircularProgress, {}), containerProps = {}, enableMaps = true, mapsHeight = '400px', mapsClickCallback = () => { }, theme, confirmMui }) => {
19
- const [devices, setDevices] = useState(null);
18
+ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, handleRemoveUserFromGroup, handleGetGroups, handleGetUsersGroup, handleGetDevices, handleUpdateDevice, handleGetPositions, handleAddDevicesToGroup, handleRemoveDevicesFromGroup, handleCreateGroup, handleDeleteGroup, handleUpdateGroup, group = 'all', columnsArray = [], containerDataGrid = 'Card', props = {}, propsDatagrid = {}, loadingComponent = _jsx(CircularProgress, {}), containerProps = {}, enableMaps = true, mapsHeight = '400px', mapsClickCallback = () => { }, theme, confirmMui, propsHeaderGroups, forceGetDevices = 0, customToolbar, groupsLabelAll, addDevicesLabel, noDevicesLabel, groupUpdateRoles, isOrg = false, currentOrg, t, dataGridLocaleText }) => {
19
+ const [devices, setDevices] = useState([]);
20
20
  const [positions, setPositions] = useState([]);
21
21
  const [loadingDevices, setLoadingDevices] = useState(false);
22
22
  const [loadingGroups, setLoadingGroups] = useState(false);
23
23
  const [loadingAdd, setLoadingAdd] = useState(false);
24
- const [editGroup, setEditGroup] = useState(false);
24
+ const [editGroup, setEditGroup] = useState(isOrg ? true : false);
25
25
  const [checkboxSelection, setCheckboxSelection] = useState(false);
26
26
  const [devicesToAdd, setDevicesToAdd] = useState([]);
27
+ const [deviceSelectedObjs, setDeviceSelectedObjs] = useState([]);
27
28
  const [currentGroup, setCurrentGroup] = useState(group);
28
29
  const [selectedGroup, setSelectedGroup] = useState(group);
29
30
  const [groups, setGroups] = useState(null);
30
31
  const [usersList, setUsersList] = useState([]);
31
- const [usersGroup, setUsersGroup] = useState([]);
32
+ const [usersGroup, setUsersGroup] = useState(null);
32
33
  const [groupInfo, setGroupInfo] = useState(null);
33
34
  const [openAdd, setOpenAdd] = useState(false);
34
35
  const [groupName, setGroupName] = useState('');
35
36
  const [description, setDescription] = useState('');
36
37
  const [groupUpdateVisible, setGroupUpdateVisible] = useState(false);
37
38
  const [valueTab, setValueTab] = useState('1');
39
+ const clickedIdRef = useRef(null);
40
+ const labelEntity = isOrg ? t('library.groupsDevices.organization') : t('library.groupsDevices.group');
41
+ const labelEntityLower = labelEntity.toLowerCase();
38
42
  const handleChangeTab = (event, newValue) => {
39
43
  setValueTab(newValue);
40
44
  };
41
- const Map = useMemo(() => dynamic(() => import("./Map"), {
45
+ const MapComponent = useMemo(() => dynamic(() => import("./Map"), {
42
46
  loading: () => isValidElement(loadingComponent) ? cloneElement(loadingComponent, { height: mapsHeight }) : null,
43
47
  ssr: false
44
48
  }), []);
45
49
  const getUsersList = async () => {
46
50
  try {
47
- let page = 1;
48
- const pageSize = 100;
49
- let usersData = [];
50
- let moreData = true;
51
- while (moreData) {
52
- const usersList = await handleGetUsersList({
53
- page,
54
- pageSize,
55
- });
56
- if (usersList.users && usersList.users.length > 0) {
57
- usersData = [...usersData, ...usersList.users];
58
- }
59
- // Se il numero di utenti restituiti è minore di pageSize, non ci sono più pagine da caricare
60
- moreData = usersList.users.length === pageSize;
61
- page++;
62
- }
63
- const userGroupsUserIds = usersGroup.map((ug) => ug.user.userId);
64
- setUsersList(usersData.filter((user) => user.role === 'support' && !userGroupsUserIds.includes(user.uid)).map((user) => {
65
- const userName = user.name ? user.name.replace("/", " ") : "";
66
- return { label: `${userName} (${user.email})`, id: user.uid };
51
+ const usersData = await handleGetUsersList();
52
+ const userGroupsUserIds = usersGroup && usersGroup.map((ug) => ug.user.userId) || [];
53
+ setUsersList(usersData
54
+ .filter((user) => !userGroupsUserIds.includes(user.uid))
55
+ .map((user) => {
56
+ const userName = user.profile.name ? user.profile.name.replace("/", " ") : "";
57
+ return { label: `${userName} (${user.profile.email})`, id: user.uid };
67
58
  }));
68
59
  }
69
60
  catch (err) {
@@ -71,11 +62,18 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
71
62
  }
72
63
  };
73
64
  const fetchDevices = async (group, selected) => {
65
+ let groupToUse = group;
66
+ if (currentOrg === 'all' && group === 'all' && selected !== 'all') {
67
+ groupToUse = groupInfo.parent_id;
68
+ }
69
+ else if (currentOrg != undefined && group === 'all') {
70
+ groupToUse = currentOrg;
71
+ }
74
72
  try {
75
73
  setLoadingDevices(true);
76
- const devices = await handleGetDevices(userInfo, group, selected);
74
+ const devices = await handleGetDevices(userInfo, groupToUse, selected);
77
75
  setDevices(devices);
78
- if (enableMaps) {
76
+ if (enableMaps && handleGetPositions) {
79
77
  const positions = await handleGetPositions(devices);
80
78
  setPositions(positions);
81
79
  }
@@ -89,7 +87,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
89
87
  };
90
88
  const getGroups = async () => {
91
89
  try {
92
- const responseData = await handleGetGroups(1008, userInfo);
90
+ const responseData = await handleGetGroups(userInfo);
93
91
  setGroups(responseData);
94
92
  }
95
93
  catch (err) {
@@ -111,18 +109,26 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
111
109
  }
112
110
  }, [userInfo]);
113
111
  useEffect(() => {
114
- if (usersGroup) {
115
- getUsersList();
116
- }
112
+ getUsersList();
117
113
  }, [usersGroup]);
118
114
  useEffect(() => {
119
- if (currentGroup && !checkboxSelection) {
115
+ if (currentGroup && !checkboxSelection && groups !== null) {
120
116
  setSelectedGroup(currentGroup);
121
117
  setGroupInfo(groups && groups.find((g) => g.id === currentGroup));
122
- getUsersGroup(currentGroup);
118
+ if (currentGroup !== 'all') {
119
+ getUsersGroup(currentGroup);
120
+ }
123
121
  fetchDevices(currentGroup, currentGroup);
122
+ if (isOrg) {
123
+ setCheckboxSelection(true);
124
+ }
124
125
  }
125
- }, [currentGroup]);
126
+ }, [currentGroup, groups]);
127
+ useEffect(() => {
128
+ if (forceGetDevices !== 0) {
129
+ fetchDevices(currentGroup, currentGroup);
130
+ }
131
+ }, [forceGetDevices]);
126
132
  const handleSubmit = async (e) => {
127
133
  e.preventDefault();
128
134
  setLoadingAdd(true);
@@ -130,13 +136,13 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
130
136
  const newGroup = {
131
137
  name: groupName,
132
138
  description,
133
- productID: 1008, // Assuming this is the correct productID
134
139
  };
135
140
  const id = await handleCreateGroup(newGroup);
136
141
  await getGroups();
137
142
  setCurrentGroup(id);
138
143
  setGroupInfo({ ...newGroup, id });
139
144
  setSelectedGroup(id);
145
+ getUsersGroup(id);
140
146
  setDevicesToAdd([]), setEditGroup(!editGroup);
141
147
  setCheckboxSelection(!checkboxSelection);
142
148
  fetchDevices(id, id);
@@ -172,28 +178,11 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
172
178
  const addToSelectedGroup = async () => {
173
179
  setLoadingGroups(true);
174
180
  try {
175
- const selectedData = devices.filter((row) => devicesToAdd.includes(row.id));
176
- const devicesToPatch = selectedData?.map((device) => ({ id: device.id, groups: device.state.groups, managers: device.managers }));
177
- const devicesPatched = await handleAddDevicesToGroup(userInfo, selectedGroup, devicesToPatch);
178
- if (devicesPatched && devicesPatched.length > 0) {
179
- // get all members of the group
180
- const userIdsToAdd = usersGroup.map((ug) => ug.user.userId);
181
- if (userIdsToAdd.length > 0) {
182
- for (const device of devicesToPatch) {
183
- // add members to devices managers
184
- await handleUpdateDevice(device.id, {
185
- managers: [
186
- ...device.managers,
187
- ...userIdsToAdd
188
- ]
189
- }, userInfo);
190
- }
191
- }
192
- setLoadingGroups(false);
193
- setCurrentGroup(selectedGroup);
194
- setDevicesToAdd([...[]]);
195
- fetchDevices(selectedGroup, selectedGroup);
196
- }
181
+ await handleAddDevicesToGroup(userInfo, selectedGroup, deviceSelectedObjs);
182
+ setLoadingGroups(false);
183
+ setCurrentGroup(selectedGroup);
184
+ setDevicesToAdd([...[]]);
185
+ fetchDevices(selectedGroup, selectedGroup);
197
186
  }
198
187
  catch (err) {
199
188
  console.error(err);
@@ -205,32 +194,10 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
205
194
  const removeFromCurrentGroup = async () => {
206
195
  setLoadingGroups(true);
207
196
  try {
208
- const devicesToRemove = devices.filter((row) => devicesToAdd.includes(row.id));
209
- const devicesToPatch = devicesToRemove?.map((device) => ({ id: device.id, groups: device.state.groups, managers: device.managers }));
210
- const devicesPatched = await handleRemoveDevicesFromGroup(userInfo, selectedGroup, devicesToPatch);
211
- if (devicesPatched && devicesPatched.length > 0) {
212
- for (const device of devicesToPatch) {
213
- if (device.managers.length > 0) {
214
- let managersToKeep = device.managers || [];
215
- for (const manager of device.managers) {
216
- // should check if device is present in other groups the user is member of
217
- const groupsData = await handleGetGroups(1008, { role: 'support', uid: manager });
218
- const userGroupIds = groupsData.map((group) => group.id);
219
- const found = device.groups && device.groups.some((gID) => userGroupIds.includes(gID));
220
- if (!found) {
221
- // @ts-ignore
222
- managersToKeep = managersToKeep.filter(man => man !== manager);
223
- }
224
- }
225
- await handleUpdateDevice(device.id, {
226
- managers: managersToKeep
227
- }, userInfo);
228
- }
229
- }
230
- setLoadingGroups(false);
231
- setDevicesToAdd([]);
232
- fetchDevices(currentGroup, selectedGroup);
233
- }
197
+ await handleRemoveDevicesFromGroup(userInfo, selectedGroup, deviceSelectedObjs);
198
+ setLoadingGroups(false);
199
+ setDevicesToAdd([]);
200
+ fetchDevices(currentGroup, selectedGroup);
234
201
  }
235
202
  catch (err) {
236
203
  console.error(err);
@@ -246,15 +213,101 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
246
213
  setEditGroup(!editGroup);
247
214
  setCheckboxSelection(!checkboxSelection);
248
215
  };
249
- const renderMaps = (_jsx(Map, { positions: positions, mapsClickCallback: mapsClickCallback, height: mapsHeight }));
250
- const renderDataGrid = (_jsx("div", { style: { display: 'flex', flexDirection: 'column', minHeight: 323 }, children: _jsx(DataGrid, { checkboxSelection: checkboxSelection, onRowSelectionModelChange: (ids) => {
251
- if (checkboxSelection) {
252
- setDevicesToAdd(ids);
216
+ const renderMaps = (_jsx(MapComponent, { positions: positions, mapsClickCallback: mapsClickCallback, height: mapsHeight, t: t }));
217
+ useEffect(() => {
218
+ if (devicesToAdd.length <= 0) {
219
+ setDeviceSelectedObjs([]);
220
+ }
221
+ }, [devicesToAdd]);
222
+ const CustomToolbar = useCallback((props) => (_jsxs("div", { style: { display: 'flex', padding: '8px', justifyContent: 'space-between', paddingTop: '2px' }, children: [_jsxs("div", { style: { display: 'flex', gap: 8, marginRight: '20px' }, children: [customToolbar && customToolbar.includes('filters') ?
223
+ _jsx(GridToolbarFilterButton, {})
224
+ : '', customToolbar && customToolbar.includes('export') ?
225
+ _jsx(GridToolbarExport, {})
226
+ : ''] }), customToolbar && customToolbar.includes('quickfilter') && _jsx(GridToolbarQuickFilter, {})] })), []);
227
+ const renderDataGrid = (_jsx("div", { style: { display: 'flex', flexDirection: 'column', minHeight: 323 }, children: _jsx(DataGrid, { checkboxSelection: checkboxSelection, localeText: dataGridLocaleText,
228
+ // Se siamo in modalità aggiunta, includi gli ID già nel gruppo
229
+ rowSelectionModel: (checkboxSelection && currentGroup === 'all')
230
+ ? [
231
+ ...devices
232
+ .filter(d => d.groups?.includes(selectedGroup))
233
+ .map(d => d.id.toString()),
234
+ ...devicesToAdd,
235
+ ]
236
+ : devicesToAdd,
237
+ // Se siamo in modalità aggiunta, disabilita la selezione per i già nel gruppo
238
+ isRowSelectable: params => {
239
+ return (checkboxSelection && currentGroup === 'all')
240
+ ? !params.row.groups?.includes(selectedGroup)
241
+ : true;
242
+ }, onCellClick: (params) => {
243
+ clickedIdRef.current = params.id.toString(); // aggiornamento immediato
244
+ }, onRowSelectionModelChange: (ids) => {
245
+ if (!checkboxSelection)
246
+ return;
247
+ // Se abbiamo un clickedIdRef, gestiamo il click individuale
248
+ if (clickedIdRef.current) {
249
+ const clickedId = clickedIdRef.current;
250
+ clickedIdRef.current = null; // resetta subito dopo l'uso
251
+ setDevicesToAdd(prevIds => {
252
+ const updated = prevIds.includes(clickedId)
253
+ ? prevIds.filter(id => id !== clickedId)
254
+ : [...prevIds, clickedId];
255
+ return updated;
256
+ });
257
+ setDeviceSelectedObjs(prevObjs => {
258
+ const isDeselecting = prevObjs.some(d => d.id.toString() === clickedId);
259
+ if (isDeselecting) {
260
+ return prevObjs.filter(d => d.id.toString() !== clickedId);
261
+ }
262
+ else {
263
+ const device = devices.find(d => d.id.toString() === clickedId);
264
+ return device ? [...prevObjs, device] : prevObjs;
265
+ }
266
+ });
253
267
  }
254
- }, rowSelectionModel: devicesToAdd, disableDensitySelector: true, disableColumnSelector: true, disableRowSelectionOnClick: true, loading: loadingDevices, rows: devices, columns: checkboxSelection ? columnsArray.filter(col => col.field !== 'id') : columnsArray, slots: {
255
- noRowsOverlay: () => (_jsx(Stack, { height: "100%", alignItems: "center", justifyContent: "center", children: currentGroup !== 'all' ? _jsxs(_Fragment, { children: [_jsx(Box, { children: "No devices in group" }), editGroup ? _jsxs(Button, { onClick: () => addDevicesToCurrentGroup(), variant: "outlined", color: "primary", size: "small", sx: { mt: 2 }, children: [_jsx(PlaylistAddIcon, { fontSize: "small", sx: { mr: 1 } }), " Add devices"] }) : ''] }) : "No devices" })),
256
- noResultsOverlay: () => (_jsx(Stack, { height: "100%", alignItems: "center", justifyContent: "center", children: "Filter returns no result" })),
257
- toolbar: GridToolbar,
268
+ else {
269
+ // Gestione del "check all" - confronta con il modello di selezione attuale
270
+ const currentSelection = (checkboxSelection && currentGroup === 'all')
271
+ ? [
272
+ ...devices
273
+ .filter(d => d.groups?.includes(selectedGroup))
274
+ .map(d => d.id.toString()),
275
+ ...devicesToAdd,
276
+ ]
277
+ : devicesToAdd;
278
+ // Se la selezione è diversa, aggiorna devicesToAdd
279
+ if (JSON.stringify(ids.sort()) !== JSON.stringify(currentSelection.sort())) {
280
+ // Filtra solo i dispositivi che non sono già nel gruppo
281
+ const selectableDevices = devices
282
+ .filter(d => !d.groups?.includes(selectedGroup))
283
+ .map(d => d.id.toString());
284
+ // Calcola i nuovi dispositivi da aggiungere
285
+ const newDevicesToAdd = ids.filter(id => selectableDevices.includes(id) && !devicesToAdd.includes(id));
286
+ // Calcola i dispositivi da rimuovere dalla selezione
287
+ const devicesToRemove = devicesToAdd.filter(id => !ids.includes(id));
288
+ // Aggiorna devicesToAdd
289
+ setDevicesToAdd(prevIds => {
290
+ return prevIds
291
+ .filter(id => !devicesToRemove.includes(id))
292
+ .concat(newDevicesToAdd);
293
+ });
294
+ // Aggiorna deviceSelectedObjs
295
+ setDeviceSelectedObjs(prevObjs => {
296
+ return prevObjs
297
+ .filter(d => !devicesToRemove.includes(d.id.toString()))
298
+ .concat(devices.filter(d => newDevicesToAdd.includes(d.id.toString()) &&
299
+ !prevObjs.some(obj => obj.id.toString() === d.id.toString())));
300
+ });
301
+ }
302
+ }
303
+ }, disableDensitySelector: true, disableColumnSelector: true, disableRowSelectionOnClick: true, loading: loadingDevices, rows: devices, columns: checkboxSelection
304
+ ? columnsArray.filter(col => col.field !== 'id')
305
+ : columnsArray, slots: {
306
+ noRowsOverlay: () => (_jsx(Stack, { height: "100%", alignItems: "center", justifyContent: "center", children: currentGroup !== 'all'
307
+ ? (_jsxs(_Fragment, { children: [_jsx(Box, { children: noDevicesLabel || t('library.groupsDevices.noDevicesInGroup', { entity: labelEntityLower }) }), editGroup && (_jsxs(Button, { onClick: addDevicesToCurrentGroup, variant: "outlined", color: "primary", size: "small", sx: { mt: 2 }, children: [_jsx(PlaylistAddIcon, { fontSize: "small", sx: { mr: 1 } }), addDevicesLabel || t('library.groupsDevices.addDevices')] }))] }))
308
+ : noDevicesLabel || t('library.groupsDevices.noDevices') })),
309
+ noResultsOverlay: () => (_jsx(Stack, { height: "100%", alignItems: "center", justifyContent: "center", children: t('library.groupsDevices.filterReturnsNoResult') })),
310
+ toolbar: customToolbar && customToolbar.length ? CustomToolbar : GridToolbar,
258
311
  }, slotProps: {
259
312
  toolbar: {
260
313
  showQuickFilter: true,
@@ -262,38 +315,40 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
262
315
  printOptions: { disableToolbarButton: true },
263
316
  },
264
317
  }, initialState: {
265
- sorting: {
266
- sortModel: [{ field: 'online', sort: 'desc' }],
267
- },
318
+ pagination: { paginationModel: { pageSize: 100 } },
268
319
  }, ...propsDatagrid }) }));
269
- const renderTabContext = (_jsxs(TabContext, { value: valueTab, children: [_jsx(Box, { sx: { borderBottom: 1, borderColor: 'divider' }, children: _jsxs(TabList, { onChange: handleChangeTab, sx: { minHeight: 20 }, children: [_jsx(Tab, { label: "List", value: "1", sx: { minHeight: 20 } }), _jsx(Tab, { label: "Map", value: "2", sx: { minHeight: 20 } })] }) }), _jsx(TabPanel, { value: "1", sx: { p: 0 }, children: renderDataGrid }), _jsx(TabPanel, { value: "2", sx: { p: 0 }, children: renderMaps })] }));
320
+ const renderTabContext = (_jsxs(TabContext, { value: valueTab, children: [_jsx(Box, { sx: { borderBottom: 1, borderColor: 'divider' }, children: _jsxs(TabList, { onChange: handleChangeTab, sx: { minHeight: 20 }, children: [_jsx(Tab, { label: t('library.groupsDevices.list'), value: "1", sx: { minHeight: 20 } }), _jsx(Tab, { label: t('library.groupsDevices.map'), value: "2", sx: { minHeight: 20 } })] }) }), _jsx(TabPanel, { value: "1", sx: { p: 0 }, children: renderDataGrid }), _jsx(TabPanel, { value: "2", sx: { p: 0 }, children: renderMaps })] }));
270
321
  const renderDatagridAndMaps = (enableMaps ?
271
322
  containerDataGrid === 'Card' ?
272
323
  _jsx(Card, { ...containerProps, children: renderTabContext }) : _jsx(Box, { ...containerProps, children: renderTabContext }) : containerDataGrid === 'Card' ?
273
324
  _jsx(Card, { ...containerProps, children: renderDataGrid }) : _jsx(Box, { ...containerProps, children: renderDataGrid }));
274
325
  if (!userInfo || !groups || !devices)
275
326
  return loadingComponent;
276
- return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Box, { ...props, children: [_jsxs(Box, { component: "div", sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 1, backgroundColor: editGroup ? 'secondary.light' : '', borderRadius: 3, px: editGroup ? 2 : 0, py: 1, height: 50 }, children: [editGroup ? _jsxs(Typography, { variant: 'subtitle1', children: [_jsx(Box, { component: 'span', sx: { display: { xs: 'none' } }, children: "Edit group" }), " ", _jsx("b", { children: groupInfo?.name })] }) : '', groups && !checkboxSelection && !(editGroup && currentGroup === 'all') ?
277
- _jsx(Autocomplete, { disablePortal: true, onChange: handleChangeGroupSelect, value: groupInfo?.name || 'All devices', disableClearable: currentGroup === 'all', isOptionEqualToValue: (o, v) => o.label === v, options: [{ label: 'All devices', id: 'all' }, ...groups.map((grp) => ({ label: grp.name, id: grp.id }))], sx: { width: { xs: 200, sm: 300 }, textAlign: 'left' }, size: 'small', renderInput: (params) => _jsx(TextField, { ...params, label: "Group" }) })
278
- : '', userInfo.role === 'admin' &&
279
- _jsxs(Box, { children: [checkboxSelection ?
327
+ return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Box, { ...props, children: [_jsxs(Box, { component: "div", sx: { display: 'flex', alignItems: 'center', mb: 1, backgroundColor: editGroup && !isOrg ? 'secondary.light' : '', borderRadius: 3, px: editGroup ? 2 : 0, py: 1, height: 50, ...propsHeaderGroups }, children: [editGroup ? _jsx(Typography, { variant: isOrg ? 'h6' : 'subtitle1', children: _jsxs("b", { children: [labelEntity, " \"", groupInfo?.name, "\""] }) }) : '', groups && !checkboxSelection && !isOrg && !(editGroup && currentGroup === 'all') ?
328
+ _jsx(Autocomplete, { disablePortal: true, onChange: handleChangeGroupSelect, value: groupInfo?.name || groupsLabelAll || t('library.groupsDevices.allDevices'), disableClearable: currentGroup === 'all', isOptionEqualToValue: (o, v) => o.label === v, options: [{ label: groupsLabelAll || t('library.groupsDevices.allDevices'), id: 'all' }, ...groups.map((grp) => ({ label: grp.name, id: grp.id }))], sx: { width: { xs: 200, sm: 300 }, textAlign: 'left' }, size: 'small', renderInput: (params) => _jsx(TextField, { ...params, label: labelEntity }) })
329
+ : '', (userInfo.role === 'admin' || (groupUpdateRoles && groupUpdateRoles.includes(userInfo.role))) &&
330
+ _jsxs(Box, { sx: { ml: 2 }, children: [checkboxSelection ?
280
331
  _jsx(Input, { value: selectedGroup, type: 'hidden', size: 'small' })
281
- : '', selectedGroup === 'all' ? _jsxs(Button, { variant: "contained", color: "primary", onClick: () => { handleOpenAdd(); }, children: [_jsx(AddIcon, { sx: { mr: 1 } }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: "Create\u00A0" }), " group"] }) : '', editGroup ?
332
+ : '', selectedGroup === 'all' && (currentOrg !== 'all') ? _jsxs(Button, { variant: "contained", color: "primary", onClick: () => { handleOpenAdd(); }, children: [_jsx(AddIcon, { sx: { mr: 1 } }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: t('library.groupsDevices.createGroup', { entity: labelEntityLower }) })] }) : '', editGroup ?
282
333
  currentGroup === 'all' ?
283
- checkboxSelection ? _jsxs(_Fragment, { children: [_jsxs(Button, { onClick: () => { setGroupUpdateVisible(false); setDevicesToAdd([]); setCurrentGroup(selectedGroup); setCheckboxSelection(true); fetchDevices(selectedGroup, selectedGroup); }, variant: "text", color: "inherit", size: "small", children: [_jsx(BackIcon, { fontSize: "small" }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: "\u00A0Group devices" })] }), _jsxs(LoadingButton, { loading: loadingGroups, onClick: () => addToSelectedGroup(), variant: 'contained', size: "small", disabled: devicesToAdd.length === 0 || selectedGroup === 'all' || loadingGroups, sx: { ml: 2 }, children: [_jsx(ReadMoreIcon, { sx: { mr: 1 } }), " Add to group"] })] }) : ''
284
- : devicesToAdd.length === 0 ? groupUpdateVisible ? _jsxs(Button, { onClick: () => setGroupUpdateVisible(false), sx: { ml: 2 }, variant: "text", color: "inherit", size: "small", children: [_jsx(BackIcon, { fontSize: "small" }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: "\u00A0Group devices" })] }) :
285
- _jsxs(_Fragment, { children: [_jsxs(Button, { onClick: () => addDevicesToCurrentGroup(), sx: { ml: 2 }, variant: "outlined", color: "primary", size: "small", children: [_jsx(PlaylistAddIcon, { fontSize: "small", sx: { mr: 1 } }), " Add devices"] }), _jsxs(Button, { onClick: () => setGroupUpdateVisible(true), sx: { ml: 2 }, variant: "outlined", color: "success", size: "small", children: [_jsx(SettingsIcon, { fontSize: "small" }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: "\u00A0Manage group" })] })] })
286
- : _jsxs(LoadingButton, { loading: loadingGroups, onClick: async () => { setLoadingGroups(true); await removeFromCurrentGroup(); }, variant: "contained", color: "error", size: "small", disabled: loadingGroups, sx: { ml: 2 }, children: [_jsx(PlaylistRemoveIcon, { fontSize: "small", sx: { mr: 1 } }), " Remove from group"] })
287
- : '', selectedGroup !== 'all' ?
334
+ checkboxSelection ? _jsxs(_Fragment, { children: [_jsxs(Button, { onClick: () => { setGroupUpdateVisible(false); setDevicesToAdd([]); setCurrentGroup(selectedGroup); setCheckboxSelection(true); fetchDevices(selectedGroup, selectedGroup); }, variant: "text", color: "inherit", size: "small", children: [_jsx(BackIcon, { fontSize: "small" }), _jsxs(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: ["\u00A0", t('library.groupsDevices.backToGroup', { entity: labelEntityLower })] })] }), _jsxs(LoadingButton, { loading: loadingGroups, onClick: () => addToSelectedGroup(), variant: 'contained', size: "small", disabled: devicesToAdd.length === 0 || selectedGroup === 'all' || loadingGroups, sx: { ml: 2 }, children: [_jsx(ReadMoreIcon, { sx: { mr: 1 } }), " ", t('library.groupsDevices.addToGroup')] })] }) : ''
335
+ : devicesToAdd.length === 0 ? groupUpdateVisible ? _jsxs(Button, { onClick: () => setGroupUpdateVisible(false), sx: { ml: 2 }, variant: "text", color: "inherit", size: "small", children: [_jsx(BackIcon, { fontSize: "small" }), _jsxs(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: ["\u00A0", t('library.groupsDevices.backToGroup', { entity: labelEntityLower })] })] }) :
336
+ _jsxs(_Fragment, { children: [_jsxs(Button, { onClick: () => addDevicesToCurrentGroup(), sx: { ml: 2 }, variant: "outlined", color: "primary", size: "small", children: [_jsx(PlaylistAddIcon, { fontSize: "small", sx: { mr: 1 } }), " ", addDevicesLabel || t('library.groupsDevices.addDevices')] }), _jsxs(Button, { onClick: () => setGroupUpdateVisible(true), sx: { ml: 2 }, variant: "outlined", color: "success", size: "small", children: [_jsx(SettingsIcon, { fontSize: "small" }), _jsxs(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: ["\u00A0", t('library.groupsDevices.manageGroup', { entity: labelEntityLower })] })] })] })
337
+ : _jsxs(LoadingButton, { loading: loadingGroups, onClick: async () => { setLoadingGroups(true); await removeFromCurrentGroup(); }, variant: "contained", color: "error", size: "small", disabled: loadingGroups, sx: { ml: 2 }, children: [_jsx(PlaylistRemoveIcon, { fontSize: "small", sx: { mr: 1 } }), " ", t('library.groupsDevices.removeFromGroup', { entity: labelEntityLower })] })
338
+ : '', selectedGroup !== 'all' && !isOrg ?
288
339
  _jsx(_Fragment, { children: editGroup ?
289
- _jsxs(Button, { variant: "text", color: "inherit", onClick: () => closeEditGroup(), sx: { ml: 2 }, children: [_jsx(CloseIcon, { fontSize: "small" }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: "\u00A0Close edit" })] })
290
- : _jsxs(Button, { variant: "contained", color: "secondary", onClick: () => { setDevicesToAdd([]); setEditGroup(!editGroup); setCheckboxSelection(!checkboxSelection); }, children: [_jsx(EditIcon, { sx: { mr: 1 } }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: "Edit\u00A0" }), " group"] }) }) : ''] })] }), _jsx(Modal, { open: openAdd, onClose: handleCloseAdd, children: _jsxs(Card, { sx: {
340
+ _jsxs(Button, { variant: "text", color: "inherit", onClick: () => closeEditGroup(), sx: { ml: 2 }, children: [_jsx(CloseIcon, { fontSize: "small" }), _jsxs(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: ["\u00A0", t('library.groupsDevices.closeEdit')] })] })
341
+ : _jsxs(Button, { variant: "contained", color: "secondary", onClick: () => { setDevicesToAdd([]); setEditGroup(!editGroup); setCheckboxSelection(!checkboxSelection); }, children: [_jsx(EditIcon, { sx: { mr: 1 } }), _jsx(Box, { component: 'span', sx: { display: { xs: 'none', sm: 'inline' } }, children: t('library.groupsDevices.editGroup', { entity: labelEntityLower }) })] }) }) : ''] })] }), _jsx(Modal, { open: openAdd, onClose: handleCloseAdd, children: _jsxs(Card, { sx: {
291
342
  position: 'absolute',
292
343
  top: '50%',
293
344
  left: '50%',
294
345
  transform: 'translate(-50%, -50%)',
295
346
  width: 400,
296
347
  borderRadius: 4
297
- }, children: [_jsx(CardHeader, { title: "New Group", action: _jsx(IconButton, { onClick: handleCloseAdd, children: _jsx(CloseIcon, {}) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TextField, { fullWidth: true, label: "Group Name", value: groupName, onChange: (e) => setGroupName(e.target.value), required: true }), _jsx(TextField, { fullWidth: true, label: "Description", value: description, onChange: (e) => setDescription(e.target.value), margin: "normal", multiline: true, rows: 4 }), _jsxs(Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [_jsx(Button, { variant: "contained", color: "info", onClick: handleCloseAdd, children: "Cancel" }), _jsx(LoadingButton, { loading: loadingAdd, variant: "contained", color: "primary", type: "submit", children: "Create" })] })] }) })] }) }), !groupUpdateVisible && renderDatagridAndMaps, groupInfo && editGroup && groupUpdateVisible && _jsx(GroupUpdate, { confirmMui: confirmMui, userInfo: userInfo, usersGroup: usersGroup, usersList: usersList, handleGetGroups: handleGetGroups, handleUpdateDevice: handleUpdateDevice, handleAddUserToGroup: handleAddUserToGroup, handleRemoveUserFromGroup: handleRemoveUserFromGroup, groupInfo: groupInfo, afterUpdateCallback: async (groupInfo) => { setGroupInfo(groupInfo); await getGroups(); await getUsersGroup(groupInfo.id); }, afterRemoveCallback: async () => { closeEditGroup(); await getGroups(); setCurrentGroup('all'); }, container: 'Card', handleDeleteGroup: handleDeleteGroup, handleUpdateGroup: handleUpdateGroup, devicesList: devices.map((device) => ({ id: device.id, state: device.state, managers: device.managers })) })] }) }));
348
+ }, children: [_jsx(CardHeader, { title: t('library.groupsDevices.newGroup', { entity: labelEntity }), action: _jsx(IconButton, { onClick: handleCloseAdd, children: _jsx(CloseIcon, {}) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TextField, { fullWidth: true, label: t('library.groupsDevices.groupName', { entity: labelEntity }), value: groupName, onChange: (e) => setGroupName(e.target.value), required: true }), _jsx(TextField, { fullWidth: true, label: t('library.groupsDevices.description'), value: description, onChange: (e) => setDescription(e.target.value), margin: "normal", multiline: true, rows: 4 }), _jsxs(Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [_jsx(Button, { variant: "contained", color: "info", onClick: handleCloseAdd, children: t('library.groupsDevices.cancel') }), _jsx(LoadingButton, { loading: loadingAdd, variant: "contained", color: "primary", type: "submit", children: t('library.groupsDevices.create') })] })] }) })] }) }), !groupUpdateVisible && renderDatagridAndMaps, groupInfo && editGroup && groupUpdateVisible && _jsx(GroupUpdate, { userInfo: userInfo, confirmMui: confirmMui, usersGroup: usersGroup, usersList: usersList, handleGetGroups: handleGetGroups, handleUpdateDevice: handleUpdateDevice, handleAddUserToGroup: handleAddUserToGroup, handleRemoveUserFromGroup: handleRemoveUserFromGroup, groupInfo: groupInfo, afterUpdateCallback: async (groupInfo) => { setGroupInfo(groupInfo); await getGroups(); await getUsersGroup(groupInfo.id); }, afterRemoveCallback: async () => { if (!isOrg) {
349
+ closeEditGroup();
350
+ setCurrentGroup('all');
351
+ await getGroups();
352
+ } }, container: 'Card', handleDeleteGroup: handleDeleteGroup, handleUpdateGroup: handleUpdateGroup, devicesList: devices, labelEntity: labelEntity, isOrg: isOrg, t: t })] }) }));
298
353
  };
299
354
  export default GroupsDevices;
@@ -1,14 +1,10 @@
1
1
  import 'leaflet/dist/leaflet.css';
2
2
  import "leaflet-defaulticon-compatibility";
3
3
  import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
4
- export type Position = {
5
- deviceID: string;
6
- name: string;
7
- lat: number;
8
- lng: number;
9
- };
10
- export default function Map({ positions, height, mapsClickCallback }: {
11
- positions: Position[];
4
+ import { DevicePositionType } from "../../types/device";
5
+ export default function Map({ positions, height, mapsClickCallback, t }: {
6
+ positions: DevicePositionType[];
12
7
  height: string;
13
- mapsClickCallback: (position: Position) => void;
8
+ mapsClickCallback: (position: DevicePositionType) => void;
9
+ t: (key: string, params?: any) => string;
14
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -6,12 +6,12 @@ import 'leaflet/dist/leaflet.css';
6
6
  import "leaflet-defaulticon-compatibility";
7
7
  import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
8
8
  import { Box, Link } from "@mui/material";
9
- export default function Map({ positions, height, mapsClickCallback = () => { } }) {
9
+ export default function Map({ positions, height, mapsClickCallback = () => { }, t }) {
10
10
  return positions.filter(pos => pos.lat !== null)?.length ? _jsxs(MapContainer, { bounds: L.latLngBounds(positions.filter(pos => pos.lat !== null)), zoom: 13, scrollWheelZoom: false, style: { width: '100%', height }, children: [_jsx(TileLayer, { attribution: '\u00A9 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" }), _jsx(MarkerClusterGroup, { chunkedLoading: true, children: positions.filter(pos => pos.lat !== null).map((position) => (_jsx(Marker, { position: [position.lat, position.lng], children: _jsx(Popup, { children: _jsxs(Link, { href: "#", onClick: () => mapsClickCallback(position), children: [_jsx("b", { children: position.name }), _jsx("br", {}), position.deviceID] }) }) }, position.deviceID))) })] }) : _jsx(Box, { sx: {
11
11
  display: 'flex',
12
12
  flexDirection: 'column',
13
13
  alignItems: 'center',
14
14
  justifyContent: 'center',
15
15
  height,
16
- }, children: _jsx("small", { children: "No positions for devices" }) });
16
+ }, children: _jsx("small", { children: t('library.map.noPositionsForDevices') }) });
17
17
  }
@@ -1,5 +1,6 @@
1
1
  import { SvgIconProps } from "@mui/material/SvgIcon";
2
2
  import { Theme } from "@emotion/react";
3
+ import React from "react";
3
4
  interface MenuItem {
4
5
  name: string;
5
6
  description: string;
@@ -4,6 +4,7 @@ import { createElement, useState } from "react";
4
4
  import { Box, Card, CardContent, List, ListItemButton, ListItemText, styled, ThemeProvider } from "@mui/material";
5
5
  import Grid from "@mui/material/Grid2";
6
6
  import NavigateNextIcon from "@mui/icons-material/NavigateNext";
7
+ import React from "react";
7
8
  const ListItemButtonSettings = styled(ListItemButton)(({ theme, selected }) => ({
8
9
  backgroundColor: theme.palette.primary.main,
9
10
  color: theme.palette.primary.contrastText,
@@ -37,6 +38,6 @@ const DynamicMenu = ({ menuItems, selectedIndex = null, theme }) => {
37
38
  const handleMenuClick = (index) => {
38
39
  setSelected(index); // Assicurati di non chiamarlo nel rendering
39
40
  };
40
- return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Grid, { container: true, spacing: 2, sx: { width: '100%' }, children: _jsx(Grid, { size: { xs: 12, lg: 9 }, children: _jsx(Card, { sx: { borderRadius: 2 }, children: _jsx(CardContent, { sx: { p: 0, "&:last-child": { p: 0 } }, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsx(Grid, { size: { xs: 12, sm: 4 }, sx: { display: { xs: selected !== null ? 'none' : 'block', sm: 'block' } }, children: _jsx(List, { sx: { p: 0, height: "100%", backgroundColor: "primary.main" }, children: menuItems.map((item, index) => (_jsxs(ListItemButtonSettings, { selected: selected === index, onClick: () => handleMenuClick(index), children: [item.icon && _jsx(Box, { sx: { mr: 2 }, children: item.icon }), _jsx(ListItemText, { primary: _jsx("b", { children: item.name }), secondary: item.description }), _jsx(NavigateNextIcon, { sx: { display: { xs: "block", sm: "none" } } })] }, index))) }) }), _jsx(Grid, { size: { xs: 12, sm: 8, md: 6 }, sx: { display: { xs: selected === null ? 'none' : 'block', sm: 'block' } }, children: _jsx(Box, { component: "div", sx: { p: { xs: 2 }, py: { sm: 3 } }, children: selected !== null ? createElement(menuItems[selected].page, { handleBack: () => { setSelected(null); } }) : "" }) })] }) }) }) }) }) }));
41
+ return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Grid, { container: true, spacing: 2, sx: { width: '100%' }, children: _jsx(Grid, { size: { xs: 12, lg: 9 }, children: _jsx(Card, { sx: { borderRadius: 2 }, children: _jsx(CardContent, { sx: { p: 0, "&:last-child": { p: 0 } }, children: _jsxs(Grid, { container: true, spacing: 2, children: [_jsx(Grid, { size: { xs: 12, sm: 4 }, sx: { display: { xs: selected !== null ? 'none' : 'block', sm: 'block' } }, children: _jsx(List, { sx: { p: 0, height: "100%", backgroundColor: "primary.main" }, children: menuItems.map((item, index) => (_jsxs(ListItemButtonSettings, { selected: selected === index, onClick: () => handleMenuClick(index), children: [item.icon && _jsx(Box, { sx: { mr: 2 }, children: React.isValidElement(item.icon) ? item.icon : null }), _jsx(ListItemText, { primary: _jsx("b", { children: item.name }), secondary: item.description }), _jsx(NavigateNextIcon, { sx: { display: { xs: "block", sm: "none" } } })] }, index))) }) }), _jsx(Grid, { size: { xs: 12, sm: 8, md: 6 }, sx: { display: { xs: selected === null ? 'none' : 'block', sm: 'block' } }, children: _jsx(Box, { component: "div", sx: { p: { xs: 2 }, py: { sm: 3 } }, children: selected !== null ? createElement(menuItems[selected].page, { handleBack: () => { setSelected(null); } }) : "" }) })] }) }) }) }) }) }));
41
42
  };
42
43
  export default DynamicMenu;
@@ -1,11 +1,12 @@
1
1
  import { UserType } from '../../types/user';
2
2
  import { Theme } from '@emotion/react';
3
- declare const UserUpdate: ({ userInfo, handleUpdateUser, container, containerProps, roles, theme }: {
3
+ declare const UserUpdate: ({ userInfo, handleUpdateUser, container, containerProps, roles, theme, t }: {
4
4
  userInfo: UserType;
5
5
  handleUpdateUser: (userId: string, userInfo: Partial<UserType>) => Promise<void>;
6
6
  container?: "Card" | "Box";
7
7
  containerProps?: object | undefined;
8
8
  roles?: string[];
9
9
  theme: Theme;
10
+ t: (key: string, params?: any) => string;
10
11
  }) => import("react/jsx-runtime").JSX.Element;
11
12
  export default UserUpdate;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { Box, Card, CardContent, FormControl, InputLabel, MenuItem, Select, ThemeProvider } from '@mui/material';
4
4
  import { LoadingButton } from '@mui/lab';
5
- const UserUpdate = ({ userInfo, handleUpdateUser, container = 'Box', containerProps = {}, roles = ['customer', 'support', 'admin'], theme }) => {
5
+ const UserUpdate = ({ userInfo, handleUpdateUser, container = 'Box', containerProps = {}, roles = ['customer', 'support', 'admin'], theme, t }) => {
6
6
  const [userRole, setUserRole] = useState(userInfo.role || roles[0]);
7
7
  const [loadingButton, setLoadingButton] = useState(false);
8
8
  const handleChangeRole = (event) => {
@@ -19,7 +19,7 @@ const UserUpdate = ({ userInfo, handleUpdateUser, container = 'Box', containerPr
19
19
  setLoadingButton(false);
20
20
  };
21
21
  const renderUserUpdate = () => {
22
- return (_jsxs(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: [_jsxs(FormControl, { children: [_jsx(InputLabel, { id: "select-role-label", children: "Role" }), _jsx(Select, { labelId: "select-role-label", id: "select-role", value: userRole || '', label: "Role", onChange: handleChangeRole, children: roles.map((role) => (_jsx(MenuItem, { value: role, children: role.charAt(0).toUpperCase() + role.slice(1) }, role))) })] }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingButton, onClick: () => handleUpdate(), children: "Update" }) })] }));
22
+ return (_jsxs(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: [_jsxs(FormControl, { children: [_jsx(InputLabel, { id: "select-role-label", children: t('library.userUpdate.role') }), _jsx(Select, { labelId: "select-role-label", id: "select-role", value: userRole || '', label: t('library.userUpdate.role'), onChange: handleChangeRole, children: roles.map((role) => (_jsx(MenuItem, { value: role, children: role.charAt(0).toUpperCase() + role.slice(1) }, role))) })] }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingButton, onClick: () => handleUpdate(), children: t('library.userUpdate.update') }) })] }));
23
23
  };
24
24
  return _jsx(ThemeProvider, { theme: theme, children: container === "Card" ? (_jsx(Card, { ...containerProps, children: _jsx(CardContent, { sx: { py: 0 }, children: renderUserUpdate() }) })) : (_jsx(Box, { ...containerProps, children: renderUserUpdate() })) });
25
25
  };
@@ -1,7 +1,8 @@
1
+ import { GridSortModel } from '@mui/x-data-grid';
1
2
  import { UserType } from '../../types/user';
2
3
  import { Theme } from '@emotion/react';
3
- declare const UsersDataGrid: ({ handleGetUsersList, pageSize, container, containerProps, props, loadingComponent, theme }: {
4
- handleGetUsersList: ({ page, pageSize, filter }: {
4
+ declare const UsersDataGrid: ({ handleGetUsersList, pageSize, container, containerProps, props, loadingComponent, theme, columns, filterTypes, t, dataGridLocaleText }: {
5
+ handleGetUsersList: ({ page, pageSize, filter, sortModel }: {
5
6
  page: number;
6
7
  pageSize: number;
7
8
  filter?: {
@@ -9,15 +10,22 @@ declare const UsersDataGrid: ({ handleGetUsersList, pageSize, container, contain
9
10
  operator?: string;
10
11
  value: string;
11
12
  };
13
+ sortModel: GridSortModel;
12
14
  }) => Promise<{
13
15
  users: UserType[];
14
16
  rowCount: number;
15
17
  }>;
16
18
  pageSize: number;
17
19
  container?: "Card" | "Box";
18
- containerProps?: object | undefined;
20
+ containerProps?: any;
19
21
  props?: object | undefined;
20
22
  loadingComponent?: React.ReactNode;
21
23
  theme: Theme;
24
+ columns: any[];
25
+ filterTypes?: {
26
+ [key: string]: string;
27
+ };
28
+ t: (key: string, params?: any) => string;
29
+ dataGridLocaleText?: Record<string, string>;
22
30
  }) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null;
23
31
  export default UsersDataGrid;