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;
};
