Skip to content

Commit

Permalink
fixed the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashyap1ankit committed Nov 24, 2024
1 parent e837fd0 commit 6ecf3fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions components/GetNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,18 @@ export default function GetNotification() {
async function subscribeUser(registration: ServiceWorkerRegistration) {
try {
if (!("Notification" in window)) {
console.log("notification error");
throw new Error("This browser does not support notifications");
}

const permission = await Notification.requestPermission();
if (permission !== "granted") {
console.log("permission eror");
throw new Error("Notification permission denied");
}

if (!("PushManager" in window)) {
console.log("pushmanager eror");
throw new Error("Push messaging is not supported");
}

Expand All @@ -107,8 +110,6 @@ export default function GetNotification() {
JSON.stringify(subcriptionObject),
);

console.log("response", response);

if (response.status !== 200) throw new Error(response.message);

toast.success("Notification is enabled", {
Expand All @@ -119,7 +120,6 @@ export default function GetNotification() {
},
});
} catch (error) {
console.log("error in ctahc", error);
toast.error((error as Error).message, {
style: {
backgroundColor: "red",
Expand Down
2 changes: 0 additions & 2 deletions components/Job/Create/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { SendNotification } from "@/app/actions/notification";

export default function CreateForm() {
const {
Expand Down Expand Up @@ -85,7 +84,6 @@ export default function CreateForm() {
},
});

await SendNotification(data.company);
router.push("/jobs");
} catch (error) {
toast((error as Error).message);
Expand Down

0 comments on commit 6ecf3fc

Please sign in to comment.