feat(settings): implement user profile page and notification handler

This commit introduces a new user settings page and enhances push notification functionality.

The new settings page, located at `/pages/settings`, allows users to view and update their personal profile information. It fetches the current user's data and provides a form to edit fields such as name, email, phone number, position, and role. The form is built using `react-hook-form` for state management and validation, and it leverages custom hooks (`useProfileQuery`, `useUpdateProfileQuery`) to interact with the API.

Additionally, a `notificationclick` event listener has been added to the Firebase messaging service worker. This handler improves the user experience for push notifications by focusing on an existing tab with the relevant URL or opening a new one if none exists when a notification is clicked.
This commit is contained in:
AmirReza Jamali
2025-10-11 16:41:26 +03:30
parent 03da4dea8b
commit 387747b9b0
17 changed files with 302 additions and 49 deletions
+25
View File
@@ -14,3 +14,28 @@ firebase.initializeApp({
});
const messaging = firebase.messaging();
self.addEventListener("notificationclick", (event) => {
event.notification.close();
const urlToOpen = event.notification.data.url || "/";
event.waitUntil(
clients
.matchAll({
type: "window",
includeUncontrolled: true,
})
.then((clientList) => {
for (const client of clientList) {
if (client.url === urlToOpen && "focus" in client) {
return client.focus();
}
}
if (clients.openWindow) {
return clients.openWindow(urlToOpen);
}
}),
);
});