import { axiosInstance } from "../config/api";
import {
  RECENT_NOTIFICATIONS_SIZE,
  UNREAD_NOTIFICATIONS_SIZE,
} from "../views/Notifications/notificationConstant";
export const getNotifications = (unread = false, page = 0) => {
  // let url;

  // if (unread) {
  //   url = `/notifications?status=1&page=${page}&size=${UNREAD_NOTIFICATIONS_SIZE}`; // unread notifications
  // } else {
  //   url = `/notifications?status=0&page=${page}&size=${RECENT_NOTIFICATIONS_SIZE}`; // recent notifications
  // }

  // return new Promise((resolve, reject) => {
  //   axiosInstance
  //     .get(url)
  //     .then((response) => resolve(response))
  //     .catch((err) => reject(err));
  // });
  return {
    data: {
      data: [],
      message: "Success",
      error: "",
    },
  };
};

export const markReadNotification = (notificationsIds = []) => {
  const url = notificationsIds?.length
    ? `/notifications?ids=${notificationsIds?.join(",")}`
    : `/notifications`;

  return new Promise((resolve, reject) => {
    axiosInstance
      .put(url)
      .then((response) => resolve(response))
      .catch((err) => reject(err));
  });
};

export const saveFcmToken = (data) => {
  const url = `/fcm`;

  return new Promise((resolve, reject) => {
    axiosInstance
      .post(url, data)
      .then((response) => resolve(response))
      .catch((err) => reject(err));
  });
};
