import { axiosClient } from "@/lib/axios";
import { NotificationItem } from "../type/notification.type";

export const notificationService = {
  getNotifications: async (params: { page?: number; limit?: number }) => {
    const res = await axiosClient.get<{
      data: NotificationItem[];
      meta: { total: number; page: number; limit: number };
    }>("/notifications", { params });
    return res.data;
  },

  getUnreadCount: async () => {
    const res = await axiosClient.get<{ data: { count: number } }>(
      "/notifications/unread-count",
    );
    return res.data.data.count;
  },

  markAsRead: async (notificationId: string) => {
    const res = await axiosClient.patch<{ data: NotificationItem }>(
      `/notifications/${notificationId}/read`,
    );
    return res.data.data;
  },
};
