import type { AppState, StateRepository } from '@domain/ports/StateRepository';
import { addDragodinde } from '@domain/entities/Enclos';

export interface AddDragodindeCommand { type: 'add-dragodinde'; enclosId: number; }

export function createAddDragodindeHandler(state: AppState, repo: StateRepository) {
  return (cmd: AddDragodindeCommand): void => {
    const idx = state.enclos.findIndex(e => e.id === cmd.enclosId);
    if (idx < 0) return;
    state.enclos[idx] = addDragodinde(state.enclos[idx]!);
    repo.save(state);
  };
}
