Skip to content

Commit

Permalink
cleaning and fixing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabbar03 committed Dec 11, 2024
2 parents 0451f36 + 00fcaa5 commit 8f6cd3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 42 deletions.
7 changes: 1 addition & 6 deletions client/app/(app)/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use server";
import Content from "@/components/settings/content";
import {
getNotificationStatus,
} from "@/actions/auth.action";
import { getNotificationStatus } from "@/actions/auth.action";
import { getUser, isAdmin } from "@/actions/user";
import { getEvents, getResource } from "@/actions/events";

Expand All @@ -19,9 +17,6 @@ const Page = async () => {
if (user instanceof Error) {
throw user.message;
}
// console.log("miao", user);
// console.log("events page", events);
// console.log("risorse", resource);

return (
<Content
Expand Down
46 changes: 10 additions & 36 deletions client/components/auth/NotificationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,9 @@ export default function NotificationSettings() {

useEffect(() => {
if ("serviceWorker" in navigator && "PushManager" in window) {
navigator.serviceWorker
.register("/service-worker.js")
.then((registration) => {
console.log(
"Service Worker registered with scope:",
registration.scope,
);
})
.catch((error) => {
console.error("Service Worker registration failed:", error);
});
navigator.serviceWorker.register("/service-worker.js").catch((error) => {
console.error("Service Worker registration failed:", error);
});
}
}, []);

Expand Down Expand Up @@ -125,7 +117,7 @@ export default function NotificationSettings() {
setSubscriptionStatus("Unsubscribed successfully!");
setSelectedDevice(null);
const updatedDevices = allDevices.filter(
(device) => device !== selectedDevice,
(device) => device !== selectedDevice
);
setAllDevices(updatedDevices);
} else {
Expand Down Expand Up @@ -154,29 +146,6 @@ export default function NotificationSettings() {
}
};

const sendClientSideNotification = () => {
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
return;
}

if (Notification.permission === "granted") {
new Notification("Test Notification", {
body: "This is a test notification from the client side!",
icon: "/path/to/icon.png", // Sostituisci con il percorso della tua icona
});
} else if (Notification.permission !== "denied") {
Notification.requestPermission().then((permission) => {
if (permission === "granted") {
new Notification("Test Notification", {
body: "This is a test notification from the client side!",
icon: "/path/to/icon.png", // Sostituisci con il percorso della tua icona
});
}
});
}
};

return (
<div>
<h2 className="text-md mb-3">Aggiungi dispositivo Push</h2>
Expand Down Expand Up @@ -238,7 +207,12 @@ export default function NotificationSettings() {
</div>

<p
className={`mt-3 ${subscriptionStatus.includes("successfully") || subscriptionStatus.includes("Updated") ? "text-success" : "text-danger"}`}
className={`mt-3 ${
subscriptionStatus.includes("successfully") ||
subscriptionStatus.includes("Updated")
? "text-success"
: "text-danger"
}`}
>
{subscriptionStatus}
</p>
Expand Down

0 comments on commit 8f6cd3a

Please sign in to comment.