From 05ef9ec71bcb43e41a1e9083160a41729aadf45b Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 3 Apr 2024 15:01:39 +0700 Subject: [PATCH] feat: Header => logout & filter unread --- src/layouts/MainLayout.vue | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index ed442512..aed5224d 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -7,6 +7,7 @@ import { useI18n } from 'vue-i18n'; import useLoader from 'stores/loader'; import DrawerComponent from 'components/DrawerComponent.vue'; +import GlobalDialog from 'components/GlobalDialog.vue'; interface NotificationButton { item: string; @@ -27,6 +28,7 @@ const loaderStore = useLoader(); const { visible } = storeToRefs(loaderStore); const { locale } = useI18n({ useScope: 'global' }); +const logoutModal = ref(false); const leftDrawerOpen = ref($q.screen.gt.sm); const filterUnread = ref(false); const unread = ref(1); @@ -56,8 +58,8 @@ const notiMenu = ref([ const notification = ref([ { id: '1', - title: 'test', - content: 'test', + title: 'Unread', + content: 'Unread', read: false, }, { @@ -66,6 +68,12 @@ const notification = ref([ content: 'test', read: false, }, + { + id: '3', + title: 'Read', + content: 'Already read', + read: true, + }, ]); function setActive(button: NotificationButton) { @@ -83,8 +91,12 @@ function setActive(button: NotificationButton) { } } -function doLogout() { - logout(); +function doLogout(confirm?: boolean = false) { + logoutModal.value = true; + if (confirm) { + logoutModal.value = false; + logout(); + } } @@ -112,6 +124,7 @@ function doLogout() { class="noti-circle" :class="{ bordered: $q.dark.isActive, dark: $q.dark.isActive }" style="color: var(--surface-1)" + @click="notiOpen = !notiOpen" > @@ -150,7 +163,9 @@ function doLogout() { clickable class="q-py-sm" v-ripple - v-for="item in notification" + v-for="item in !filterUnread + ? notification + : notification.filter((v) => !v.read)" :key="item.id" >