// 分类字典类型定义

export interface CategoryDictionary {
  id: string;
  code: string;
  name: string;
  category: string; // 字典分类
  value: string;
  label: string;
  sortOrder: number;
  description?: string;
  isSystem: boolean; // 是否系统内置
  isActive: boolean;
  extendData?: Record<string, any>;
  createdAt: string;
  updatedAt: string;
}

export type DictionaryCategory =
  | 'gender'
  | 'status'
  | 'unit'
  | 'weather'
  | 'soil_type'
  | 'irrigation_method'
  | 'fertilizer_type'
  | 'pesticide_type'
  | 'task_status'
  | 'task_priority'
  | 'approval_status'
  | 'operation_type'
  | 'other';

// 分类表单数据
export interface CategoryFormData {
  code: string;
  name: string;
  category: string;
  value: string;
  label: string;
  sortOrder: number;
  description: string;
  isActive: boolean;
}

// 分类操作类型
export type CategoryAction =
  | { type: 'SET_CATEGORIES'; payload: CategoryDictionary[] }
  | { type: 'ADD_CATEGORY'; payload: CategoryDictionary }
  | { type: 'UPDATE_CATEGORY'; payload: { id: string; updates: Partial<CategoryDictionary> } }
  | { type: 'DELETE_CATEGORY'; payload: string }
  | { type: 'SET_SEARCH_KEYWORD'; payload: string }
  | { type: 'SET_CATEGORY_FILTER'; payload: string }
  | { type: 'SET_DIALOG_STATE'; payload: { open: boolean; editing?: CategoryDictionary | null } }
  | { type: 'SET_FORM_DATA'; payload: Partial<CategoryFormData> };

// 分类状态
export interface CategoryState {
  categories: CategoryDictionary[];
  searchKeyword: string;
  categoryFilter: string;
  dialogState: {
    open: boolean;
    editing?: CategoryDictionary | null;
  };
  formData: CategoryFormData;
}