feat: fetch notification from api

This commit is contained in:
Methapon Metanipat 2024-10-31 17:59:51 +07:00 committed by Methapon2001
parent 838490d90d
commit 74d80a163d

View file

@ -17,6 +17,7 @@ import { useConfigStore } from 'src/stores/config';
import { useNavigator } from 'src/stores/navigator'; import { useNavigator } from 'src/stores/navigator';
import { initLang, initTheme, Lang, setLang } from 'src/utils/ui'; import { initLang, initTheme, Lang, setLang } from 'src/utils/ui';
import { baseUrl } from 'stores/utils'; import { baseUrl } from 'stores/utils';
import { useNotification } from 'src/stores/notification';
const useMyBranch = useMyBranchStore(); const useMyBranch = useMyBranchStore();
const { fetchListMyBranch } = useMyBranch; const { fetchListMyBranch } = useMyBranch;
@ -37,8 +38,11 @@ interface Notification {
const $q = useQuasar(); const $q = useQuasar();
const loaderStore = useLoader(); const loaderStore = useLoader();
const navigatorStore = useNavigator(); const navigatorStore = useNavigator();
const notificationStore = useNotification();
const configStore = useConfigStore(); const configStore = useConfigStore();
const { data: notificationData } = storeToRefs(notificationStore);
const { visible } = storeToRefs(loaderStore); const { visible } = storeToRefs(loaderStore);
const { t } = useI18n({ useScope: 'global' }); const { t } = useI18n({ useScope: 'global' });
const userStore = useUserStore(); const userStore = useUserStore();
@ -129,6 +133,14 @@ onMounted(async () => {
await configStore.getConfig(); await configStore.getConfig();
{
const noti = await notificationStore.getNotificationList();
if (noti) {
notificationData.value = noti.result;
}
}
await fetchListMyBranch(getUserId() ?? ''); await fetchListMyBranch(getUserId() ?? '');
leftDrawerOpen.value = $q.screen.gt.xs ? true : false; leftDrawerOpen.value = $q.screen.gt.xs ? true : false;
@ -324,10 +336,10 @@ onMounted(async () => {
clickable clickable
class="q-py-sm" class="q-py-sm"
v-ripple v-ripple
v-for="item in !filterUnread v-for="(item, i) in !filterUnread
? notification ? notificationData
: notification.filter((v) => !v.read)" : notificationData"
:key="item.id" :key="i"
> >
<q-avatar <q-avatar
color="positive" color="positive"
@ -343,7 +355,7 @@ onMounted(async () => {
{{ item.title }} {{ item.title }}
</span> </span>
<span class="block ellipsis full-width text-stone"> <span class="block ellipsis full-width text-stone">
{{ item.content }} {{ item.detail }}
</span> </span>
</div> </div>
<span align="right" class="col text-caption text-stone"> <span align="right" class="col text-caption text-stone">
@ -356,7 +368,7 @@ onMounted(async () => {
:delay="1000" :delay="1000"
:offset="[10, 10]" :offset="[10, 10]"
> >
{{ item.content }} {{ item.detail }}
</q-tooltip> </q-tooltip>
</q-item> </q-item>
</div> </div>