@iotready/nextjs-components-library 1.0.0-preview38 → 1.0.0-preview39

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.
@@ -1,9 +1,10 @@
1
1
  import { UserType } from '../../types/user';
2
2
  import { Theme } from "@emotion/react";
3
- export default function UserMenuAccount({ userInfo, handleClick, handleSignOut, accountRoute, theme }: {
3
+ export default function UserMenuAccount({ userInfo, handleClick, handleSignOut, accountRoute, theme, t }: {
4
4
  userInfo: UserType;
5
5
  handleClick: () => void;
6
6
  handleSignOut: () => Promise<void>;
7
7
  accountRoute?: string;
8
8
  theme: Theme;
9
+ t: (key: string, params?: any) => string;
9
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import { Box, Typography, IconButton, Menu, MenuItem, Tooltip, Avatar, ListItem,
5
5
  import { Logout, Person } from "@mui/icons-material";
6
6
  import { useRouter } from 'next/navigation';
7
7
  import { ThemeProvider } from '@mui/material/styles';
8
- export default function UserMenuAccount({ userInfo, handleClick, handleSignOut, accountRoute = '/account', theme }) {
8
+ export default function UserMenuAccount({ userInfo, handleClick, handleSignOut, accountRoute = '/account', theme, t }) {
9
9
  const [anchorEl, setAnchorEl] = useState(null);
10
10
  const router = useRouter();
11
11
  const handleAccountClick = (event) => {
@@ -33,5 +33,5 @@ export default function UserMenuAccount({ userInfo, handleClick, handleSignOut,
33
33
  }
34
34
  },
35
35
  }
36
- }, children: [_jsxs(ListItem, { sx: { display: 'flex', alignItems: 'center' }, children: [_jsx(ListItemIcon, { sx: { minWidth: 46 }, children: _jsx(Avatar, {}) }), _jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", children: userInfo.name?.replace('/', ' ') }), _jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 'normal' }, children: userInfo.email })] })] }), _jsxs(MenuItem, { onClick: () => { router.push(accountRoute); handleClick(); handleClose(); }, sx: { py: 1 }, children: [_jsx(ListItemIcon, { sx: { mr: 1 }, children: _jsx(Person, { fontSize: "small" }) }), " Manage account"] }), _jsxs(MenuItem, { onClick: async () => await handleSignOut(), sx: { py: 1 }, children: [_jsx(ListItemIcon, { sx: { mr: 1 }, children: _jsx(Logout, { fontSize: "small" }) }), " Sign Out"] })] }), _jsx(Tooltip, { title: "Open menu", children: _jsx(IconButton, { onClick: handleAccountClick, children: _jsx(Avatar, { sx: { bgcolor: 'secondary.main', color: 'secondary.contrastText' }, alt: userInfo.name !== " " ? userInfo.name : userInfo.email, src: userInfo.picture, children: userInfo.picture ? '' : userInfo.name !== " " ? userInfo.name?.charAt(0).toUpperCase() : userInfo.email?.charAt(0).toUpperCase() }) }) })] }) }));
36
+ }, children: [_jsxs(ListItem, { sx: { display: 'flex', alignItems: 'center' }, children: [_jsx(ListItemIcon, { sx: { minWidth: 46 }, children: _jsx(Avatar, {}) }), _jsxs(Box, { children: [_jsx(Typography, { variant: "subtitle2", children: userInfo.name?.replace('/', ' ') }), _jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 'normal' }, children: userInfo.email })] })] }), _jsxs(MenuItem, { onClick: () => { router.push(accountRoute); handleClick(); handleClose(); }, sx: { py: 1 }, children: [_jsx(ListItemIcon, { sx: { mr: 1 }, children: _jsx(Person, { fontSize: "small" }) }), " ", t('library.accountMenu.manageAccount')] }), _jsxs(MenuItem, { onClick: async () => await handleSignOut(), sx: { py: 1 }, children: [_jsx(ListItemIcon, { sx: { mr: 1 }, children: _jsx(Logout, { fontSize: "small" }) }), " ", t('library.accountMenu.signOut')] })] }), _jsx(Tooltip, { title: t('library.accountMenu.openMenu'), children: _jsx(IconButton, { onClick: handleAccountClick, children: _jsx(Avatar, { sx: { bgcolor: 'secondary.main', color: 'secondary.contrastText' }, alt: userInfo.name !== " " ? userInfo.name : userInfo.email, src: userInfo.picture, children: userInfo.picture ? '' : userInfo.name !== " " ? userInfo.name?.charAt(0).toUpperCase() : userInfo.email?.charAt(0).toUpperCase() }) }) })] }) }));
37
37
  }
@@ -1,6 +1,6 @@
1
1
  import { UserType } from '../../types/user';
2
2
  import { Theme } from "@emotion/react";
3
- declare const AccountProfile: ({ userAccount, handleSignOut, handleUpdateUser, handleUpdatePassword, handleDeleteUser, container, containerProps, theme, afterUpdateCallback, confirmMui }: {
3
+ declare const AccountProfile: ({ userAccount, handleSignOut, handleUpdateUser, handleUpdatePassword, handleDeleteUser, container, containerProps, theme, afterUpdateCallback, confirmMui, t }: {
4
4
  userAccount: UserType;
5
5
  handleSignOut: () => Promise<void>;
6
6
  handleUpdateUser: (id: string, user: Partial<UserType>) => Promise<void>;
@@ -11,5 +11,6 @@ declare const AccountProfile: ({ userAccount, handleSignOut, handleUpdateUser, h
11
11
  theme: Theme;
12
12
  afterUpdateCallback: (user: Partial<UserType>) => void;
13
13
  confirmMui?: (options?: any) => Promise<void>;
14
+ t: (key: string, params?: any) => string;
14
15
  }) => import("react/jsx-runtime").JSX.Element;
15
16
  export default AccountProfile;
@@ -6,7 +6,7 @@ import { LoadingButton } from '@mui/lab';
6
6
  import { VisibilityOff, Visibility, Delete } from '@mui/icons-material';
7
7
  import Grid from '@mui/material/Grid2';
8
8
  import { ThemeProvider } from '@mui/material/styles';
9
- const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUpdatePassword, handleDeleteUser, container = 'Box', containerProps = {}, theme, afterUpdateCallback = () => { }, confirmMui }) => {
9
+ const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUpdatePassword, handleDeleteUser, container = 'Box', containerProps = {}, theme, afterUpdateCallback = () => { }, confirmMui, t }) => {
10
10
  const [userInfo, setUserInfo] = useState(userAccount);
11
11
  const [loadingUdateButton, setLoadingUpdateButton] = useState(false);
12
12
  const [loadingSaveButton, setLoadingSaveButton] = useState(false);
@@ -39,20 +39,20 @@ const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUp
39
39
  };
40
40
  const savePassword = async () => {
41
41
  if (password === "") {
42
- setError('Password is required');
42
+ setError(t('library.accountProfile.passwordRequired'));
43
43
  return;
44
44
  }
45
45
  if (confirmPassword === "") {
46
- setError('Confirm password is required');
46
+ setError(t('library.accountProfile.confirmPasswordRequired'));
47
47
  return;
48
48
  }
49
49
  if (password !== confirmPassword) {
50
- setError('Password and Confirmation password must be the same');
50
+ setError(t('library.accountProfile.passwordsMustMatch'));
51
51
  return;
52
52
  }
53
53
  const passwordRegex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ]).{8,}$/;
