// types.ts
export interface TagItem {
  id: number;
  tagName: string;
  createTime: string;
  groupId?: number; // 可选，因为API返回的数据可能没有这个字段
}

export interface GroupItem {
  id: number;
  groupName?: string;
  createTime?: string;
  tags?: TagItem[];
}

// API响应类型
export interface TagsResponse {
  list: TagItem[];
  total: number;
}

// export interface GroupsResponse {
//   data: GroupItem[];
// }

// 核心组件的Props
export interface GroupTagCoreProps {
  // groups: GroupItem[];
  requset: RequsetConfig;
  height?: number;
  editable?: boolean;
  onChange?: (value: TagItem[]) => void;
  value: TagItem[];
  // selectedTags: number[];
  // onTagChange?: (selectedTags: number[]) => void;
  // onGroupClick?: (groupId: number) => void;
  // onLoadMoreTags?: (groupId: number, page: number) => Promise<TagsResponse>;
  // loading?: boolean;
  // loadingGroups?: Set<number>;
  // loadingMoreTags?: Set<number>;
  // editable?: boolean;
  // onAddGroup?: () => void;
  // onAddTag?: (groupId: number) => void;
  // onDeleteGroup?: (groupId: number) => Promise<void> | void;
  // onDeleteTag?: (tagId: number) => Promise<void> | void;
  // onEditGroup?: (groupId: number, newName: string) => Promise<void> | void;
  // onEditTag?: (tagId: number, newName: string) => Promise<void> | void;
  // className?: string;
  // height?: number;
  // showSearch?: boolean;
  // pageSize?: number;
}

interface RequsetConfig<T = any> {
  groupsApi: {
    get: (params?: T) => Promise<any>;
    create: (params: any) => Promise<any>;
    delete: (id: number) => Promise<any>;
    update: (params: T) => Promise<any>;
  };
  tagsApi: {
    get: (params?: T) => Promise<any>;
    create: (params: T) => Promise<any>;
    delete: (id: number) => Promise<any>;
    update: (params: T) => Promise<any>;
  };
}
// Select组件的Props
export interface GroupTagSelectProps {
  value?: number[];
  onChange?: (value: number[]) => void;
  placeholder?: string;
  className?: string;
  request: RequsetConfig;
  editable?: boolean;
  // onAddGroup?: (groupName: string) => Promise<void> | void;
  // onAddTag?: (groupId: number, tagName: string) => Promise<void> | void;
  // onDeleteGroup?: (groupId: number) => Promise<void> | void;
  // onDeleteTag?: (tagId: number) => Promise<void> | void;
  // pageSize?: number;
}

// Modal组件的Props
export interface GroupTagModalProps {
  visible: boolean;
  editable?: boolean;
  onChange?: (value: TagItem[]) => void;
  className?: string;
  onCancel: () => void;
  request: RequsetConfig;
  onOk?: (selectedTags: TagItem[]) => void;
  title?: string;
  width?: number;
  height?: number;
  value?: TagItem[];
}
