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

// 公司列表查询参数类型
export type CompanySearchParams = {
  page: number;
  limit: number;
  search: string;
};

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

// 使用Hono类型推导 - 基于公司模块的自定义路由
export type CreateCompanyRequest = InferRequestType<typeof companyClient.createCompany.$post>['json'];
export type UpdateCompanyRequest = InferRequestType<typeof companyClient.updateCompany.$post>['json'];
export type DeleteCompanyRequest = InferRequestType<typeof companyClient.deleteCompany.$post>['json'];
export type SearchCompanyRequest = InferRequestType<typeof companyClient.searchCompanies.$get>['query'];
export type GetAllCompaniesRequest = InferRequestType<typeof companyClient.getAllCompanies.$get>['query'];

// 公司详情查询参数
export type GetCompanyDetailParam = {
  id: string;
};

// 按平台获取公司查询参数
export type GetCompaniesByPlatformParam = {
  platformId: string;
};

// 响应类型
export type CreateCompanyResponse = InferResponseType<typeof companyClient.createCompany.$post, 200>;
export type UpdateCompanyResponse = InferResponseType<typeof companyClient.updateCompany.$post, 200>;
export type DeleteCompanyResponse = InferResponseType<typeof companyClient.deleteCompany.$post, 200>;
export type CompanyListResponse = InferResponseType<typeof companyClient.getAllCompanies.$get, 200>;
export type SearchCompanyResponse = InferResponseType<typeof companyClient.searchCompanies.$get, 200>;
// 根据后台模块集成测试，路由结构是getCompany[':id'].$get
export type CompanyDetailResponse = InferResponseType<typeof companyClient.getCompany[':id']['$get'], 200>;
export type CompaniesByPlatformResponse = InferResponseType<typeof companyClient.getCompaniesByPlatform[':platformId']['$get'], 200>;

// 公司项类型 - 从列表响应中提取
export type CompanyListItem = CompanyListResponse['data'][0];
export type CompanyResponse = CompanyListItem;