54
54
  if (!passwordRegex.test(password)) {
55
- setError(`Password must be longer than 8 characters and must contain 1 uppercase letter (A-Z), 1 lowercase letter (a-z), 1 digit (0-9) e 1 special symbol (!"#$%&'()*+,-./:;<=>?@[\]^_{|}~ ).`);
55
+ setError(t('library.accountProfile.passwordRequirements'));
56
56
  return;
57
57
  }
58
58
  setLoadingSaveButton(true);
@@ -61,7 +61,7 @@ const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUp
61
61
  await handleUpdatePassword(userInfo.id, password);
62
62
  setError("");
63
63
  setShowEditPassword(false);
64
- alert('Password updated');
64
+ alert(t('library.accountProfile.passwordUpdated'));
65
65
  }
66
66
  catch (err) {
67
67
  console.log(err);
@@ -78,7 +78,7 @@ const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUp
78
78
  if (afterUpdateCallback) {
79
79
  afterUpdateCallback(userInfo);
80
80
  }
81
- alert('User updated');
81
+ alert(t('library.accountProfile.userUpdated'));
82
82
  }
83
83
  catch (err) {
84
84
  console.log(err);
@@ -90,10 +90,10 @@ const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUp
90
90
  if (userInfo) {
91
91
  try {
92
92
  if (confirmMui) {
93
- await confirmMui({ description: "Are you sure you want to delete the account?", confirmationText: "Yes, remove", confirmationButtonProps: { variant: 'contained', color: 'error' } });
93
+ await confirmMui({ description: t('library.accountProfile.confirmDeleteAccount'), confirmationText: t('library.accountProfile.yesRemove'), confirmationButtonProps: { variant: 'contained', color: 'error' } });
94
94
  }
95
95
  else {
96
- confirm("Are you sure you want to delete the account?");
96
+ confirm(t('library.accountProfile.confirmDeleteAccount'));
97
97
  }
98
98
  setLoadingDeleteButton(true);
99
99
  await handleDeleteUser(userInfo.id);
@@ -137,17 +137,17 @@ const AccountProfile = ({ userAccount, handleSignOut, handleUpdateUser, handleUp
137
137
  }
138
138
  }*/
139
139
  const renderAccountProfile = (_jsxs(Box, { component: "div", children: [!userInfo.name ?
140
- _jsx(Alert, { severity: "warning", sx: { mb: 2 }, children: "Please complete the informations below" })
141
- : '', _jsx(Grid, { container: true, spacing: 2, children: _jsxs(Grid, { size: { xs: 12, md: 9, lg: 6 }, children: [_jsxs(Box, { component: "div", children: [_jsx(Typography, { variant: "h6", children: "Profile name" }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(TextField, { fullWidth: true, label: "First name", name: "firstname", value: userInfo.firstname, onChange: handleChange, error: !userInfo.firstname || userInfo.firstname === "" ? true : false, helperText: !userInfo.firstname || userInfo.firstname === "" ? "Enter your first name" : '', size: "small" }) }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(TextField, { fullWidth: true, label: "Last name", name: "lastname", value: userInfo.lastname, onChange: handleChange, error: !userInfo.lastname || userInfo.lastname === "" ? true : false, helperText: !userInfo.lastname || userInfo.lastname === "" ? "Enter your last name" : '', size: "small" }) }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingUdateButton, onClick: () => handleUpdate(), disabled: !userInfo.firstname || userInfo.firstname === "" || !userInfo.lastname || userInfo.lastname === "", children: "Update" }) })] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsx(Typography, { variant: "h6", children: "Security" }), !showEditPassword ? _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(Button, { variant: 'outlined', onClick: () => setShowEditPassword(!showEditPassword), children: "Set or edit your password" }) }) : '', showEditPassword ?
142
- _jsxs(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: [_jsx(TextField, { required: true, fullWidth: true, name: "password", label: "New Password", type: showNewPassword ? 'text' : 'password', id: "password", size: 'small', autoComplete: "current-password", onChange: (e) => setPassword(e.target.value), value: password, slotProps: {
140
+ _jsx(Alert, { severity: "warning", sx: { mb: 2 }, children: t('library.accountProfile.completeInfo') })
141
+ : '', _jsx(Grid, { container: true, spacing: 2, children: _jsxs(Grid, { size: { xs: 12, md: 9, lg: 6 }, children: [_jsxs(Box, { component: "div", children: [_jsx(Typography, { variant: "h6", children: t('library.accountProfile.profileName') }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(TextField, { fullWidth: true, label: t('library.accountProfile.firstName'), name: "firstname", value: userInfo.firstname, onChange: handleChange, error: !userInfo.firstname || userInfo.firstname === "" ? true : false, helperText: !userInfo.firstname || userInfo.firstname === "" ? t('library.accountProfile.enterFirstName') : '', size: "small" }) }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(TextField, { fullWidth: true, label: t('library.accountProfile.lastName'), name: "lastname", value: userInfo.lastname, onChange: handleChange, error: !userInfo.lastname || userInfo.lastname === "" ? true : false, helperText: !userInfo.lastname || userInfo.lastname === "" ? t('library.accountProfile.enterLastName') : '', size: "small" }) }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingUdateButton, onClick: () => handleUpdate(), disabled: !userInfo.firstname || userInfo.firstname === "" || !userInfo.lastname || userInfo.lastname === "", children: t('library.accountProfile.update') }) })] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsx(Typography, { variant: "h6", children: t('library.accountProfile.security') }), !showEditPassword ? _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(Button, { variant: 'outlined', onClick: () => setShowEditPassword(!showEditPassword), children: t('library.accountProfile.setOrEditPassword') }) }) : '', showEditPassword ?
142
+ _jsxs(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: [_jsx(TextField, { required: true, fullWidth: true, name: "password", label: t('library.accountProfile.newPassword'), type: showNewPassword ? 'text' : 'password', id: "password", size: 'small', autoComplete: "current-password", onChange: (e) => setPassword(e.target.value), value: password, slotProps: {
143
143
  input: {
144
144
  endAdornment: _jsx(InputAdornment, { position: "end", children: _jsx(IconButton, { "aria-label": "toggle password visibility", onClick: handleClickShowPassword, onMouseDown: handleMouseDownPassword, edge: "end", children: showNewPassword ? _jsx(VisibilityOff, {}) : _jsx(Visibility, {}) }) }),
145
145
  }
146
- } }), _jsx(TextField, { sx: { mt: 2 }, required: true, fullWidth: true, label: "Confirm Password", type: showConfirmPassword ? 'text' : 'password', id: "confirm-password", size: 'small', autoComplete: "confirm-password", onChange: (e) => setConfirmPassword(e.target.value), value: confirmPassword, slotProps: {
146
+ } }), _jsx(TextField, { sx: { mt: 2 }, required: true, fullWidth: true, label: t('library.accountProfile.confirmPassword'), type: showConfirmPassword ? 'text' : 'password', id: "confirm-password", size: 'small', autoComplete: "confirm-password", onChange: (e) => setConfirmPassword(e.target.value), value: confirmPassword, slotProps: {
147
147
  input: {
148
148
  endAdornment: _jsx(InputAdornment, { position: "end", children: _jsx(IconButton, { "aria-label": "toggle password visibility", onClick: handleClickShowConfirmPassword, onMouseDown: handleMouseDownConfirmPassword, edge: "end", children: showConfirmPassword ? _jsx(VisibilityOff, {}) : _jsx(Visibility, {}) }) }),
149
149
  }
150
- } }), error !== '' ? _jsx(Box, { component: 'div', sx: { mt: 1 }, children: _jsx(Typography, { variant: 'subtitle2', color: 'error', children: error }) }) : '', _jsxs(Box, { component: "div", sx: { mt: 3 }, children: [_jsx(Button, { variant: "contained", color: "inherit", onClick: () => setShowEditPassword(false), sx: { mr: 2 }, children: "Cancel" }), _jsx(LoadingButton, { loading: loadingSaveButton, type: "submit", variant: "contained", color: "primary", onClick: () => savePassword(), children: "Save" })] })] }) : ''] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsx(Typography, { variant: 'h6', children: "Delete account" }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", color: "error", loading: loadingDeleteButton, onClick: () => handleDelete(), size: 'small', children: [_jsx(Delete, { fontSize: "small", sx: { mr: 1 } }), " Delete"] }), children: "This action cannot be undone" }) })] })] }, 3) })] }));
150
+ } }), error !== '' ? _jsx(Box, { component: 'div', sx: { mt: 1 }, children: _jsx(Typography, { variant: 'subtitle2', color: 'error', children: error }) }) : '', _jsxs(Box, { component: "div", sx: { mt: 3 }, children: [_jsx(Button, { variant: "contained", color: "inherit", onClick: () => setShowEditPassword(false), sx: { mr: 2 }, children: t('library.accountProfile.cancel') }), _jsx(LoadingButton, { loading: loadingSaveButton, type: "submit", variant: "contained", color: "primary", onClick: () => savePassword(), children: t('library.accountProfile.save') })] })] }) : ''] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsx(Typography, { variant: 'h6', children: t('library.accountProfile.deleteAccount') }), _jsx(Box, { component: "div", sx: { mt: 2, mb: 0 }, children: _jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", color: "error", loading: loadingDeleteButton, onClick: () => handleDelete(), size: 'small', children: [_jsx(Delete, { fontSize: "small", sx: { mr: 1 } }), " ", t('library.accountProfile.deleteAccount')] }), children: t('library.accountProfile.actionCannotBeUndone') }) })] })] }, 3) })] }));
151
151
  return _jsx(ThemeProvider, { theme: theme, children: container === "Card" ? (_jsx(Card, { ...containerProps, children: _jsx(CardContent, { children: renderAccountProfile }) })) : (_jsx(Box, { ...containerProps, children: renderAccountProfile })) });
152
152
  };
153
153
  export default AccountProfile;
@@ -10,7 +10,7 @@ type Measure = {
10
10
  unit: string;
11
11
  stepped: boolean;
12
12
  };
13
- declare const TrendChart: ({ filter, measures1, annotationsDataFn, measures2, enableDatePicker, handleGetInfluxData, handleGetDwSlotsCB, handleExportDataCB, theme, initialTimeStart, initialTimeEnd }: {
13
+ declare const TrendChart: ({ filter, measures1, annotationsDataFn, measures2, enableDatePicker, handleGetInfluxData, handleGetDwSlotsCB, handleExportDataCB, theme, initialTimeStart, initialTimeEnd, t }: {
14
14
  filter: {
15
15
  field: string;
16
16
  value: string;
@@ -34,5 +34,6 @@ declare const TrendChart: ({ filter, measures1, annotationsDataFn, measures2, en
34
34
  theme: Theme;
35
35
  initialTimeStart?: number;
36
36
  initialTimeEnd?: number;
37
+ t: (key: string, params?: any) => string;
37
38
  }) => import("react/jsx-runtime").JSX.Element;
38
39
  export default TrendChart;
@@ -330,7 +330,7 @@ function getCsvData(data, measures) {
330
330
  .join('\n');
331
331
  }
332
332
  // eslint-disable-next-line no-unused-vars
333
- const TrendChart = ({ filter, measures1, annotationsDataFn, measures2, enableDatePicker, handleGetInfluxData, handleGetDwSlotsCB, handleExportDataCB, theme, initialTimeStart, initialTimeEnd }) => {
333
+ const TrendChart = ({ filter, measures1, annotationsDataFn, measures2, enableDatePicker, handleGetInfluxData, handleGetDwSlotsCB, handleExportDataCB, theme, initialTimeStart, initialTimeEnd, t }) => {
334
334
  const [chartJsLoaded, setChartJsLoaded] = useState(false);
335
335
  // Dichiarazione di annotationsData come funzione che ritorna una Promise<any>
336
336
  const [annotationsData, setAnnotationsData] = useState(null);
@@ -804,7 +804,7 @@ const TrendChart = ({ filter, measures1, annotationsDataFn, measures2, enableDat
804
804
  ":hover": { backgroundColor: 'action.hover' },
805
805
  ml: enableDatePicker ? 1 : 0,
806
806
  p: 0.85
807
- }, onClick: () => shiftChart('timeEnd'), children: _jsx(KeyboardArrowRightIcon, {}) })] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center' }, children: [!enableExportData && measures && measures.length === 1 ? _jsx(Typography, { variant: 'body1', sx: { mr: 2 }, children: measures[0].description || measures[0].name }) : '', enableExportData && (_jsxs(_Fragment, { children: [_jsxs(LoadingButton, { sx: { minWidth: '40px !important', mr: 1, px: 1 }, loading: loadingButton, type: "submit", variant: "text", color: "primary", onClick: handleExportData, disabled: !dataMeasures || !dataMeasures.length, size: 'small', children: [_jsx(LoginIcon, { fontSize: 'small', style: { transform: "rotate(90deg)" } }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: "Export" })] }), _jsx(CSVLink
807
+ }, onClick: () => shiftChart('timeEnd'), children: _jsx(KeyboardArrowRightIcon, {}) })] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center' }, children: [!enableExportData && measures && measures.length === 1 ? _jsx(Typography, { variant: 'body1', sx: { mr: 2 }, children: measures[0].description || measures[0].name }) : '', enableExportData && (_jsxs(_Fragment, { children: [_jsxs(LoadingButton, { sx: { minWidth: '40px !important', mr: 1, px: 1 }, loading: loadingButton, type: "submit", variant: "text", color: "primary", onClick: handleExportData, disabled: !dataMeasures || !dataMeasures.length, size: 'small', children: [_jsx(LoginIcon, { fontSize: 'small', style: { transform: "rotate(90deg)" } }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: t('library.trendChart.export') })] }), _jsx(CSVLink
808
808
  //@ts-ignore
809
809
  , {
810
810
  //@ts-ignore
@@ -850,7 +850,7 @@ const TrendChart = ({ filter, measures1, annotationsDataFn, measures2, enableDat
850
850
  '& .MuiToggleButton-root': {
851
851
  color: 'text.primary', fontSize: '0.95rem', fontWeight: 'normal', paddingTop: '6px', paddingBottom: '6px'
852
852
  }
853
- }, disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 1 }, children: _jsx(TimelineIcon, {}) }) }) }), annotationsDataFn && annotationsData !== null && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: "Show annotations", children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: annotationsEnabled, disabled: chartLoading, onChange: () => setAnnotationsEnabled(!annotationsEnabled), sx: { ml: 1 }, children: _jsx(EditNoteIcon, {}) }) }) }))] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { mt: 2, height: '100%' }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
853
+ }, disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: t('library.trendChart.connectPointValues'), children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 1 }, children: _jsx(TimelineIcon, {}) }) }) }), annotationsDataFn && annotationsData !== null && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: t('library.trendChart.showAnnotations'), children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: annotationsEnabled, disabled: chartLoading, onChange: () => setAnnotationsEnabled(!annotationsEnabled), sx: { ml: 1 }, children: _jsx(EditNoteIcon, {}) }) }) }))] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { mt: 2, height: '100%' }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
854
854
  _jsx(_Fragment, { children: dataMeasures && (dataMeasures.length > 1 || (dataMeasures.length === 1 && dataMeasures[0].data?.length)) ?
855
855
  (_jsx(Line, { options: options, data: {
856
856
  // datasets: dataMeasures || [{ data: [] }]
@@ -862,7 +862,7 @@ const TrendChart = ({ filter, measures1, annotationsDataFn, measures2, enableDat
862
862
  justifyContent: 'center',
863
863
  textAlign: 'center',
864
864
  height: '100%',
865
- }, children: [_jsx(SearchOffOutlinedIcon, { sx: { fontSize: 50, color: 'grey.500', mb: 2 } }), _jsx(Typography, { variant: "body1", color: "textSecondary", align: "center", children: "No data measure" })] }) }) : (_jsx(Box, { sx: {
865
+ }, children: [_jsx(SearchOffOutlinedIcon, { sx: { fontSize: 50, color: 'grey.500', mb: 2 } }), _jsx(Typography, { variant: "body1", color: "textSecondary", align: "center", children: t('library.trendChart.noDataMeasure') })] }) }) : (_jsx(Box, { sx: {
866
866
  display: 'flex',
867
867
  flexDirection: 'column',
868
868
  alignItems: 'center',
@@ -1,5 +1,5 @@
1
1
  import { AssetType, TrackleDeviceType, UserType } from '../../types';
2
- declare const GroupUpdate: ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, devicesList, userInfo, handleAddUserToGroup, handleGetGroups, handleRemoveUserFromGroup, handleUpdateGroup, handleDeleteGroup, container, containerProps, afterUpdateCallback, afterRemoveCallback, confirmMui }: {
2
+ declare const GroupUpdate: ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, devicesList, userInfo, handleAddUserToGroup, handleGetGroups, handleRemoveUserFromGroup, handleUpdateGroup, handleDeleteGroup, container, containerProps, afterUpdateCallback, afterRemoveCallback, confirmMui, t }: {
3
3
  groupInfo: any;
4
4
  usersGroup: any[];
5
5
  usersList: any[];
@@ -18,5 +18,6 @@ declare const GroupUpdate: ({ isOrg, labelEntity, groupInfo, usersGroup, usersLi
18
18
  labelEntity: string;
19
19
  isOrg: boolean;
20
20
  userInfo: UserType;
21
+ t: (key: string, params?: any) => string;
21
22
  }) => import("react/jsx-runtime").JSX.Element;
22
23
  export default GroupUpdate;
@@ -8,7 +8,7 @@ import AddIcon from '@mui/icons-material/Add';
8
8
  import CloseIcon from '@mui/icons-material/Close';
9
9
  import DeleteIcon from '@mui/icons-material/Delete';
10
10
  import { LoadingButton } from '@mui/lab';
11
- const GroupUpdate = ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, devicesList, userInfo, handleAddUserToGroup, handleGetGroups, handleRemoveUserFromGroup, handleUpdateGroup, handleDeleteGroup, container = 'Box', containerProps = {}, afterUpdateCallback, afterRemoveCallback, confirmMui }) => {
11
+ const GroupUpdate = ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, devicesList, userInfo, handleAddUserToGroup, handleGetGroups, handleRemoveUserFromGroup, handleUpdateGroup, handleDeleteGroup, container = 'Box', containerProps = {}, afterUpdateCallback, afterRemoveCallback, confirmMui, t }) => {
12
12
  const [group, setGroup] = useState(groupInfo);
13
13
  const [organizationsGroup, setOrganizationsGroup] = useState(null);
14
14
  const [loadingUpdateButton, setLoadingUpdateButton] = useState(false);
@@ -75,10 +75,10 @@ const GroupUpdate = ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, dev
75
75
  const deleteGroup = async () => {
76
76
  try {
77
77
  if (confirmMui) {
78
- await confirmMui({ description: "Are you sure you want to delete the group?", confirmationText: "Yes, remove it", confirmationButtonProps: { variant: 'contained', color: 'error' } });
78
+ await confirmMui({ description: t('library.groupUpdate.confirmDeleteGroup', { entity: labelEntity.toLowerCase() }), confirmationText: t('library.groupUpdate.yesRemoveIt'), confirmationButtonProps: { variant: 'contained', color: 'error' } });
79
79
  }
80
80
  else {
81
- confirm("Are you sure you want to delete the group?");
81
+ confirm(t('library.groupUpdate.confirmDeleteGroup', { entity: labelEntity.toLowerCase() }));
82
82
  }
83
83
  setLoadingDeleteGroupButton(true);
84
84
  await handleDeleteGroup(group.id, isOrg);
@@ -106,11 +106,11 @@ const GroupUpdate = ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, dev
106
106
  getInitialData();
107
107
  }, []);
108
108
  const renderGroupUpdate = () => {
109
- return (_jsxs(Box, { component: "div", children: [_jsx(Grid, { container: true, spacing: 2, children: _jsx(Grid, { size: { xs: 12, md: 8 }, children: _jsxs(Box, { component: "div", children: [_jsx(FormControl, { fullWidth: true, children: _jsx(TextField, { sx: { flexGrow: 1 }, label: "Name", value: group.name, name: "name", onChange: handleChange }) }), _jsx(FormControl, { fullWidth: true, sx: { mt: 2 }, children: _jsx(TextField, { sx: { flexGrow: 1 }, label: "Description", value: group.description, name: "description", multiline: true, rows: 4, onChange: handleChange }) }), _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingUpdateButton, sx: { mt: 2 }, onClick: () => updateGroup(), children: "Update" })] }) }) }), _jsx(Grid, { container: true, spacing: 2, sx: { mt: 4 }, children: _jsxs(Grid, { size: { xs: 12, md: 8 }, children: [_jsx(Typography, { variant: 'body1', sx: { fontWeight: 'bold' }, children: "Add members" }), _jsx(Box, { component: "div", sx: { mt: 2 }, children: usersGroup && usersGroup.length > 0 ?
109
+ return (_jsxs(Box, { component: "div", children: [_jsx(Grid, { container: true, spacing: 2, children: _jsx(Grid, { size: { xs: 12, md: 8 }, children: _jsxs(Box, { component: "div", children: [_jsx(FormControl, { fullWidth: true, children: _jsx(TextField, { sx: { flexGrow: 1 }, label: t('library.groupUpdate.name'), value: group.name, name: "name", onChange: handleChange }) }), _jsx(FormControl, { fullWidth: true, sx: { mt: 2 }, children: _jsx(TextField, { sx: { flexGrow: 1 }, label: t('library.groupUpdate.description'), value: group.description, name: "description", multiline: true, rows: 4, onChange: handleChange }) }), _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingUpdateButton, sx: { mt: 2 }, onClick: () => updateGroup(), children: t('library.groupUpdate.update') })] }) }) }), _jsx(Grid, { container: true, spacing: 2, sx: { mt: 4 }, children: _jsxs(Grid, { size: { xs: 12, md: 8 }, children: [_jsx(Typography, { variant: 'body1', sx: { fontWeight: 'bold' }, children: t('library.groupUpdate.addMembers') }), _jsx(Box, { component: "div", sx: { mt: 2 }, children: usersGroup && usersGroup.length > 0 ?
110
110
  _jsx(Table, { size: "small", children: _jsx(TableBody, { children: usersGroup.map((ug) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Typography, { variant: "body1", children: ug.user.fullName }) }), _jsx(TableCell, { align: 'right', children: _jsx(LoadingButton, { size: "small", color: "error", loading: loadingRemoveUserButton, onClick: () => removeUserFromCurrentGroup(ug.user.userId), children: _jsx(CloseIcon, { sx: { m: 0, p: 0 }, fontSize: "small" }) }) })] }, ug.id))) }) })
111
- : _jsx(Box, { component: 'div', sx: { mt: 2 }, children: "No members found" }) }), _jsxs(Box, { component: "div", sx: { mt: 4, display: 'flex', alignItems: 'center' }, children: [_jsx(Autocomplete, { fullWidth: true, disablePortal: true, options: usersList || [], value: selectedUser, size: 'small', onChange: (event, newValue) => {
111
+ : _jsx(Box, { component: 'div', sx: { mt: 2 }, children: t('library.groupUpdate.noMembersFound') }) }), _jsxs(Box, { component: "div", sx: { mt: 4, display: 'flex', alignItems: 'center' }, children: [_jsx(Autocomplete, { fullWidth: true, disablePortal: true, options: usersList || [], value: selectedUser, size: 'small', onChange: (event, newValue) => {
112
112
  setSelectedUser(newValue);
113
- }, renderInput: (params) => _jsx(TextField, { ...params, label: "Select user" }) }), _jsxs(LoadingButton, { variant: "contained", color: "primary", loading: loadingAddUserButton, sx: { ml: 2 }, disabled: !selectedUser, onClick: () => addUserToCurrentGroup(), children: [_jsx(AddIcon, { sx: { mr: 1 } }), " Add"] })] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsxs(Typography, { variant: 'body1', sx: { fontWeight: 'bold' }, children: ["Delete ", labelEntity.toLocaleLowerCase()] }), !isOrg ? (_jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", disabled: devicesList.length > 0 || usersGroup.length > 0, color: "error", loading: loadingDeleteGroupButton, onClick: () => deleteGroup(), size: 'small', children: [_jsx(DeleteIcon, { fontSize: "small", sx: { mr: 1 } }), " Delete"] }), children: devicesList.length === 0 && usersGroup.length === 0 ? `This action cannot be undone` : `You must manually remove devices and members from ${labelEntity.toLocaleLowerCase()} before deletion` })) : organizationsGroup && (_jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", disabled: devicesList.length > 0 || usersGroup.length > 0 || organizationsGroup.length > 0, color: "error", loading: loadingDeleteGroupButton, onClick: () => deleteGroup(), size: 'small', children: [_jsx(DeleteIcon, { fontSize: "small", sx: { mr: 1 } }), " Delete"] }), children: devicesList.length === 0 && usersGroup.length === 0 && organizationsGroup.length === 0 ? `This action cannot be undone` : `You must manually remove devices, members and groups from ${labelEntity.toLocaleLowerCase()} before deletion` }))] })] }) })] }));
113
+ }, renderInput: (params) => _jsx(TextField, { ...params, label: t('library.groupUpdate.selectUser') }) }), _jsxs(LoadingButton, { variant: "contained", color: "primary", loading: loadingAddUserButton, sx: { ml: 2 }, disabled: !selectedUser, onClick: () => addUserToCurrentGroup(), children: [_jsx(AddIcon, { sx: { mr: 1 } }), " ", t('library.groupUpdate.add')] })] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsx(Typography, { variant: 'body1', sx: { fontWeight: 'bold' }, children: t('library.groupUpdate.deleteGroup', { entity: labelEntity.toLowerCase() }) }), !isOrg ? (_jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", disabled: devicesList.length > 0 || usersGroup.length > 0, color: "error", loading: loadingDeleteGroupButton, onClick: () => deleteGroup(), size: 'small', children: [_jsx(DeleteIcon, { fontSize: "small", sx: { mr: 1 } }), " ", t('library.groupUpdate.deleteGroup', { entity: labelEntity.toLowerCase() })] }), children: devicesList.length === 0 && usersGroup.length === 0 ? t('library.groupUpdate.actionCannotBeUndone') : t('library.groupUpdate.mustRemoveDevicesAndMembers', { entity: labelEntity.toLowerCase() }) })) : organizationsGroup && (_jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", disabled: devicesList.length > 0 || usersGroup.length > 0 || organizationsGroup.length > 0, color: "error", loading: loadingDeleteGroupButton, onClick: () => deleteGroup(), size: 'small', children: [_jsx(DeleteIcon, { fontSize: "small", sx: { mr: 1 } }), " ", t('library.groupUpdate.deleteGroup', { entity: labelEntity.toLowerCase() })] }), children: devicesList.length === 0 && usersGroup.length === 0 && organizationsGroup.length === 0 ? t('library.groupUpdate.actionCannotBeUndone') : t('library.groupUpdate.mustRemoveDevicesMembersAndGroups', { entity: labelEntity.toLowerCase() }) }))] })] }) })] }));
114
114
  };
