Files
dmenu-admin/src/pages/notification/service/NotificationService.ts
T
hamid zarghami 4b37fe34ac read all
2025-12-21 16:42:53 +03:30

33 lines
904 B
TypeScript

import axios from "../../../config/axios";
import type {
GetNotificationsResponse,
GetUnseenCountResponse,
} from "../types/NotificationTypes";
export const getNotifications = async (
cursor: string | undefined,
status: "all" | "seen" | "unseen"
): Promise<GetNotificationsResponse> => {
let query = ``;
if (status !== "all") {
query = `&status=${status}`;
}
const cursorParam = cursor ? `&cursor=${cursor}` : ``;
const { data } = await axios.get<GetNotificationsResponse>(
`/admin/notifications?limit=10${cursorParam}${query}`
);
return data;
};
export const readAll = async () => {
const { data } = await axios.put(`/admin/notifications/read/all`);
return data;
};
export const getUnseenCount = async (): Promise<GetUnseenCountResponse> => {
const { data } = await axios.get<GetUnseenCountResponse>(
`/admin/notifications/unseen-count`
);
return data;
};