import { withHeaders } from "@/record-management/services/api/withHeaders";
import axiosInstance from "@/shared/services/axiosInstance";
import { PermissionListResponse } from "@/user-management/dto/permissions/permissonDto";
import { AxiosResponse } from "axios";

interface AssignPayload {
  firstId: string;
  secondIds: string[];
}

export const positionTypePermissionService = {
  // POST /assign-seconds-for-first
  assignPermissionsToPositionType: (
    payload: AssignPayload
  ): Promise<AxiosResponse<void>> =>
    axiosInstance.post(
      "/position-type-permissions/assign-seconds-for-first",
      payload,
      {
        headers: withHeaders(),
      }
    ),

  // GET /given-first/{id}
  getPermissionsByPositionTypeId: (
    positionTypeId: string
  ): Promise<AxiosResponse<PermissionListResponse>> =>
    axiosInstance.get(
      `/position-type-permissions/given-first/${positionTypeId}`,
      {
        headers: withHeaders(),
      }
    ),

  // DELETE /position-type-permissions/{id}
  deletePermissionRelation: (
    relationId: string
  ): Promise<AxiosResponse<void>> =>
    axiosInstance.delete(`/position-type-permissions/${relationId}`, {
      headers: withHeaders(),
    }),
};
