notification + change call back and ...

This commit is contained in:
hamid zarghami
2025-03-01 15:28:00 +03:30
parent c39240456b
commit ef71a1975e
12 changed files with 52 additions and 21 deletions
@@ -1,15 +1,14 @@
import * as api from "../service/NotificationService";
import { useInfiniteQuery, useMutation } from "@tanstack/react-query";
export const useGetNotification = () => {
export const useGetNotification = (status: "all" | "read" | "unread") => {
return useInfiniteQuery({
queryKey: ["notifications"],
queryFn: ({ pageParam = 1 }) => api.getNotifications(pageParam), // فراخوانی API برای گرفتن داده‌ها
queryKey: ["notifications", status],
queryFn: ({ pageParam = 1 }) => api.getNotifications(pageParam, status), // فراخوانی API برای گرفتن داده‌ها
initialPageParam: 1, // صفحه اول به طور پیشفرض
getNextPageParam: (lastPage) => {
const currentPage = lastPage.data?.pager.page;
const totalPages = lastPage.data?.pager.totalPages;
console.log("hasNextPage check: ", currentPage, totalPages); // بررسی وضعیت صفحات
return currentPage < totalPages ? currentPage + 1 : undefined;
},