import {
  SGW_ROUTE_BANZONES,
  SGW_ROUTE_BANZONES_LIST,
} from '@/constants/slave/sgw/routes';
import { request } from '@umijs/max';

/**
 * Get all banzones with pagination and search
 * @param body Search and pagination parameters
 */
export async function apiGetAllBanzones(
  body: SgwModel.SearchZonePaginationBody,
) {
  return request<SgwModel.ZoneResponse>(SGW_ROUTE_BANZONES_LIST, {
    method: 'POST',
    data: body,
  });
}

/**
 * Remove a banzone
 * @param id Banzone ID
 * @param groupID Group ID
 */
export async function apiRemoveBanzone(id: string, groupID: string) {
  return request(`${SGW_ROUTE_BANZONES}/${id}/${groupID}`, {
    method: 'DELETE',
  });
}

/**
 * Get banzone by ID
 * @param zoneId Banzone ID
 */
export async function apiGetZoneById(
  zoneId: string,
): Promise<SgwModel.Banzone> {
  return request<SgwModel.Banzone>(`${SGW_ROUTE_BANZONES}/${zoneId}`);
}

/**
 * Create a new banzone
 * @param body Banzone data
 */
export async function apiCreateBanzone(body: SgwModel.ZoneBasicInfo) {
  return request(SGW_ROUTE_BANZONES, {
    method: 'POST',
    data: body,
  });
}

/**
 * Update banzone by ID
 * @param id Banzone ID
 * @param body Updated banzone data
 */
export async function apiUpdateBanzone(
  id: string,
  body: SgwModel.ZoneBasicInfo,
) {
  return request(`${SGW_ROUTE_BANZONES}/${id}`, {
    method: 'PUT',
    data: body,
  });
}
