import request from '@/utils/request';
import type { Page } from '@/types/base';
import type {
  TeamMemberQuery,
  TeamMemberResponse,
  TeamMemberRequest,
} from './types';

const BASE_URL = '/api/v1/team-members';

/**
 * 分页查询团队成员
 */
export const getTeamMembers = (params?: TeamMemberQuery) =>
  request.get<Page<TeamMemberResponse>>(`${BASE_URL}/page`, { params });

/**
 * 查询团队成员详情
 */
export const getTeamMemberById = (id: number) =>
  request.get<TeamMemberResponse>(`${BASE_URL}/${id}`);

/**
 * 创建团队成员
 */
export const createTeamMember = (data: TeamMemberRequest) =>
  request.post<TeamMemberResponse>(BASE_URL, data);

/**
 * 更新团队成员
 */
export const updateTeamMember = (id: number, data: TeamMemberRequest) =>
  request.put<TeamMemberResponse>(`${BASE_URL}/${id}`, data);

/**
 * 删除团队成员
 */
export const deleteTeamMember = (id: number) =>
  request.delete(`${BASE_URL}/${id}`);