115
115
  return (container === "Card" ? (_jsx(Card, { ...containerProps, children: _jsx(CardContent, { children: renderGroupUpdate() }) })) : (_jsx(Box, { ...containerProps, children: renderGroupUpdate() })));
116
116
  };
@@ -1,6 +1,6 @@
1
1
  import { Theme } from "@emotion/react";
2
2
  import { UserType, AssetType, DevicePositionType, TrackleDeviceType } from "../../types";
3
- declare const GroupsDevices: ({ userInfo, handleGetUsersList, handleAddUserToGroup, handleRemoveUserFromGroup, handleGetGroups, handleGetUsersGroup, handleGetDevices, handleUpdateDevice, handleGetPositions, handleAddDevicesToGroup, handleRemoveDevicesFromGroup, handleCreateGroup, handleDeleteGroup, handleUpdateGroup, group, columnsArray, containerDataGrid, props, propsDatagrid, loadingComponent, containerProps, enableMaps, mapsHeight, mapsClickCallback, theme, confirmMui, propsHeaderGroups, forceGetDevices, customToolbar, groupsLabelAll, addDevicesLabel, noDevicesLabel, groupUpdateRoles, isOrg, currentOrg }: {
3
+ declare const GroupsDevices: ({ userInfo, handleGetUsersList, handleAddUserToGroup, handleRemoveUserFromGroup, handleGetGroups, handleGetUsersGroup, handleGetDevices, handleUpdateDevice, handleGetPositions, handleAddDevicesToGroup, handleRemoveDevicesFromGroup, handleCreateGroup, handleDeleteGroup, handleUpdateGroup, group, columnsArray, containerDataGrid, props, propsDatagrid, loadingComponent, containerProps, enableMaps, mapsHeight, mapsClickCallback, theme, confirmMui, propsHeaderGroups, forceGetDevices, customToolbar, groupsLabelAll, addDevicesLabel, noDevicesLabel, groupUpdateRoles, isOrg, currentOrg, t, dataGridLocaleText }: {
4
4
  userInfo: UserType;
5
5
  handleGetUsersList: () => Promise<UserType[]>;
6
6
  handleAddUserToGroup: (groupID: string, userName: string, userID: string) => Promise<any>;
@@ -36,5 +36,7 @@ declare const GroupsDevices: ({ userInfo, handleGetUsersList, handleAddUserToGro
36
36
  groupUpdateRoles?: string[];
37
37
  isOrg?: boolean;
38
38
  currentOrg?: string;
39
+ t: (key: string, params?: any) => string;
40
+ dataGridLocaleText?: Record<string, string>;
39
41
  }) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null;
40
42
  export default GroupsDevices;
@@ -15,7 +15,7 @@ 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, propsHeaderGroups, forceGetDevices = 0, customToolbar, groupsLabelAll, addDevicesLabel, noDevicesLabel, groupUpdateRoles, isOrg = false, currentOrg }) => {
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
19
  const [devices, setDevices] = useState([]);
20
20
  const [positions, setPositions] = useState([]);
21
21
  const [loadingDevices, setLoadingDevices] = useState(false);
@@ -37,11 +37,12 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
37
37
  const [groupUpdateVisible, setGroupUpdateVisible] = useState(false);
38
38
  const [valueTab, setValueTab] = useState('1');
39
39
  const clickedIdRef = useRef(null);
40
- const labelEntity = isOrg ? "Organization" : "Group";
40
+ const labelEntity = isOrg ? t('library.groupsDevices.organization') : t('library.groupsDevices.group');
41
+ const labelEntityLower = labelEntity.toLowerCase();
41
42
  const handleChangeTab = (event, newValue) => {
42
43
  setValueTab(newValue);
43
44
  };
44
- const Map = useMemo(() => dynamic(() => import("./Map"), {
45
+ const MapComponent = useMemo(() => dynamic(() => import("./Map"), {
45
46
  loading: () => isValidElement(loadingComponent) ? cloneElement(loadingComponent, { height: mapsHeight }) : null,
46
47
  ssr: false
47
48
  }), []);
@@ -212,7 +213,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
212
213
  setEditGroup(!editGroup);
213
214
  setCheckboxSelection(!checkboxSelection);
214
215
  };
215
- const renderMaps = (_jsx(Map, { positions: positions, mapsClickCallback: mapsClickCallback, height: mapsHeight }));
216
+ const renderMaps = (_jsx(MapComponent, { positions: positions, mapsClickCallback: mapsClickCallback, height: mapsHeight, t: t }));
216
217
  useEffect(() => {
217
218
  if (devicesToAdd.length <= 0) {
218
219
  setDeviceSelectedObjs([]);
@@ -223,7 +224,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
223
224
  : '', customToolbar && customToolbar.includes('export') ?
224
225
  _jsx(GridToolbarExport, {})
225
226
  : ''] }), customToolbar && customToolbar.includes('quickfilter') && _jsx(GridToolbarQuickFilter, {})] })), []);
