import { withHeaders } from "@/record-management/services/api/withHeaders";
import performanceInstance from "@/shared/services/performanceInstance";
import { AxiosResponse } from "axios";

export interface CreatePlanTeamDto {
  name: {
    am: string;
    en: string;
  };
  description: {
    am: string;
    en: string;
  };
  teamLeaderId: string;
  positionId: string;
}

export interface CreatePlanTeamMemberDto {
  planTeamId: string;
  employeePositionIds: string;
}
export interface CreatePlanBulkTeamMemberDto {
  planTeamId: string;
  employeePositionIds: string[];
}
export interface PlanTeamParams {
  skip?: number;
  take?: number;
  orderBy?: string;
}
export interface CreatePlanTeamMemberDto {
  planTeamId: string;
  employeePositionId: string;
}
export const getPlanTeam = async (id: string): Promise<AxiosResponse> => {
  return performanceInstance.get(`/plan-teams/${id}`, {
    headers: withHeaders(),
  });
};
export const updatePlanTeam = async (
  id: string,
  data: CreatePlanTeamDto
): Promise<AxiosResponse> => {
  return performanceInstance.put(`/plan-teams/${id}`, data, {
    headers: withHeaders(),
  });
};
export const deletePlanTeam = async (id: string): Promise<AxiosResponse> => {
  return performanceInstance.delete(`/plan-teams/${id}`, {
    headers: withHeaders(),
  });
};

export const createPlanTeam = async (
  data: CreatePlanTeamDto
): Promise<AxiosResponse> => {
  return performanceInstance.post(`/plan-teams`, data, {
    headers: withHeaders(),
  });
};

export const getPlanTeamList = async (
  id: string,
  params?: PlanTeamParams
): Promise<AxiosResponse> => {
  return performanceInstance.get(`/plan-teams/list/${id}`, {
    headers: withHeaders(),
    params,
  });
};

export const getPlanTeamMembers = async (
  id: string
): Promise<AxiosResponse> => {
  return performanceInstance.get(`/plan-team-members/${id}`, {
    headers: withHeaders(),
  });
};

export const createPlanTeamMember = async (
  data: CreatePlanTeamMemberDto
): Promise<AxiosResponse> => {
  return performanceInstance.post(`/plan-team-members`, data, {
    headers: withHeaders(),
  });
};
export const createPlanBulkTeamMember = async (
  data: CreatePlanBulkTeamMemberDto
): Promise<AxiosResponse> => {
  return performanceInstance.post(`/plan-team-members/bulk-create`, data, {
    headers: withHeaders(),
  });
};

export const deletePlanTeamMember = async (
  id: string
): Promise<AxiosResponse> => {
  return performanceInstance.delete(`/plan-team-members/${id}`, {
    headers: withHeaders(),
  });
};

export const updatePlanTeamMember = async (
  id: string,
  data: CreatePlanTeamMemberDto
): Promise<AxiosResponse> => {
  return performanceInstance.put(`/plan-team-members/${id}`, data, {
    headers: withHeaders(),
  });
};

export const getPlanTeamMemberList = async (
  id: string,
  params?: PlanTeamParams
): Promise<AxiosResponse> => {
  return performanceInstance.get(`/plan-team-members/list/${id}`, {
    headers: withHeaders(),
    params,
  });
};
