export default function () {

  type GetOvernightParkingRequestsParams = {
    page?: number
    limit?: number
    order?: "asc" | "desc"
    site?: string
    status?: string
  }

  async function getOvernightParkingRequests({
    page = 1,
    limit = 10,
    order = "desc",
    site = "",
    status = "",
  }: GetOvernightParkingRequestsParams = {}) {
    return await useNuxtApp().$api<Record<string, any>>(
      "/api/overnight-parking-requests",
      {
        method: "GET",
        query: {
          page,
          limit,
          order,
          site,
          status,
        },
      }
    );
  }

  async function getOvernightParkingRequestById(_id: string) {
    return await useNuxtApp().$api<TOvernightParkingRequest>(
      `/api/overnight-parking-requests/id/${_id}`,
      {
        method: "GET",
      }
    );
  }

  async function createOvernightParkingRequest(payload: Partial<TOvernightParkingRequest>) {
    return await useNuxtApp().$api<TOvernightParkingRequest>(
      "/api/overnight-parking-requests",
      {
        method: "POST",
        body: payload,
      }
    );
  }

  async function updateOvernightParkingRequest(_id: string, payload: Partial<TOvernightParkingRequest>) {
    return await useNuxtApp().$api<TOvernightParkingRequest>(
      `/api/overnight-parking-requests/id/${_id}`,
      {
        method: "PUT",
        body: payload,
      }
    );
  }

  async function deleteOvernightParkingRequest(_id: string) {
    return await useNuxtApp().$api<Record<string, any>>(
      `/api/overnight-parking-requests/id/${_id}`,
      {
        method: "DELETE",
      }
    );
  }

  return {
    getOvernightParkingRequests,
    getOvernightParkingRequestById,
    createOvernightParkingRequest,
    updateOvernightParkingRequest,
    deleteOvernightParkingRequest,
  };
}
