notification admin

This commit is contained in:
hamid zarghami
2026-02-24 09:55:28 +03:30
parent 4f0f9cda73
commit 689376787e
7 changed files with 123 additions and 44 deletions
@@ -1,18 +1,35 @@
import axios from "../../../config/axios";
import type {
NotificationsResponseType,
UnseenCountResponseType,
} from "../types/NotificationTypes";
export const getNotifications = async (
page: number,
status: "all" | "read" | "unread"
) => {
pageOrCursor: number | string,
status: "all" | "read" | "unread",
): Promise<NotificationsResponseType> => {
let query = ``;
if (status !== "all") {
query = `&isRead=${status === "read" ? 1 : 0}`;
query = `&status=${status === "read" ? "seen" : "unseen"}`;
}
const { data } = await axios.get(`/notifications?page=${page}${query}`);
const pageParam =
typeof pageOrCursor === "number"
? `page=${pageOrCursor}`
: `cursor=${encodeURIComponent(pageOrCursor)}`;
const { data } = await axios.get<NotificationsResponseType>(
`/admin/notifications?${pageParam}${query}&limit=10`,
);
return data;
};
export const readAll = async () => {
const { data } = await axios.patch(`/notifications/read-all`);
const { data } = await axios.put(`/admin/notifications/read/all`);
return data;
};
export const getUnseenCount = async (): Promise<UnseenCountResponseType> => {
const { data } = await axios.get<UnseenCountResponseType>(
`/admin/notifications/unseen-count`,
);
return data;
};