import type { InferResponseType, InferRequestType } from 'hono/client';
import { channelClient } from '../api/channelClient';

// 渠道搜索参数类型
export type ChannelSearchParams = {
  page: number;
  pageSize: number;
  keyword?: string;
};

// 分页响应类型
export type PaginatedResponse<T> = {
  data: T[];
  pagination: {
    total: number;
    page: number;
    pageSize: number;
    totalPages: number;
  };
};

// 使用Hono类型推导 - 基于渠道模块的自定义路由
export type CreateChannelRequest = InferRequestType<typeof channelClient.createChannel.$post>['json'];
export type UpdateChannelRequest = InferRequestType<typeof channelClient.updateChannel.$post>['json'];
export type DeleteChannelRequest = InferRequestType<typeof channelClient.deleteChannel.$post>['json'];
export type SearchChannelsRequest = InferRequestType<typeof channelClient.searchChannels.$get>['query'];
// 注意：渠道模块使用自定义路由，没有批量删除功能

// 渠道列表查询参数
export type GetChannelsQuery = {
  skip?: number;
  take?: number;
};

// 渠道详情查询参数
export type GetChannelDetailParam = {
  id: string;
};

// 响应类型
export type ChannelResponse = InferResponseType<typeof channelClient.createChannel.$post, 200>;
export type ChannelListResponse = InferResponseType<typeof channelClient.getAllChannels.$get, 200>;
// 根据后台模块集成测试，路由结构是getChannel[':id'].$get
export type ChannelDetailResponse = InferResponseType<typeof channelClient.getChannel[':id']['$get'], 200>;
export type SearchChannelsResponse = InferResponseType<typeof channelClient.searchChannels.$get, 200>;

// 渠道项类型 - 从列表响应中提取（按照广告管理UI的模式）
export type ChannelListItem = ChannelListResponse['data'][0];