@applica-software-guru/react-admin 1.5.367 → 1.5.368

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/README.md CHANGED
@@ -11,6 +11,6 @@ Components library for React to create web applications based on React-Admin and
11
11
 
12
12
  ---
13
13
 
14
- ## Documentazione
14
+ ## Documentation
15
15
 
16
- - [Configurazione notifiche push (Firebase Cloud Messaging)](./docs/push-notifications.md)
16
+ - [Push Notifications Configuration (Firebase Cloud Messaging)](./docs/push-notifications.md)
@@ -1,13 +1,12 @@
1
- # Notifiche Push (Firebase Cloud Messaging)
1
+ # Push Notifications (Firebase Cloud Messaging)
2
2
 
3
- > ⚠️ **Attenzione:** Per poter gestire le notifiche push, è indispensabile che il backend esponga i servizi FCM (Firebase Cloud Messaging) per la registrazione e la rimozione dei token. Senza questi endpoint, l'integrazione delle notifiche non potrà funzionare correttamente. Per informazioni di dettaglio a riguardo
4
- > consulta la documentazione sul backend (Archetipo).
3
+ > ⚠️ **Warning:** To manage push notifications, your backend must expose FCM (Firebase Cloud Messaging) services for token registration and removal. Without these endpoints, push notification integration will not work correctly.
5
4
 
6
- Questa guida spiega come abilitare e gestire le notifiche push tramite Firebase Cloud Messaging (FCM) nel progetto.
5
+ This guide explains how to enable and manage push notifications using Firebase Cloud Messaging (FCM) in your project.
7
6
 
8
- ## 1. Configurazione Firebase
7
+ ## 1. Firebase Configuration
9
8
 
