import { api } from "../utils/axiosClient";
import { DirectoryRepository } from "./DirectoryRepository";

export const CollectionRepository = {
  createNewCollection: (data) =>
    api.post(`/api/Collection/invoice/create`, data),
  updateCollection:(id,data)=>{
    api.put(`/api/Collection/invoice/edit/${id}`,data)
  },
  getCollections: (pageSize, pageNumber,fromDate,toDate, isPending,isActive,projectId, searchString) => {
    let url = `/api/Collection/invoice/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isPending=${isPending}&isActive=${isActive}&searchString=${searchString}`;

    const params = [];
    if (fromDate) params.push(`fromDate=${fromDate}`);
    if (toDate) params.push(`toDate=${toDate}`);
    if(projectId) params.push(`projectId=${projectId}`)

    if (params.length > 0) {
      url += `&${params.join("&")}`;
    }
   return api.get(url);
  },

   makeReceivePayment:(data)=> api.post(`/api/Collection/invoice/payment/received`,data),
   markPaymentReceived:(invoiceId)=>api.put(`/api/Collection/invoice/marked/completed/${invoiceId}`),
   getCollection:(id)=>api.get(`/api/Collection/invoice/details/${id}`),
   addComment:(data)=>api.post(`/api/Collection/invoice/add/comment`,data)
};

