import { withHeaders } from "@/record-management/services/api/withHeaders";
import recordAxiosInstance from "@/shared/services/recordAxiosInstance";
import {
  CreateRecordTagPayload,
  RecordTag,
  RecordTagResponse,
  UpdateRecordTagPayload,
} from "@/user-management/dto/recordTags/recordTags.type";
import { AxiosResponse } from "axios";

export const recordTagService = {
  getRecordTags: (id: string): Promise<AxiosResponse<RecordTag>> =>
    recordAxiosInstance.get(`/record-tags/${id}`, {
      headers: withHeaders(),
    }),

  getRecordTagsListWithUnitById: (
    id: string,
  ): Promise<AxiosResponse<RecordTagResponse>> =>
    recordAxiosInstance.get(`/record-tags/list/${id}?take=1000`, {
      headers: withHeaders(),
    }),

  createRecordTags: (
    payload: CreateRecordTagPayload,
  ): Promise<AxiosResponse<RecordTag>> =>
    recordAxiosInstance.post(
      `/record-tags`,
      { ...payload, recordTypeKey: "external" },
      {
        headers: withHeaders(),
      },
    ),

  updateEmployee: (
    id: string,
    payload: UpdateRecordTagPayload,
  ): Promise<AxiosResponse<RecordTag>> =>
    recordAxiosInstance.put(`/record-tags/${id}`, payload, {
      headers: withHeaders(),
    }),

  deleteEmployee: (id: string): Promise<AxiosResponse<void>> =>
    recordAxiosInstance.delete(`/record-tags/${id}`, {
      headers: withHeaders(),
    }),
};