10
- Recupera la configurazione dal [Firebase Console](https://console.firebase.google.com):
9
+ Retrieve the configuration from the [Firebase Console](https://console.firebase.google.com):
11
10
 
12
11
  ```ts
13
12
  const config = {
@@ -17,33 +16,33 @@ const config = {
17
16
  storageBucket: '<PROJECT_ID>.appspot.com',
18
17
  messagingSenderId: '<SENDER_ID>',
19
18
  appId: '<APP_ID>',
20
- vapidKey: '<VAPID_KEY>', // Da Cloud Messaging > Web Push certificates
21
- apiUrl: 'https://api.tuodominio.com' // Endpoint backend per la registrazione token
19
+ vapidKey: '<VAPID_KEY>', // From Cloud Messaging > Web Push certificates
20
+ apiUrl: 'https://api.yourdomain.com' // Backend endpoint for token registration
22
21
  };
23
22
  ```
24
23
 
25
- ## 2. Abilitazione automatica in ApplicaAdmin
24
+ ## 2. Automatic Enablement in ApplicaAdmin
26
25
 
27
- Per abilitare le notifiche push in tutta l'applicazione, passa semplicemente la configurazione come prop a `ApplicaAdmin`:
26
+ To enable push notifications throughout the application, simply pass the configuration as a prop to `ApplicaAdmin`:
28
27
 
29
28
  ```tsx
30
29
  import { ApplicaAdmin } from '@/ApplicaAdmin';
31
30
 
32
31
  <ApplicaAdmin
33
- // ...altre props
32
+ // ...other props
34
33
  pushNotifications={config}
35
34
  />;
36
35
  ```
37
36
 
38
- Questo farà che:
37
+ This will ensure that:
39
38
 
40
- - Le notifiche push siano gestite globalmente.
41
- - Il toggle per abilitare/disabilitare le notifiche sia già integrato nell'interfaccia delle notifiche (header).
42
- - I messaggi push ricevuti in foreground aggiorneranno automaticamente il pannello notifiche.
39
+ - Push notifications are managed globally.
40
+ - The toggle to enable/disable notifications is already integrated in the notifications interface (header).
41
+ - Push messages received in the foreground will automatically update the notifications panel.
43
42
 
44
- ## 3. Utilizzo manuale del bottone toggle
43
+ ## 3. Manual Use of the Toggle Button
45
44
 
46
- Se vuoi mostrare un bottone per abilitare/disabilitare le notifiche in un punto specifico dell'app:
45
+ If you want to show a button to enable/disable notifications in a specific part of the app:
47
46
 
48
47
  ```tsx
49
48
  import { PushNotificationToggleButton } from '@/components/ra-buttons/PushNotificationToggleButton';
@@ -51,18 +50,18 @@ import { PushNotificationToggleButton } from '@/components/ra-buttons/PushNotifi
51
50
  <PushNotificationToggleButton config={config} />;
52
51
  ```
53
52
 
54
- ## 4. Dettagli tecnici e ciclo di vita
53
+ ## 4. Technical Details & Lifecycle
55
54
 
56
- Il sistema:
55
+ The system:
57
56
 
58
- - Registra automaticamente il service worker `/firebase-messaging-sw.js` (deve essere presente nella root pubblica).
59
- - Richiede il permesso all'utente per le notifiche.
60
- - Registra il token FCM sul backend tramite `{apiUrl}/fcm/register` (POST) e lo rimuove con `{apiUrl}/fcm/{token}` (DELETE).
61
- - Gestisce lo stato: `enabled`, `disabled`, `pending`, `error`.
62
- - Espone funzioni per abilitare/disabilitare/toggle/listen alle notifiche tramite la hook `usePushNotifications`.
63
- - In caso di errore, mostra una notifica tramite il sistema di react-admin.
57
+ - Automatically registers the service worker `/firebase-messaging-sw.js` (must be present in the public root).
58
+ - Requests user permission for notifications.
59
+ - Registers the FCM token on the backend via `{apiUrl}/fcm/register` (POST) and removes it with `{apiUrl}/fcm/{token}` (DELETE).
60
+ - Manages state: `enabled`, `disabled`, `pending`, `error`.
61
+ - Exposes functions to enable/disable/toggle/listen to notifications via the `usePushNotifications` hook.
62
+ - In case of error, shows a notification using the react-admin system.
64
63
 
65
- ### Esempio avanzato con hook
64
+ ### Advanced Example with Hook
66
65
 
67
66
  ```tsx
68
67
  import { usePushNotifications } from '@/hooks/usePushNotifications';
@@ -71,22 +70,26 @@ const { status, enable, disable, toggle, listen } = usePushNotifications(config)
71
70
 
72
71
  useEffect(() => {
73
72
  const unsubscribe = listen(({ title, message, url }) => {
74
- // Mostra una notifica custom o aggiorna la UI
73
+ // Show a custom notification or update the UI
75
74
  });
76
75
  return unsubscribe;
77
76
  }, [listen]);
78
77
  ```
79
78
 
80
- ## 5. Requisiti e note
79
+ ## 5. Requirements & Notes
81
80
 
82
- - Il file `/firebase-messaging-sw.js` deve essere presente nella root pubblica del progetto.
83
- - Il backend deve esporre gli endpoint per la registrazione/rimozione del token FCM.
84
- - Il supporto alle notifiche push dipende dal browser e dai permessi utente.
85
- - Il sistema è pensato per integrarsi con React-Admin e ApplicaAdmin, ma può essere usato anche in altri contesti.
81
+ - The file `/firebase-messaging-sw.js` must be present in the public root of the project.
82
+ - The backend must expose the endpoints for FCM token registration/removal.
83
+ - Push notification support depends on the browser and user permissions.
84
+ - The system is designed to integrate with React-Admin and ApplicaAdmin, but can also be used in other contexts.
86
85
 
87
- ## 6. Template del Service Worker
86
+ ---
88
87
 
89
- Copia il seguente file come `/public/firebase-messaging-sw.js` nel tuo progetto. Ricordati di sostituire la configurazione Firebase con la tua!
88
+ For details on backend configuration and troubleshooting, see the official Firebase Cloud Messaging documentation.
89
+
90
+ ## 6. Service Worker Template
91
+
92
+ Copy the following file as `/public/firebase-messaging-sw.js` in your project. Remember to replace the Firebase configuration with your own!
90
93
 
91
94
  ```js
92
95
  /* public/firebase-messaging-sw.js */
@@ -106,7 +109,7 @@ firebase.initializeApp({
106
109
  const messaging = firebase.messaging();
107
110
 
108
111
  messaging.onBackgroundMessage((payload) => {
109
- const title = payload?.data?.title || 'Notifica';
112
+ const title = payload?.data?.title || 'Notification';
110
113
  const body = payload?.data?.message || '';
111
114
  const url = payload?.data?.url || '/';
112
115
 
@@ -135,4 +138,4 @@ self.addEventListener('notificationclick', (event) => {
135
138
  });
136
139
  ```
137
140
 
138
- > ⚠️ **Nota:** Sostituisci i valori di configurazione con quelli del tuo progetto Firebase!
141
+ > ⚠️ **Note:** Replace the configuration values with those from your Firebase project!
package/package.json CHANGED
@@ -109,5 +109,5 @@
109
109
  "type": "module",
110
110
  "types": "dist/index.d.ts",
111
111
  "typings": "dist/index.d.ts",
112
- "version": "1.5.367"
112
+ "version": "1.5.368"
113
113
  }