diff --git a/frontend/package.json b/frontend/package.json
index 848a669..b4a7ca4 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -42,6 +42,7 @@
"vue-skeletor": "^1.0.6",
"vue3-marquee": "^4.2.2",
"vue3-persian-datetime-picker": "^1.2.2",
+ "web-push": "^3.6.7",
"workbox-window": "^7.3.0"
},
"devDependencies": {
diff --git a/frontend/pages/cart/index.vue b/frontend/pages/cart/index.vue
index 8879956..12e30f2 100644
--- a/frontend/pages/cart/index.vue
+++ b/frontend/pages/cart/index.vue
@@ -15,9 +15,7 @@ definePageMeta({
// queries
-const { data: cart, isLoading: cartIsLoading, suspense } = useGetCartOrders();
-
-await suspense();
+const { data: cart, isLoading: cartIsLoading } = useGetCartOrders();
// computed
diff --git a/frontend/pages/profile/notifications.vue b/frontend/pages/profile/notifications.vue
index 9ba8144..ce345bf 100644
--- a/frontend/pages/profile/notifications.vue
+++ b/frontend/pages/profile/notifications.vue
@@ -5,12 +5,127 @@ definePageMeta({
middleware: "check-is-logged-in",
layout: "profile",
});
+
+// imports
+
+import { usePushNotifications } from "~/composables/global/usePushNotifications";
+import useSubscribeNotification from "~/composables/api/notifications/useSubscribeNotification";
+
+// state
+
+const params = useUrlSearchParams("history");
+
+const subscribe = ref(false);
+
+const sortFilters = ref([
+ {
+ title: "جدید ترین",
+ value: "created_at",
+ },
+ {
+ title: "قدیمی ترین",
+ value: "-created_at",
+ },
+]);
+
+// queries
+
+const {
+ isSupported,
+ subscribe: notificationSubsribe,
+ unsubscribe: notificationUnSubsribe,
+ subscription,
+} = usePushNotifications();
+
+const { isPending: subscribeNotificationIsPending } =
+ useSubscribeNotification();
+
+// watch
+
+watch(
+ () => subscribe.value,
+ (nv) => {
+ if (!!subscription && nv) {
+ notificationSubsribe();
+ } else {
+ notificationUnSubsribe();
+ }
+ }
+);
-
+
-
+
+
+
+
+
+
+
+
+
+ دریافت مستقیم اعلانات
+
+ اعلانات حساب شما به صورت مستقیم به دستگاه شما ارسال می
+ شود
+
+
+
+
+
+
+
+ 1 اعلان
+
+
+
+ فیلتر بر اساس
+
+
+
+
+
+
+
+
+
diff --git a/frontend/server/api/vapid.get.ts b/frontend/server/api/vapid.get.ts
new file mode 100644
index 0000000..1fbd99c
--- /dev/null
+++ b/frontend/server/api/vapid.get.ts
@@ -0,0 +1,26 @@
+import webPush from "web-push";
+
+export default defineEventHandler(() => {
+ // Generate once and set in .env for production
+ if (process.env.NODE_ENV === "production") {
+ if (
+ !process.env.VAPID_PRIVATE_KEY ||
+ !process.env.NUXT_PUBLIC_VAPID_KEY
+ ) {
+ throw createError({
+ statusCode: 500,
+ statusMessage: "VAPID keys not configured in production",
+ });
+ }
+ return { publicKey: process.env.NUXT_PUBLIC_VAPID_KEY };
+ }
+
+ // Development: Generate and reuse
+ if (!process.env.VAPID_PRIVATE_KEY) {
+ const vapidKeys = webPush.generateVAPIDKeys();
+ process.env.VAPID_PRIVATE_KEY = vapidKeys.privateKey;
+ process.env.NUXT_PUBLIC_VAPID_KEY = vapidKeys.publicKey;
+ }
+
+ return { publicKey: process.env.NUXT_PUBLIC_VAPID_KEY };
+});