import { defineStore } from "pinia"; import { ref, computed } from "vue"; export const useUserStore = defineStore("user", () => { const user = ref(null); const notifications = computed(() => { return typeof user.value.notifications === "array" ? user.value.notifications : Object.values(user.value.notifications); }); function readNotification(notificationId) { user.value.notifications.forEach((notification) => { if (notification.id === notificationId) { notification.isread = "true"; } }); } function readAllNotifications(notificationId) { user.value.notifications.forEach((notification) => { notification.isread = true; }); } return { user, notifications, readNotification, readAllNotifications }; });