import type { BaseEmployeePageQuery, BaseEmployeeResultVO, PageParams, PageResult } from '@/apis';
import { userClient } from '@/apis/client';
import { unwrapResponse } from '@/utils';

export const pageBaseEmployeeApi = async (pageQuery: PageParams<BaseEmployeePageQuery>, options?: { signal?: AbortSignal }) => {
  const { signal } = options ?? {};
  const client = userClient;
  const endpoint = '/api/base/baseEmployee/page';
  const resp = await client.post<PageResult<BaseEmployeeResultVO>>(endpoint, pageQuery, { signal });
  const data = unwrapResponse(resp);
  return data;
};

export const detailBaseEmployeeApi = async (id: string, options?: { signal?: AbortSignal }) => {
  const { signal } = options ?? {};
  const client = userClient;
  const endpoint = `/api/base/baseEmployee/detail`;
  const resp = await client.get<BaseEmployeeResultVO>(endpoint, { params: { id }, signal });
  const data = unwrapResponse(resp);
  return data;
};
