@applica-software-guru/react-admin 1.5.325 → 1.5.327

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.
package/package.json CHANGED
@@ -107,5 +107,5 @@
107
107
  "type": "module",
108
108
  "types": "dist/index.d.ts",
109
109
  "typings": "dist/index.d.ts",
110
- "version": "1.5.325"
110
+ "version": "1.5.327"
111
111
  }
@@ -3,6 +3,7 @@ import { IconButton, Transitions } from '@/components/@extended';
3
3
  import { HeaderToggleButton } from '@/components/Layout/Header/Buttons';
4
4
  import { useLayoutMediaState, useLayoutNotificationsState } from '@/components/Layout/Provider';
5
5
  import { MainCard } from '@/components/MainCard';
6
+ import { Empty } from '@/components/ra-lists';
6
7
  import { usePopoverState } from '@/hooks';
7
8
  import { BellOutlined, CheckCircleOutlined } from '@ant-design/icons';
8
9
  import {
@@ -140,45 +141,58 @@ function HeaderNotificationButton() {
140
141
  </>
141
142
  }
142
143
  >
143
- <List
144
- component="nav"
145
- sx={{
146
- p: 0,
147
- '& .MuiListItemButton-root': {
148
- py: 0.5,
149
- '&.Mui-selected': { bgcolor: 'grey.50', color: 'text.primary' },
150
- '& .MuiAvatar-root': avatarSx,
151
- '& .MuiListItemSecondaryAction-root': { ...actionSx, position: 'relative' }
152
- },
153
- maxHeight: 'calc(100vh - 240px)',
154
- overflow: 'auto'
155
- }}
156
- >
157
- {notifications.map((item, index) => (
158
- <HeaderNotificationItem
159
- key={item.id}
160
- selected={read > 0}
161
- notification={item}
162
- onClick={handleClose}
163
- divider={index < notifications.length - 1}
164
- />
165
- ))}
166
- </List>
167
- {/*@ts-ignore*/}
168
- <ListItemButton
169
- sx={{ textAlign: 'center', py: `${12}px !important` }}
170
- to={`/${resource}`}
171
- LinkComponent={Link}
172
- onClick={handleClose}
173
- >
174
- <ListItemText
175
- primary={
176
- <Typography variant="h6" color="primary">
177
- {translate('ra.notification.view_all')}
178
- </Typography>
179
- }
144
+ {notifications.length === 0 ? (
145
+ <Empty
146
+ hasCreate={false}
147
+ title={<Typography variant="h5">{translate('ra.notification.empty')}</Typography>}
148
+ sx={{
149
+ '& .ApplicaEmpty-icon': { fontSize: '60px' },
150
+ '& .ApplicaEmpty-toolbar': { display: 'none' }
151
+ }}
180
152
  />
181
- </ListItemButton>
153
+ ) : (
154
+ <>
155
+ <List
156
+ component="nav"
157
+ sx={{
158
+ p: 0,
159
+ '& .MuiListItemButton-root': {
160
+ py: 0.5,
161
+ '&.Mui-selected': { bgcolor: 'grey.50', color: 'text.primary' },
162
+ '& .MuiAvatar-root': avatarSx,
163
+ '& .MuiListItemSecondaryAction-root': { ...actionSx, position: 'relative' }
164
+ },
165
+ maxHeight: 'calc(100vh - 240px)',
166
+ overflow: 'auto'
167
+ }}
168
+ >
169
+ {notifications.map((item, index) => (
170
+ <HeaderNotificationItem
171
+ key={item.id}
172
+ selected={read > 0}
173
+ notification={item}
174
+ onClick={handleClose}
175
+ divider={index < notifications.length - 1}
176
+ />
177
+ ))}
178
+ </List>
179
+ {/*@ts-ignore*/}
180
+ <ListItemButton
181
+ sx={{ textAlign: 'center', py: `${12}px !important` }}
182
+ to={`/${resource}`}
183
+ LinkComponent={Link}
184
+ onClick={handleClose}
185
+ >
186
+ <ListItemText
187
+ primary={
188
+ <Typography variant="h6" color="primary">
189
+ {translate('ra.notification.view_all')}
190
+ </Typography>
191
+ }
192
+ />
193
+ </ListItemButton>
194
+ </>
195
+ )}
182
196
  <Divider />
183
197
  </MainCard>
184
198
  </ClickAwayListener>
@@ -1,4 +1,4 @@
1
- import { FC, ReactElement, memo, useCallback, useMemo, useState } from 'react';
1
+ import { FC, ReactElement, memo, useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { TablePagination, TablePaginationBaseProps, Theme, Toolbar, useMediaQuery } from '@mui/material';
4
4
  import {
@@ -20,6 +20,17 @@ const Pagination: FC<PaginationProps> = memo((props) => {
20
20
  const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md'));
21
21
  const [currentPage, setCurrentPage] = useState(page - 1); // Stato per la UI
22
22
  const { hasCreate } = useResourceDefinition(props);
23
+ const [isSelectedPage, setIsSelectedPage] = useState(false);
24
+
25
+ useEffect(() => {
26
+ if (page !== currentPage + 1 && !isSelectedPage) {
27
+ setCurrentPage(page - 1);
28
+ }
29
+ }, [currentPage, isSelectedPage, page]);
30
+
31
+ useEffect(() => {
32
+ setIsSelectedPage(false);
33
+ }, [page]);
23
34
 
24
35
  const totalPages = useMemo(() => {
25
36
  return total != null ? Math.ceil(total / perPage) : undefined;
@@ -62,6 +73,7 @@ const Pagination: FC<PaginationProps> = memo((props) => {
62
73
  arrowSelected.includes('KeyboardArrowRightIcon');
63
74
 
64
75
  setCurrentPage(page);
76
+ setIsSelectedPage(true);
65
77
 
66
78
  if (isArrowClick) {
67
79
  // apply debounced API call for arrows clicks
@@ -71,7 +83,7 @@ const Pagination: FC<PaginationProps> = memo((props) => {
71
83
  setPage(page + 1);
72
84
  }
73
85
  },
74
- [debouncedPageChange, setPage, translate, totalPages]
86
+ [debouncedPageChange, setPage, translate, totalPages, setIsSelectedPage]
75
87
  );
76
88
 
77
89
  const handlePerPageChange = useCallback(
@@ -112,10 +112,12 @@ function Empty({
112
112
  const translate = useTranslate();
113
113
 
114
114
  const getResourceLabel = useGetResourceLabel();
115
- const resourceName = translate(`resources.${resource}.forcedCaseName`, {
116
- smart_count: 0,
117
- _: getResourceLabel(resource, 0)
118
- });
115
+ const resourceName = resource
116
+ ? translate(`resources.${resource}.forcedCaseName`, {
117
+ smart_count: 0,
118
+ _: getResourceLabel(resource, 0)
119
+ })
120
+ : translate('ra.empty.no_resource');
119
121
 
120
122
  const emptyMessage = translate('ra.page.empty', { name: resourceName });
121
123
  const inviteMessage = translate('ra.page.invite');