import 'package:rasadyar_chicken/data/models/response/poultry_science/home_poultry_science/home_poultry_science_model.dart';
import 'package:rasadyar_chicken/presentation/pages/poultry_science/root/logic.dart';
import 'package:rasadyar_core/core.dart';

class PoultryScienceHomeLogic extends GetxController {
  PoultryScienceRootLogic rootLogic = Get.find<PoultryScienceRootLogic>();
  Rxn<HomePoultryScienceModel> homeInformation = Rxn();
  RxBool isExpanded = false.obs;

  @override
  void onReady() {
    super.onReady();
    getHomePoultryHatching();
  }

  Future<void> getHomePoultryHatching() async {
    await safeCall<HomePoultryScienceModel?>(
      call: () async => await rootLogic.poultryRepository.getHomePoultry(
        token: rootLogic.tokenService.accessToken.value!,
        type: 'home',
      ),
      onSuccess: (result) {
        if (result != null) {
          homeInformation.value = result;
        }
      },
      onError: (error, stackTrace) {},
    );
  }
}
