import React from 'react';

export interface Pagination {
  current: number;
  pageSize: number;
  total: number;
}

export interface BaseState {
  pagination: Pagination;
  searchString: string;
}

export interface IModalProps<T> {
  showModal?(): void;
  hideModal?(): void;
  switchVisible?(visible: boolean): void;
  visible?: boolean;
  loading?: boolean;
  onOk?(payload?: T): Promise<any> | void;
}

export interface ResponseType {
  code: number;
  message?: string;
  data?: any;
}

// Dialog相关接口定义
export interface IDialogConfig {
  title?: string;
  content?: React.ReactNode;
  type?: 'info' | 'success' | 'warning' | 'error' | 'confirm';
  confirmText?: string;
  cancelText?: string;
  showCancel?: boolean;
  maskClosable?: boolean;
  width?: number | string;
  onConfirm?: () => void | Promise<void>;
  onCancel?: () => void;
}

export interface IDialogInstance {
  id: string;
  config: IDialogConfig;
  resolve: (value: boolean) => void;
  reject: (reason?: any) => void;
}

export interface IDialogContextValue {
  dialogs: IDialogInstance[];
  openDialog: (config: IDialogConfig) => Promise<boolean>;
  closeDialog: (id: string, result?: boolean) => void;
  confirm: (config: Omit<IDialogConfig, 'type'>) => Promise<boolean>;
  info: (config: Omit<IDialogConfig, 'type'>) => Promise<boolean>;
  success: (config: Omit<IDialogConfig, 'type'>) => Promise<boolean>;
  warning: (config: Omit<IDialogConfig, 'type'>) => Promise<boolean>;
  error: (config: Omit<IDialogConfig, 'type'>) => Promise<boolean>;
}
