fixed route Notification
All checks were successful
Build frontend / build (push) Successful in 1m33s
All checks were successful
Build frontend / build (push) Successful in 1m33s
This commit is contained in:
@ -88,10 +88,8 @@ export default function NotificationHandler() {
|
|||||||
|
|
||||||
async function handleEnable() {
|
async function handleEnable() {
|
||||||
setShowPrompt(false);
|
setShowPrompt(false);
|
||||||
|
|
||||||
// This MUST be synchronous from a user gesture
|
// This MUST be synchronous from a user gesture
|
||||||
const permission = await Notification.requestPermission();
|
const permission = await Notification.requestPermission();
|
||||||
|
|
||||||
if (permission === "granted") {
|
if (permission === "granted") {
|
||||||
await setupFCM();
|
await setupFCM();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ export default function useAuth() {
|
|||||||
name: authUser?.name ?? "Not found",
|
name: authUser?.name ?? "Not found",
|
||||||
email: authUser?.email ?? "Not found",
|
email: authUser?.email ?? "Not found",
|
||||||
isOwner: role?.includes("Owner"),
|
isOwner: role?.includes("Owner"),
|
||||||
isAgent: role?.includes("RealEstateAgent",""),
|
isAgent: role?.includes("RealEstateAgent"),
|
||||||
isCustomer: role?.includes("Customer"),
|
isCustomer: role?.includes("Customer"),
|
||||||
role: role,
|
role: role,
|
||||||
isGuest: !authUser,
|
isGuest: !authUser,
|
||||||
|
|||||||
@ -66,9 +66,7 @@ const AuthService = Object.freeze({
|
|||||||
*/
|
*/
|
||||||
getCachedUser() {
|
getCachedUser() {
|
||||||
const user = Cookies.get(USER_KEY);
|
const user = Cookies.get(USER_KEY);
|
||||||
|
|
||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return JSON.parse(user);
|
return JSON.parse(user);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@ -31,10 +31,25 @@ messaging.onBackgroundMessage((payload) => {
|
|||||||
self.registration.showNotification(title, options);
|
self.registration.showNotification(title, options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function mapNotificationUrl(url) {
|
||||||
|
if (!url) return "/";
|
||||||
|
if (url.startsWith("/SaleProperty/")) {
|
||||||
|
return url.replace("/SaleProperty/", "/owner/properties/");
|
||||||
|
}
|
||||||
|
if (url.startsWith("/reservations/")) {
|
||||||
|
return url.replace("/reservations/", "/reservations/");
|
||||||
|
}
|
||||||
|
if (url === "/" || url === "/home") {
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle notification click
|
// Handle notification click
|
||||||
//اذا ضغطنا ع الاشعار شو بصير
|
//اذا ضغطنا ع الاشعار شو بصير
|
||||||
self.addEventListener("notificationclick", (event) => {
|
self.addEventListener("notificationclick", (event) => {
|
||||||
event.notification.close();
|
event.notification.close();
|
||||||
const url = event.notification.data?.url || "/";
|
const notificationUrl = event.notification.data?.url || "/";
|
||||||
|
const url = mapNotificationUrl(notificationUrl);
|
||||||
event.waitUntil(clients.openWindow(url));
|
event.waitUntil(clients.openWindow(url));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user