226
- const renderDataGrid = (_jsx("div", { style: { display: 'flex', flexDirection: 'column', minHeight: 323 }, children: _jsx(DataGrid, { checkboxSelection: checkboxSelection,
227
+ const renderDataGrid = (_jsx("div", { style: { display: 'flex', flexDirection: 'column', minHeight: 323 }, children: _jsx(DataGrid, { checkboxSelection: checkboxSelection, localeText: dataGridLocaleText,
227
228
  // Se siamo in modalità aggiunta, includi gli ID già nel gruppo
228
229
  rowSelectionModel: (checkboxSelection && currentGroup === 'all')
229
230
  ? [
@@ -303,9 +304,9 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
303
304
  ? columnsArray.filter(col => col.field !== 'id')
304
305
  : columnsArray, slots: {
305
306
  noRowsOverlay: () => (_jsx(Stack, { height: "100%", alignItems: "center", justifyContent: "center", children: currentGroup !== 'all'
306
- ? (_jsxs(_Fragment, { children: [_jsxs(Box, { children: [noDevicesLabel || 'No devices', " in ", labelEntity.toLocaleLowerCase()] }), editGroup && (_jsxs(Button, { onClick: addDevicesToCurrentGroup, variant: "outlined", color: "primary", size: "small", sx: { mt: 2 }, children: [_jsx(PlaylistAddIcon, { fontSize: "small", sx: { mr: 1 } }), addDevicesLabel || 'Add devices'] }))] }))
307
- : noDevicesLabel || 'No devices' })),
308
- noResultsOverlay: () => (_jsx(Stack, { height: "100%", alignItems: "center", justifyContent: "center", children: "Filter returns no result" })),
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') })),
309
310
  toolbar: customToolbar && customToolbar.length ? CustomToolbar : GridToolbar,
310
311
  }, slotProps: {
311
312
  toolbar: {
@@ -316,7 +317,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
316
317
  }, initialState: {
317
318
  pagination: { paginationModel: { pageSize: 100 } },
318
319
  }, ...propsDatagrid }) }));
319
- 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 })] }));
320
321
  const renderDatagridAndMaps = (enableMaps ?
321
322
  containerDataGrid === 'Card' ?
322
323
  _jsx(Card, { ...containerProps, children: renderTabContext }) : _jsx(Box, { ...containerProps, children: renderTabContext }) : containerDataGrid === 'Card' ?
@@ -324,30 +325,30 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
324
325
  if (!userInfo || !groups || !devices)
325
326
  return loadingComponent;
326
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') ?
327
- _jsx(Autocomplete, { disablePortal: true, onChange: handleChangeGroupSelect, value: groupInfo?.name || groupsLabelAll || 'All devices', disableClearable: currentGroup === 'all', isOptionEqualToValue: (o, v) => o.label === v, options: [{ label: groupsLabelAll || '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: labelEntity }) })
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 }) })
328
329
  : '', (userInfo.role === 'admin' || (groupUpdateRoles && groupUpdateRoles.includes(userInfo.role))) &&
329
330
  _jsxs(Box, { sx: { ml: 2 }, children: [checkboxSelection ?
330
331
  _jsx(Input, { value: selectedGroup, type: 'hidden', size: 'small' })
331
- : '', 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: "Create\u00A0" }), " ", labelEntity.toLocaleLowerCase()] }) : '', 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 ?
332
333
  currentGroup === 'all' ?
