send notification user method working

This commit is contained in:
isUnknown 2024-10-30 10:56:11 +01:00
parent 14f409abec
commit 9752fffae6
7 changed files with 67 additions and 18 deletions

View file

@ -1,8 +1,12 @@
import { defineStore } from "pinia";
import { ref } from "vue";
import { ref, computed } from "vue";
export const useUserStore = defineStore("user", () => {
const user = ref(null);
return { user };
const notifications = computed(() => {
return user.value.notifications;
});
return { user, notifications };
});

View file

@ -2,12 +2,15 @@
<main class="wrapper">
<h2 id="tabslist" class="sr-only">Status</h2>
<Tabs :tabs="tabs" @update:currentTab="changeTab" />
<button class="btn | absolute top-0 right-gutter" disabled>
<button
class="btn | absolute top-0 right-gutter"
:disabled="!notifications.length"
>
Marquer tout come lu
</button>
<div
v-if="comments.length === 0"
v-if="notifications.length === 0"
class="flex flex-col justify-center | text-grey-700 | absolute inset-0 -z-1"
>
<svg
@ -108,7 +111,7 @@ import { storeToRefs } from "pinia";
dayjs.locale("fr");
const { page } = storeToRefs(usePageStore());
const user = useUserStore().user;
const { notifications } = storeToRefs(useUserStore());
const currentTab = ref("all");
const tabs = computed(() => {
return [
@ -129,18 +132,16 @@ const tabs = computed(() => {
];
});
const comments = user?.notifications?.comments
? Object.values(user.notifications.comments)
: [];
const notifications = [...comments];
const allNotifications = computed(() => {
return Object.values(notifications.value);
});
function changeTab(newValue) {
currentTab.value = newValue;
}
const isEmpty = computed(() => {
return comments.length === 0;
return notifications.value.length === 0;
});
</script>