From 8c426d7e7ae379d105c852a461b4077c45b7f91b Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Sat, 22 Mar 2025 16:22:17 +0330 Subject: [PATCH] added notifications --- frontend/pages/profile/notifications.vue | 119 ++++++++++++++++++++++- 1 file changed, 117 insertions(+), 2 deletions(-) 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(); + } + } +);