import 'package:farm_tpf/custom_model/Supply.dart';
import 'package:get/get.dart';

class ChangeSupply extends GetxController {
  late Supply currentSupply;
  late int selectedSupplyId;
  late String selectedSupplyName;
  late String unit;
  late bool isValid;

  void initValue() {
    currentSupply = Supply();
    selectedSupplyName = "";
    selectedSupplyId = -1;
    unit = "";
    isValid = true;
    update();
  }

  void change(Supply supply) {
    currentSupply = supply;
    selectedSupplyId = supply.id ?? -1;
    selectedSupplyName = supply.tbSuppliesName ?? '';
    unit = supply.unit ?? '';
    update();
  }

  void changeByIdAndName(int supplyId, String supplyName, {String? unitName}) {
    selectedSupplyId = supplyId;
    selectedSupplyName = supplyName;
    unit = unitName ?? '';
    update();
  }

  void changeValid(bool valid) {
    isValid = valid;
    update();
  }
}
