import { ndmClient, userClient, type NdmIcmpLogPageQuery, type NdmIcmpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
import { unwrapResponse } from '@/utils';

export const pageIcmpLogApi = async (pageQuery: PageParams<NdmIcmpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
  const { stationCode, signal } = options ?? {};
  const client = stationCode ? ndmClient : userClient;
  const prefix = stationCode ? `/${stationCode}` : '';
  const endpoint = `${prefix}/api/ndm/ndmIcmpLog/page`;
  const resp = await client.post<PageResult<NdmIcmpLogResultVO>>(endpoint, pageQuery, { signal });
  const data = unwrapResponse(resp);
  return data;
};
