|
|
@@ -94,11 +94,14 @@ import type { AnyJson, Pagination } from '~/types/data'
|
|
|
import { useEntityManager } from '~/composables/data/useEntityManager'
|
|
|
import UrlUtils from '~/services/utils/urlUtils'
|
|
|
import NotificationRepository from '~/stores/repositories/NotificationRepository'
|
|
|
+import Query from "~/services/data/Query";
|
|
|
+import PageFilter from "~/services/data/Filters/PageFilter";
|
|
|
|
|
|
const accessProfileStore = useAccessProfileStore()
|
|
|
|
|
|
const isOpen: Ref<boolean> = ref(false)
|
|
|
const page: Ref<number> = ref(1)
|
|
|
+const itemsPerPage: Ref<number> = ref(5)
|
|
|
|
|
|
const i18n = useI18n()
|
|
|
const runtimeConfig = useRuntimeConfig()
|
|
|
@@ -109,15 +112,15 @@ const { em } = useEntityManager()
|
|
|
const { fetchCollection } = useEntityFetch()
|
|
|
const notificationRepo = useRepo(NotificationRepository)
|
|
|
|
|
|
-const query: ComputedRef<AnyJson> = computed(() => {
|
|
|
- return { page: page.value }
|
|
|
-})
|
|
|
+const query = new Query(
|
|
|
+ new PageFilter(page, itemsPerPage)
|
|
|
+)
|
|
|
|
|
|
const {
|
|
|
data: collection,
|
|
|
pending,
|
|
|
refresh,
|
|
|
-} = await fetchCollection(Notification, null, query)
|
|
|
+} = fetchCollection(Notification, null, query)
|
|
|
|
|
|
/**
|
|
|
* On récupère les Notifications via le store
|
|
|
@@ -137,7 +140,7 @@ const unreadNotification: ComputedRef<Array<Notification>> = computed(() => {
|
|
|
* Les metadata dépendront de la dernière valeur du GET lancé
|
|
|
*/
|
|
|
const pagination: ComputedRef<Pagination> = computed(() => {
|
|
|
- return !pending.value && collection.value !== null
|
|
|
+ return collection.value !== null
|
|
|
? collection.value.pagination
|
|
|
: {}
|
|
|
})
|
|
|
@@ -173,6 +176,8 @@ const update = async () => {
|
|
|
|
|
|
await refresh()
|
|
|
|
|
|
+ console.log(page.value)
|
|
|
+
|
|
|
// Si des notifications n'avaient pas été marquées comme lues, on le fait immédiatement.
|
|
|
markNotificationsAsRead()
|
|
|
}
|