import { deleteRequest, getRequest, postRequest, putRequest } from ".";
import apiEndpoints from "./apiEndpoints";

export const attemptFetchOffers = (payload) => {
  if (payload) return getRequest(apiEndpoints.offers.getOffers + payload);
  return getRequest(apiEndpoints.offers.getOffers);
};
export const attemptFetchOneOffer = (payload) => {
   const url = `${apiEndpoints.offers.getOneOffer}/${payload}`;
    return getRequest(url);
}
export const attemptFetchMoreOffers = (page, payload) => {
  if (payload)
    return getRequest(
      apiEndpoints.offers.getOffers + payload + `&size=10&page=${page}`
    );
  return getRequest(apiEndpoints.offers.getOffers + `?size=10&page=${page}`);
};
export const attemptAddOffer = (payload) => {
  return postRequest(apiEndpoints.offers.addOffer, payload);
};
export const attemptFetchProfileOffers = (payload) => {
  return getRequest(`${apiEndpoints.offers.mineOffers}/${payload}/offers`);
};
export const attemptRemoveOffer = (payload) => {
  return deleteRequest(apiEndpoints.offers.removeOffer + "/" + payload);
};
export const attemptEditOffer = (payload, editedData) => {
  return putRequest(apiEndpoints.offers.editOffer + "/" + payload, editedData);
};