333
- 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: ["\u00A0Back to ", labelEntity.toLocaleLowerCase()] })] }), _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"] })] }) : ''
334
- : 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: ["\u00A0Back to ", labelEntity.toLocaleLowerCase()] })] }) :
335
- _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 || 'Add devices'] }), _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: ["\u00A0Manage ", labelEntity.toLocaleLowerCase()] })] })] })
336
- : _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 ", labelEntity.toLocaleLowerCase()] })
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 })] })
337
338
  : '', selectedGroup !== 'all' && !isOrg ?
338
339
  _jsx(_Fragment, { children: editGroup ?
339
- _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" })] })
340
- : _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" }), " ", labelEntity.toLocaleLowerCase()] }) }) : ''] })] }), _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: {
341
342
  position: 'absolute',
342
343
  top: '50%',
343
344
  left: '50%',
344
345
  transform: 'translate(-50%, -50%)',
345
346
  width: 400,
346
347
  borderRadius: 4
347
- }, children: [_jsx(CardHeader, { title: "New " + labelEntity, action: _jsx(IconButton, { onClick: handleCloseAdd, children: _jsx(CloseIcon, {}) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TextField, { fullWidth: true, label: labelEntity + " 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, { 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) {
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) {
348
349
  closeEditGroup();
349
350
  setCurrentGroup('all');
350
351
  await getGroups();
351
- } }, container: 'Card', handleDeleteGroup: handleDeleteGroup, handleUpdateGroup: handleUpdateGroup, devicesList: devices, labelEntity: labelEntity, isOrg: isOrg })] }) }));
352
+ } }, container: 'Card', handleDeleteGroup: handleDeleteGroup, handleUpdateGroup: handleUpdateGroup, devicesList: devices, labelEntity: labelEntity, isOrg: isOrg, t: t })] }) }));
352
353
  };
