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

export const DirectoryRepository = {
  GetOrganizations: () => api.get("/api/directory/organization"),
  GetDesignations: () => api.get("/api/directory/designations"),
  GetContact: (id) => api.get(`/api/Directory/profile/${id}`),

  GetContacts: (
    isActive,
    projectId,
    pageSize,
    pageNumber,
    filter,
    searchString
  ) => {
    const payloadJsonString = JSON.stringify(filter);
    return api.get(
      `/api/Directory/list?active=${isActive}` +
        (projectId ? `&projectId=${projectId}` : "") +
        `&pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${encodeURIComponent(
          payloadJsonString
        )}&searchString=${encodeURIComponent(searchString)}`
    );
  },

  GetContactFilter: () => api.get("/api/directory/contact/filter"),
  CreateContact: (data) => api.post("/api/directory", data),
  UpdateContact: (id, data) => api.put(`/api/directory/${id}`, data),
  DeleteContact: (id, isActive) =>
    api.delete(`/api/directory/${id}/?active=${isActive}`),
  AssignedBuckets: (id, data) =>
    api.post(`/api/directory/assign-bucket/${id}`, data),

  GetBucktes: () => api.get(`/api/directory/buckets`),
  CreateBuckets: (data) => api.post(`/api/Directory/bucket`, data),
  UpdateBuckets: (id, data) => api.put(`/api/Directory/bucket/${id}`, data),
  DeleteBucket: (id) => api.delete(`/api/directory/bucket/${id}`),

  GetContactProfile: (id) => api.get(`/api/directory/profile/${id}`),

  CreateNote: (data) => api.post("/api/directory/note", data),
  GetContactNotes: (id, isActive) =>
    api.get(`/api/directory/notes/${id}?active=${isActive}`),
  
  UpdateNote: (id, data) => api.put(`/api/directory/note/${id}`, data),
  DeleteNote: (id, isActive) =>
    api.delete(`/api/directory/note/${id}?active=${isActive}`),

  GetNotes: (
    projectId,
    pageSize,
    pageNumber,
    filter,
    searchString
  ) => {
    const payloadJsonString = JSON.stringify(filter);
    return api.get(
      `/api/directory/notes?` +
        (projectId ? `projectId=${projectId}&` : "&") +
        `pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${encodeURIComponent(
          payloadJsonString
        )}&searchString=${encodeURIComponent(searchString)}`
    );
  },
  GetNoteFilter:()=>api.get("/api/directory/notes/filter")
};
