export interface LandClassificationState {
  fields: any[];
  tags: any[];
  soilTypes: any[];
  plantingModes: any[];
  showTagManagement: boolean;
  showClassificationManagement: boolean;
}

export const initialState: LandClassificationState = {
  fields: [],
  tags: [],
  soilTypes: [],
  plantingModes: [],
  showTagManagement: false,
  showClassificationManagement: false,
};

export type LandClassificationAction =
  | { type: 'SET_FIELDS'; payload: any[] }
  | { type: 'SET_TAGS'; payload: any[] }
  | { type: 'SET_SOIL_TYPES'; payload: any[] }
  | { type: 'SET_PLANTING_MODES'; payload: any[] }
  | { type: 'SET_SHOW_TAG_MANAGEMENT'; payload: boolean }
  | { type: 'SET_SHOW_CLASSIFICATION_MANAGEMENT'; payload: boolean };

export function LandClassificationReducer(state: LandClassificationState, action: LandClassificationAction): LandClassificationState {
  switch (action.type) {
    case 'SET_FIELDS':
      return { ...state, fields: action.payload };
    case 'SET_TAGS':
      return { ...state, tags: action.payload };
    case 'SET_SOIL_TYPES':
      return { ...state, soilTypes: action.payload };
    case 'SET_PLANTING_MODES':
      return { ...state, plantingModes: action.payload };
    case 'SET_SHOW_TAG_MANAGEMENT':
      return { ...state, showTagManagement: action.payload };
    case 'SET_SHOW_CLASSIFICATION_MANAGEMENT':
      return { ...state, showClassificationManagement: action.payload };
    default:
      return state;
  }
}