import 'package:farm_tpf/custom_model/action_form/RequestActivity.dart';
import 'package:get/get_state_manager/get_state_manager.dart';

class ChangeWorker extends GetxController {
  List<TbNurseryDetailsDTO>? currentItems;
  TbNurseryDetailsDTO? currentItem;
  int? currentIndex;
  void init(List<TbNurseryDetailsDTO> initItems) {
    currentItems = initItems ?? [];
    currentItem = TbNurseryDetailsDTO();
    currentIndex = -1;
    update();
  }

  void changeIndexEdit(int index) {
    currentIndex = index;
    update();
  }

  void changeInitList(List<TbNurseryDetailsDTO> initListWorkers) {
    currentItems = initListWorkers;
    update();
  }

  void addNurseryDetail(TbNurseryDetailsDTO nurseryDetail) {
    currentItems?.insert(0, nurseryDetail);
    currentItem = TbNurseryDetailsDTO();
    update();
  }

  void deleteNurseryDetail(int index) {
    currentItems?.removeAt(index);
    currentItem = TbNurseryDetailsDTO();
    update();
  }
}