353
354
  export default GroupsDevices;
@@ -2,8 +2,9 @@ import 'leaflet/dist/leaflet.css';
2
2
  import "leaflet-defaulticon-compatibility";
3
3
  import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css";
4
4
  import { DevicePositionType } from "../../types/device";
5
- export default function Map({ positions, height, mapsClickCallback }: {
5
+ export default function Map({ positions, height, mapsClickCallback, t }: {
6
6
  positions: DevicePositionType[];
7
7
  height: string;
8
8
  mapsClickCallback: (position: DevicePositionType) => void;
9
+ t: (key: string, params?: any) => string;
9
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,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,7 @@
1
1
  import { GridSortModel } from '@mui/x-data-grid';
2
2
  import { UserType } from '../../types/user';
3
3
  import { Theme } from '@emotion/react';
4
- declare const UsersDataGrid: ({ handleGetUsersList, pageSize, container, containerProps, props, loadingComponent, theme, columns }: {
4
+ declare const UsersDataGrid: ({ handleGetUsersList, pageSize, container, containerProps, props, loadingComponent, theme, columns, filterTypes, t, dataGridLocaleText }: {
5
5
  handleGetUsersList: ({ page, pageSize, filter, sortModel }: {
6
6
  page: number;
7
7
  pageSize: number;
@@ -22,5 +22,10 @@ declare const UsersDataGrid: ({ handleGetUsersList, pageSize, container, contain
22
22
  loadingComponent?: React.ReactNode;
23
23
  theme: Theme;
24
24
  columns: any[];
25
+ filterTypes?: {
26
+ [key: string]: string;
27
+ };
28
+ t: (key: string, params?: any) => string;
29
+ dataGridLocaleText?: Record<string, string>;
25
30
  }) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null;
26
31
  export default UsersDataGrid;
@@ -4,13 +4,13 @@ import { DataGrid, GridLogicOperator, GridToolbarExport } from '@mui/x-data-grid
4
4
  import { Card, Box, CircularProgress, ThemeProvider, FormControl, IconButton, InputLabel, MenuItem, Select, TextField } from '@mui/material';
5
5
  import { ClearIcon } from "@mui/x-date-pickers";
6
6
  import debounce from 'lodash.debounce';
7
- const UsersDataGrid = ({ handleGetUsersList, pageSize, container = 'Box', containerProps = {}, props = {}, loadingComponent = _jsx(CircularProgress, {}), theme, columns }) => {
7
+ const UsersDataGrid = ({ handleGetUsersList, pageSize, container = 'Box', containerProps = {}, props = {}, loadingComponent = _jsx(CircularProgress, {}), theme, columns, filterTypes, t, dataGridLocaleText }) => {
8
8
  const [usersList, setUsersList] = useState(undefined);
9
9
  const [userCount, setUserCount] = useState(undefined);
10
- const filterType = {
11
- email: 'Email Address',
12
- name: 'Full name',
13
- role: 'Role'
10
+ const filterType = filterTypes || {
11
+ email: t('library.usersDataGrid.emailAddress'),
12
+ name: t('library.usersDataGrid.fullName'),
13
+ role: t('library.usersDataGrid.role')
14
14
  };
15
15
  const [selectedFilterValue, setSelectedFilterValue] = useState(undefined);
16
16
  const [selectedFilterType, setSelectedFilterType] = useState('email');
@@ -77,7 +77,7 @@ const UsersDataGrid = ({ handleGetUsersList, pageSize, container = 'Box', contai
77
77
  setPaginationModel(prev => ({ ...prev, page: 0 }));
78
78
  };
79
79
  const CustomToolbar = () => (_jsx(Box, { sx: { display: 'flex', alignItems: 'center', p: 1, justifyContent: 'space-between' }, children: _jsx(GridToolbarExport, {}) }));
80
- const renderUsersList = () => (_jsx("div", { style: { display: 'flex', flexDirection: 'column', minHeight: 323 }, children: _jsx(DataGrid, { disableDensitySelector: true, disableColumnSelector: true, disableRowSelectionOnClick: true, onSortModelChange: handleSortModelChange, disableColumnResize: true, columns: columns, rows: usersList, slots: {
80
+ const renderUsersList = () => (_jsx("div", { style: { display: 'flex', flexDirection: 'column', minHeight: 323 }, children: _jsx(DataGrid, { disableDensitySelector: true, disableColumnSelector: true, disableRowSelectionOnClick: true, onSortModelChange: handleSortModelChange, disableColumnResize: true, columns: columns, rows: usersList, localeText: dataGridLocaleText, slots: {
81
81
  toolbar: CustomToolbar,
82
82
  }, slotProps: {
83
83
  toolbar: {
@@ -85,7 +85,7 @@ const UsersDataGrid = ({ handleGetUsersList, pageSize, container = 'Box', contai
85
85
  showQuickFilter: false,
86
86
  },
87
87
  }, rowCount: userCount, loading: isLoading, pageSizeOptions: [], paginationModel: paginationModel, paginationMode: "server", onPaginationModelChange: setPaginationModel, ...props }) }));
88
- const renderFilter = () => (_jsxs(Box, { sx: { position: "absolute", top: 10, right: 10, zIndex: 1 }, children: [_jsxs(FormControl, { children: [_jsx(InputLabel, { shrink: true, id: "filter-by-select-label", children: "Filter by" }), _jsx(Select, { value: selectedFilterType || '', onChange: (e) => setSelectedFilterType(e.target.value), labelId: "filter-by-select-label", label: "Filter by", size: "small", sx: { mr: 2 }, children: Object.entries(filterType).map(([key, label]) => (_jsx(MenuItem, { value: key, children: label }, key))) })] }), _jsx(TextField, { value: selectedFilterValue || "", onChange: (e) => handleFilterModelChange(e.target.value), placeholder: "Search...", size: "small", InputProps: {
88
+ const renderFilter = () => (_jsxs(Box, { sx: { position: "absolute", top: 10, right: 10, zIndex: 1 }, children: [_jsxs(FormControl, { children: [_jsx(InputLabel, { shrink: true, id: "filter-by-select-label", children: t('library.usersDataGrid.filterBy') }), _jsx(Select, { value: selectedFilterType || '', onChange: (e) => setSelectedFilterType(e.target.value), labelId: "filter-by-select-label", label: t('library.usersDataGrid.filterBy'), size: "small", sx: { mr: 2 }, children: Object.entries(filterType).map(([key, label]) => (_jsx(MenuItem, { value: key, children: label }, key))) })] }), _jsx(TextField, { value: selectedFilterValue || "", onChange: (e) => handleFilterModelChange(e.target.value), placeholder: t('library.usersDataGrid.search'), size: "small", InputProps: {
89
89
  endAdornment: selectedFilterValue ? (_jsx(IconButton, { size: "small", onClick: () => handleFilterModelChange(""), children: _jsx(ClearIcon, { fontSize: "small" }) })) : null,
90
90
  } })] }));
91
91
  return _jsx(ThemeProvider, { theme: theme, children: container === "Card" ? (_jsx(_Fragment, { children: _jsxs(Card, { ...containerProps, sx: { position: 'relative', ...(containerProps?.sx) }, children: [renderFilter(), renderUsersList()] }) })) : (_jsxs(_Fragment, { children: [renderFilter(), _jsxs(Box, { ...containerProps, sx: { position: 'relative', ...(containerProps?.sx) }, children: [renderFilter(), renderUsersList()] })] })) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iotready/nextjs-components-library",
3
- "version": "1.0.0-preview38",
3
+ "version": "1.0.0-preview39",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc --project tsconfig.build.json && cp package.json dist/",
@@ -20,6 +20,7 @@
20
20
  "chartjs-plugin-annotation": "^3.1.0",
21
21
  "chartjs-plugin-zoom": "^2.0.1",
22
22
  "csv-parse": "^5.6.0",
23
+ "exceljs": "^4.4.0",
23
24
  "firebase-admin": "^13.4.0",
24
25
  "leaflet": "^1.9.4",
25
26
  "leaflet-defaulticon-compatibility": "^0.1.2",